determine_smoothing_spline

sofia_redux.toolkit.splines.spline_utils.determine_smoothing_spline(knots, n_knots, knot_estimate, degrees, initial_sum_square_residual, smoothing, smoothing_difference, n_coefficients, bandwidth, amat, beta, max_iteration, knot_steps, knot_mapping, eps, splines, start_indices, next_indices, panel_mapping, spline_mapping, coordinates, values, weights, panel_shape, accuracy)[source]

Smooth the current solution to a specified level.

Parameters:
knotsnumpy.ndarray (float)

The knots in each dimension of shape (n_dimensions, max_knot_estimate). Must be monotonically increasing for each dimension.

n_knotsnumpy.ndarray (int)

The number of knots in each dimension of shape (n_dimensions,).

knot_estimatenumpy.ndarray (int)

The maximum number of knots allowable of shape (n_dimensions,).

degreesnumpy.ndarray (int)

The degrees of the spline in each dimension (n_dimensions,).

initial_sum_square_residualfloat

The initial sum square of the residuals from the first knot fit.

smoothingfloat

Used to specify the smoothing factor.

smoothing_differencefloat

The sum of the square residuals minus the smoothing factor.

n_coefficientsint

The number of coefficients to fit.

bandwidthint

The bandwidth of the observation.

amatnumpy.ndarray (float)

The ‘A’ in the system Ax = B of shape (>=n_coefficients, >=bandwidth).

betanumpy.ndarray (float)

The ‘B’ in the system Ax = B of shape (>=n_coefficients,).

max_iterationint

The maximum number of iterations used to determine the smoothing spline.

knot_stepsnumpy.ndarray (int)

The flat index mapping steps in knot-space of shape (n_dimensions,). These are returned by passing the shape (n_knots - degrees - 1) into flat_index_mapping().

knot_mappingnumpy.ndarray (int)

An array containing the knot mapping (flat to n-D) indices. This is created by passing the shape (n_knots - degrees - 1) into flat_index_mapping(). Should be an array of shape (n_dimensions, n_panels).

epsfloat

The precision to determine singular values of A. If any row of amat[:,0] < (eps * max(amat[:,0])) it will be considered singular.

splinesnumpy.ndarray (float)

The splines of shape (n_dimensions, n_data, max(k1)).

start_indicesnumpy.ndarray (int)

The starting indices of shape (m,) as returned by create_ordering().

next_indicesnumpy.ndarray (int)

The next indices of shape (m,) as returned by create_ordering().

panel_mappingnumpy.ndarray (int)

An array containing the panel mapping (flat to n-D) indices. This is created by passing the panel shape (n_knots - (2 * degrees) - 1) into flat_index_mapping(). Should be an array of shape (n_dimensions, n_panels).

spline_mappingnumpy.ndarray (int)

The 1-D to N-D spline mapping array as returned by flat_index_mapping(). Should be of shape (n_dimensions, n_spline).

coordinatesnumpy.ndarray (float)

The coordinates at which to evaluate the spline of shape (n_dimensions, n).

valuesnumpy.ndarray (float)

An array of values of shape (n_data,).

weightsnumpy.ndarray (float)

The value weights of shape (n_data,).

panel_shapenumpy.ndarray (int)

The number of panels in the spline fit of shape (n_dimensions,).

accuracyfloat

The accuracy that is used to determine when a suitable smoothing fit has been achieved. Iterations will stop when abs(smoothing - sum_square_residuals) < accuracy.

Returns:
coefficients, fp, ier, fitted_valuesndarray, float, float, ndarray

The new spline coefficients, sum of the residuals^2, exit code, and the fitted values.