Module forward_model
source code
This module contains classes that aid in constructing cost functions.
Cost function can easily be created by hand; however, mystic also
provides an automated method that allows the dynamic wrapping of forward
models into cost function objects.
Usage
The basic usage pattern for a cost factory is to generate a cost
function from a set of data points and a corresponding set of
evaluation points. The cost factory requires a "forward model
factory", which is just a generator of forward model instances
from a list of coefficients. The following example uses numpy.poly1d,
which provides a factory for generating polynomials. An expanded
version of the following can be found in
`mystic.examples.example12`.
>>>
>>> from numpy import array, sum, poly1d, random
>>> ForwardFactory = poly1d
>>> pts = 0.1*(numpy.array([range(101)])50.)[0]
>>>
>>>
>>> target = [2.,5.,3.]
>>> datapts = [random.normal(0,1) + i for i in ForwardFactory(target)(pts)]
>>>
>>>
>>> from mystic.forward_model import CostFactory
>>> F = CostFactory()
>>>
>>>
>>> costmetric = lambda x: numpy.sum(x*x)
>>> F.addModel(ForwardFactory, name='example', inputs=len(target))
>>> costfunction = F.getCostFunction(evalpts=pts, observations=datapts,
... sigma=1.0, metric=costmetric)
>>>
>>>
>>> initial_guess = [1.,2.,1.]
>>> solution = fmin_powell(costfunction, initial_guess)
In general, a user will be required to write their own model
factory. See the examples contained in `mystic.models` for more
information.
The CostFactory can be used to couple models together into a single
cost function. For an example, see `mystic.examples.forward_model`.

ForwardModel1
A simple utility to 'prettify' object representations of forward
models.


CostFactory
A cost function generator.
