class Problem( object ) | Source |
---|
Problem implements the common parts of specialized Problems.
A Problem is an optimization of parameters which does not involve the fitting of data to a Model.
Problems can be solved by NestedSampler, with appropriate Engines and ErrorDistributions.
The result of the function for certain x and p is given by problem.result( x, p ) The parameters, p, are to be optimized while the x provide additional information.
This class is a base class. Further specializations will define the result method.
Attributes
-
model : Model
to be optimized -
xdata : array_like
independent variable (static) -
ydata : array_like
dependent variable (static) -
weights : array_like
weights associated with ydata -
varyy : float or ndarry of shape (ndata,)
Variance in the errors of the ydata -
npars : int
number of parameters in the model of the problem -
partype : float | int
type of the parameters -
Author : Do Kester
Problem( model=None, xdata=None, ydata=None, weights=None, accuracy=None, copy=None ) |
---|
Problem Constructor.
Parameters
- model : Model
the model to be solved - xdata : array_like or None
independent variable - ydata : array_like or None
dependent variable - weights : array_like or None
weights associated with ydata - accuracy : float or ndarray of shape (ndata,)
accuracy scale for the datapoints
all the same or one for each data point - copy : Problem
to be copied
copy( ) |
---|
setAccuracy( accuracy=None ) |
---|
Paramaters
- accuracy : float or array of NDATA floats or None
Either one value for all or one for each data point
When None the value is set to 0 (for easy computational reasons)
hasWeights( ) |
---|
Return whether it has weights.
result( param ) |
---|
In this (base)class it is a placeholder.
Parameters
- param : array_like
values for the parameters.
residuals( param, mockdata=None ) |
---|
Parameters
- param : array_like
values for the parameters. - mockdata : array_like
model fit at xdata
cyclicCorrection( res ) |
---|
Returns
the residuals, unadultered
Parameters
- res : array_like
residuals
cycor1( res ) |
---|
Parameters
- res : array_like
residuals
cycor2( res ) |
---|
Parameters
- res : array_like
residuals
cyclize( res, period ) |
---|
If the model results in a phase value of +ε while the data give that phase value as (p - ε) to keep all data in the range [0,p], the naive residual would be (p - 2 ε) while the actual distance should be measured the other way around as (2 ε). Here p = period and ε = small deviation.
Parameters
- res : array_like
original residuals - period : float
of the phase space
Returns
corrected residuals.
weightedResSq( allpars, mockdata=None, extra=False ) |
---|
Optionally (extra=True) the weighted residuals themselves are returned too.
Parameters
- allpars : array_like
values for the parameters. - mockdata : array_like
model fit at xdata - extra : bool (False)
true : return ( wgt * res^2, wgt * res )
false : return wgt * res2
isDynamic( ) |
---|
domain2Unit( dval, kpar ) |
---|
Parameters
- dval : float
domain value for the selected parameter - kpar : array_like
selected parameter index, where kp is index in [parameters, hyperparams]
unit2Domain( uval, kpar ) |
---|
Parameters
- uval : array_like
unit value for the selected parameter - kpar : array_like
selected parameter indices, where kp is index in [parameters, hyperparams]
shortName( ) |
---|
baseName( ) |
---|