Bases: pymodelfit.core.FunctionModel
Models a plane of the form
i.e. (a,b,c) is the normal vector and d/a, b ,or c are the intercepts.
Methods
__init__([varorder, vn, wn, origin]) | |
chi2Data([x, y, weights, ddof]) | Computes the chi-squared statistic for the data assuming this model. |
distance(x, y, z) | compute the distance of a set of points in the 3D space from |
f(x[, a, b, c, d]) | |
fitData(x, y, z[, w]) | Least squares fit using the output variable as the dependent variable. |
getCov() | Computes the covariance matrix for the last fitData() call. |
getMCMC(x, y[, priors, datamodel]) | Generate an Markov Chain Monte Carlo sampler for the data and model. |
inv(output, *args, **kwargs) | Compute the inverse of this model for the requested output. |
isVarnumModel() | Determines if the model represented by this class accepts a variable number of parameters (i.e. |
plot3d((data=array([[-1, 1], [-1, ...) | data should be 3 x N |
proj(x, y, z) | Project points onto the plane from the 3D space |
resampleFit([x, y, xerr, yerr, bootstrap, ...]) | Estimates errors via resampling. |
residuals([x, y, retdata]) | Compute residuals of the provided data against the model. |
stdData([x, y]) | Determines the standard deviation of the model from data. |
unproj(v, w) | Extract points from the plane back into the 3D space |
Attributes
data | The fitting data for this model. |
defaultparval | int(x=0) -> int or long |
errors | Error on the data. |
fittype | str(object=’‘) -> string |
fittypes | A Sequence of the available valid values for the fittype |
fixedpars | tuple() -> empty tuple |
n | non-normalized unit vector |
nhat | normalized unit vector |
origin | |
params | A tuple of the parameter names. |
pardict | A dictionary mapping parameter names to the associated values. |
parvals | The values of the parameters in the same order as params |
rangehint | |
varorder | |
vn | 3D vector to project on to plane to get 2D basis vector 1 |
weightstype | Determines the statistical interpretation of the weights in data. |
wn | 3D vector to project on to plane to get 2D basis vector 2 |
Computes the chi-squared statistic for the data assuming this model.
Parameters: |
|
---|---|
Returns: | tuple of floats (chi2,reducedchi2,p-value) |
The fitting data for this model. Should be either None, or a tuple(datain,dataout,weights). Note that the weights are interpreted statistically as errors based on the weightstype attribute.
Error on the data. Sets the weights on data assuming the interpretation for errors given by weightstype. If data is None/missing, a TypeError will be raised.
Least squares fit using the output variable as the dependent variable.
A Sequence of the available valid values for the fittype attribute. (Read-only)
Computes the covariance matrix for the last fitData() call.
Returns: | The covariance matrix with variables in the same order as params. Diagonal entries give the variance in each parameter. |
---|
Warning
This is not guaranteed to work for custom fit-types, but will always work with the default (leastsq) fit.
Generate an Markov Chain Monte Carlo sampler for the data and model. This function requires the PyMC package for the MCMC internals and sampling.
Parameters: |
|
---|---|
Raises ValueError: | |
If a prior is not provided for any parameter. |
|
Returns: | A pymc.MCMC object ready to sample for this model. |
Compute the inverse of this model for the requested output.
Parameters: | output – The output value of the model at which to compute the inverse. |
---|---|
Returns: | The input value at which the model produces output |
Raises ModelTypeError: | |
If the model is not invertable for the provided data set. |
Determines if the model represented by this class accepts a variable number of parameters (i.e. number of parameters is set when the object is created).
Returns: | True if this model has a variable number of parameters. |
---|
A tuple of the parameter names. (read-only)
A dictionary mapping parameter names to the associated values.
data should be 3 x N
Project points onto the plane from the 3D space
Parameters: |
|
---|---|
Returns: | A 2 x N array in the plane for each of the input points. |
Estimates errors via resampling. Uses the fitData function to fit the function many times while either using the “bootstrap” technique (resampling w/replacement), monte carlo estimates for the error, or both to estimate the error in the fit.
Parameters: |
|
---|
kwargs are passed into fitData
Returns: | (histd,cov) where histd is a dictionary mapping parameters to their histograms and cov is the covariance matrix of the parameters in parameter order. |
---|
Note
If x, y, xerr, or yerr are provided, they do not overwrite the stored data, unlike most other methods for this class.
Compute residuals of the provided data against the model. E.g. .
Parameters: | |
---|---|
Returns: | Residuals of model from y or if retdata is True, a tuple (x,y,residuals). |
Return type: | array-like |
Determines the standard deviation of the model from data. Data can either be provided or (by default) will be taken from the stored data.
Parameters: | |
---|---|
Returns: | standard deviation of model from y |
Extract points from the plane back into the 3D space
Parameters: |
|
---|---|
Returns: | a 3 x N (x,y,z) array |
3D vector to project on to plane to get 2D basis vector 1
Determines the statistical interpretation of the weights in data. Can be:
Weights act as inverse errors (default)
Weights act as inverse variance
Weights act as errors (non-standard - this makes points with larger error bars count more towards the fit).
Weights act as variance (non-standard - this makes points with larger error bars count more towards the fit).
3D vector to project on to plane to get 2D basis vector 2