Package park :: Package modelling :: Module parameter :: Class Parameter

Class Parameter

source code


A parameter is a box for communicating with the fitting service. Parameters can have a number of properties,

Parameters have a number of properties:

name "string"

name of the parameter within the parameter set.

The name is read only. You can rename a parameter but only in the context of the parameter set which contains it, using parameterset.rename(par,name). This will change all expressions containing the named parameter.

path
dotted name of the parameter within the set of models. The dotted name is automatically generated by the parameter set before expressions are parsed and evaluated. There are some operations on parameter sets (such as renaming the layer containing a parameter) which will force an adjustment of all the underlying parameter names, as well as any expressions in which they are referenced.
limits (low, high)
hard limits on the range of allowed parameter values, dictated by physics rather than by knowledge of the particular system. For example, thickness parameters would have limits (0,inf) because negative thicknesses are unphysical. These limits are enforced when setting range for the fit.
units "string"
units for the parameter. This should be a string, but be parsable by whatever units package your application supports.
tip "string"
parameter description, suitable for use in a tooltip
value double
current value of the parameter, either fixed, fitted or computed
range (low, high)
range of expected values for the parameter in the model
expression "string"

expression for the parameter in the model. This is a string containing a formula for updating the parameter value based on the values of other parameters in the system. The expression is ignored if 'calculated' is False.

Note: the list of symbols available to the expression evaluator defaults to the contents of the math module. The caller will be able to override this within the fitting fitting class.

status 'fixed'|'computed'|'fitted'
the parameter type. Choose 'fixed' if the values is to remain fixed throughout the fit, even if a range and an expression have been specified. Choose 'computed' if the value of the parameter is to be computed each time the parameters are updated. Choose 'fitted' if an optimization algorithm is supposed to search the parameter space.
likelihood

function to return the negative log likelihood of seeing a particular parameter value. 2*likelihood(value) will be added to the total cost function for the particular parameter set during the fit. This will be on par with the probabilty of seeing the particular theory function given the observed datapoints when performing the fit (the residual term is closely related to the log likelihood of the normal distribution).

Note: we are minimizing chi^2 = sum [ ((y-f(x;p))/dy)^2 ] rather than -log P = sum [ ((y-f(x;p))/dy)^2/2 + log(2 pi dy^2) ], where P is the probability of seeing f(x;p) given y,dy as the mean and standard deviation of a normal distribution. Because chi^2_p = - 2 * log P_p + constant, the minima of p are the same for chi^2 and negative log likelihood. However, to weight the likelihood properly when adding likelihood values to chisq, we need the extra factor of 2 mentioned above. The usual statistical implications of normalized chi^2 will of course be suspect, both because the assumption of independence between the points in chi^2 (which definitely do not hold for the new 'point' p_k), and because of the additional 2 log(2 pi dp_k^2) constant, but given the uncertainty in the estimate of the distribution parameters, this is likely a minor point.

Instance Methods
 
__init__(self, name='unknown', **kw)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
source code
 
__str__(self)
str(x)
source code
 
__repr__(self)
repr(x)
source code
 
summarize(self)
Return parameter range string.
source code
 
isfitted(self) source code
 
iscomputed(self) source code
 
isfixed(self) source code
 
isrestrained(self) source code
 
isfeasible(self, value)
Return true if the value is in the range
source code
 
setprefix(self, prefix)
Set the full path to the parameter as used in expressions involving the parameter name.
source code
 
get(self)
Return the current value for a parameter.
source code
 
set(self, value)
Set a parameter to a value, a range or an expression.
source code

Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __setattr__

Class Variables
  path = ''
  value = 0.0
  limits = (-inf, inf)
  expression = ''
  status = 'fixed'
  likelihood = None
  units = ''
  tip = 'Fitting parameter'
  deriv = False
Properties
  name
parameter name
  range
parameter range

Inherited from object: __class__

Method Details

__init__(self, name='unknown', **kw)
(Constructor)

source code 
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
Overrides: object.__init__
(inherited documentation)

__str__(self)
(Informal representation operator)

source code 
str(x)
Overrides: object.__str__
(inherited documentation)

__repr__(self)
(Representation operator)

source code 
repr(x)
Overrides: object.__repr__
(inherited documentation)

summarize(self)

source code 

Return parameter range string.

E.g., " Gold .....|.... 5.2043 in [2,7]"

set(self, value)

source code 

Set a parameter to a value, a range or an expression. If it is a value, the parameter will be fixed for the fit. If it is a range, the value will be varying for the fit. If it is an expression, the parameter will be calculated from the values of other parameters in the fit.

Raises ValueError if the value could not be interpreted.


Property Details

name

parameter name
Get Method:
_getname(self)

range

parameter range
Get Method:
_getrange(self)
Set Method:
_setrange(self, r)