BasicSplinesModel = class BasicSplinesModel(SplinesModel) |
|
BasicSplinesModel(knots=None, order=3, nrknots=None, min=None, max=None,
xrange=None, border=0, copy=None, **kwargs)
Splines model consisting of a basis of spline blobs.
The blobs have limited support. Each blob is a segment of polynomial order,
between 2 knots. At the knots they are continuous (differentiable) upto order - 1.
Similarly the edges of the blobs are smoothly connected to 0.
order support behaviour between knots continuity at knots
0 1 piecewise constant not continuous at all
1 2 piecewise linear lines are continuous (connected)
2 3 parabolic pieces 1st derivatives are also continuous
3 4 cubic pieces 2nd derivatives are also continuous
n>3 n+1 n-th order polynomials (n-1)-th derivatives are also continuous
The function result is the sum over all spline blobs, multiplied with
the parameters, the amplitudes of the spline blobs.
The support of the knots defined the domain where the function is defined. They are
hard edges. Consequently the function is not continuous or differentiable at the edges.
The spline blobs at the edges may be different from the ones in the middle.
From SplinesModel
-----------------
The user lays out a number ( << datapoints ) of knots on the x-axis at
arbitrary position, generally more knots where the curvature is higher.
The knots need to be monotonuously increasing in x.
Alternatively one can ask this class to do the lay-out which is then
equidistant in x over the user-provided range.
Through these knots a splines function is obtained which best
fits the datapoints. One needs at least 2 knots, one smaller and one
larger than the x-values in the dataset.
This model is NOT for (cubic) spline interpolation.
Examples
--------
>>> knots = numpy.arange( 17, dtype=float ) * 10 # make equidistant knots from 0 to 160
>>> csm = BasicSplinesModel( knots=knots, order=2 )
>>> print csm.getNumberOfParameters( )
18
# or alternatively:
>>> csm = SplinesModel( nrknots=17, order=2, min=0, max=160 ) # automatic layout of knots
>>> print csm.getNumberOfParameters( )
18
# or alternatively:
>>> npt = 161 # to include both 0 and 160.
>>> x = numpy.arange( npt, dtype=float ) # x-values
>>> csm = BasicSplinesModel( nrknots=17, order=2, xrange=x ) # automatic layout of knots
>>> print csm.getNumberOfParameters( )
18
Attributes
----------
knots : array_like
positions of the spline knots
order : int
order of the spline. default: 3
Attributes from Model
---------------------
npchain, parameters, stdevs, xUnit, yUnit
Attributes from FixedModel
--------------------------
npmax, fixed, parlist, mlist
Attributes from BaseModel
--------------------------
npbase, ndim, priors, posIndex, nonZero,
tiny, deltaP, parNames
Limitations
-----------
Dont construct the knots so closely spaced, that there are no datapoints in between. |
|
- Method resolution order:
- BasicSplinesModel
- SplinesModel
- LinearModel
- Model
- FixedModel
- BaseModel
- builtins.object
Constructor:
- BasicSplinesModel( knots=None, order=3, nrknots=None, min=None, max=None,
xrange=None, border=0, copy=None, **kwargs)
- Splines on a given set of knots and a given order.
The number of parameters is ( length( knots ) + order - 1 )
Parameters
----------
knots : array_like
a array of arbitrarily positioned knots
order : int
order of the spline. Default 3 (cubic splines)
nrknots : int
number of knots, equidistantly posited over xrange or [min,max]
border : [0, 1, 2]
defines what happens at the borders of the knot range.
0 : Just like de Boors b-splines.
the model is NOT defined outside the knot range.
1 : periodic, make knot[0] the same as knot[-1]
2 : easy borders. the model is slightly extensable.
min : float
minimum of the knot range
max : float
maximum of the knot range
xrange : array_like
range of the xdata
copy : BasicSplinesModel
model to be copied.
fixed : None or dictionary of {int:float|Model}
int index of parameter to fix permanently.
float|Model values for the fixed parameters.
Attribute fixed can only be set in the constructor.
See: FixedModel
Raises
------
ValueError : At least either (`knots`) or (`nrknots`, `min`, `max`) or
(`nrknots`, `xrange`) must be provided to define a valid model.
Notes
-----
The SplinesModel is only strictly valid inside the domain defined by the
minmax of knots. It deteriorates fastly going outside the domain.
Methods defined here:
- baseDerivative( xdata, params )
- Return the derivative df/dx at each xdata (=x).
Parameters
----------
xdata : array_like
value at which to calculate the partials
params : array_like
parameters to the model
- baseName()
- Returns a string representation of the model.
- baseParameterUnit( k )
- Return the name of the parameter.
Parameters
----------
k : int
index of the parameter.
- basePartial( xdata, params, parlist=None )
- Returns the partials at the input value.
The partials are the powers of x (input) from 0 to degree.
Parameters
----------
xdata : array_like
value at which to calculate the partials
params : array_like
parameters to the model (ignored in LinearModels)
parlist : array_like
list of indices active parameters (or None for all)
- baseResult( xdata, params )
- Returns the functional result at the input value.
Parameters
----------
xdata : array_like
value at which to calculate the partials
params : array_like
parameters to the model (ignored in LinearModels)
- basicBlob( xdata, basis, x2k, poly )
- Calculates a spline blob for all of xdata
Parameters
----------
xdata : array_like
value at which to calculate the spline
basis : array_like
splineParameters
x2k : int_array
pointing to the knot preceeding each xdata point
poly : PolynomialModel
model to calculate the splines
- copy()
- Return a copy.
- findParameters( knotix, dist, kpar=0)
- Find the parameters by assuming (order-1) continuous differentials.
At the edges it is less. Normalized to 1.0
Parameters
----------
knotix : int array
knot indices involved in this spline blob
dist : array_like
distances between knots
kpar : int
index of parameter for which the spline-blob is constructed
Returns
-------
par : 2-d array
sets of poly parameters.
- makeBaseBasis()
- Make a sets of polynomial bases for each of the parameters
Return
------
basis : 3-d array-like
parameters to the polynomials that make up the spline blobs
- makeDist( knotix )
- makeKnotIndices( xdata )
- Return a list of indices of the knots immediately preceeding the xdata.
Parameters
----------
xdata : array_like
values at which to calculate the indices
- makePeriodicBasis()
- Make a sets of polynomial bases for each of the parameters
Return
------
basis : 3-d array-like
parameters to the polynomials that make up the spline blobs
- normalizeBasis( basis )
- Normalize the base splines such that a constant value of 1.0
is returned when all model parameters are 1.
Parameters
----------
basis : array_like
parameters to the polynomials that make up the spline blobs
Methods inherited from Model:
Overloaded operators and aliases
Other methods
- addModel( model )
- appendModel( model, operation )
- assignDF1( partial, i, dpi )
- assignDF2( partial, i, dpi )
- chainLength()
- correctParameters( params )
- derivative( xdata, param, useNum=False )
- divideModel( model )
- domain2Unit( dvalue, kpar=None )
- getIntegralUnit()
- getLimits()
- getLinearIndex()
- getNumberOfParameters()
- getParameterName( k )
- getParameterUnit( k )
- getPrior( k )
- hasLimits( fitindex=None )
- hasPriors( isBound=True )
- isDynamic()
- isMixed()
- isNullModel()
- isolateModel( k )
- multiplyModel( model )
- nextPrior()
- numDerivative( xdata, param )
- numPartial( xdata, param )
- operate( res, pars, next )
- partial( xdata, param, useNum=False )
- partialDomain2Unit( dvalue )
- pipeModel( model )
- pipe_0( dGd, dHdG)
- pipe_1( dGd, dHdG)
- pipe_2( dGd, dHdG)
- pipe_3( dGd, dHdG)
- pipe_4( dGdx, dHdG)
- pipe_5( dGdx, dHdG)
- pipe_6( dGdx, dHdG)
- pipe_7( dGdx, dHdG)
- pipe_8( dGdx, dHdG)
- pipe_9( dGdx, dHdG)
- result( xdata, param=None )
- selectPipe( ndim, ninter, ndout )
- setLimits( lowLimits=None, highLimits=None )
- setPrior( k, prior=None, **kwargs )
- shortName()
- strictNumericDerivative( xdata, param )
- strictNumericPartial( xdata, params, parlist=None )
- subtractModel( model )
- testPartial( xdata, params, silent=True )
- unit2Domain( uvalue, kpar=None )
Methods inherited from FixedModel:
Methods inherited from BaseModel:
|
|