# Spline Fitting (1D B-Spline) (G Dataflow)

Version:

Uses B-spline fitting to smooth a data set. The input data must be two arrays.

## number of control points

Number of control points that fit to the data set.

number of control points must be greater than degree.

Default: 10

## y

Dependent values. y must contain at least two points.

## x

Independent values. x must be the same size as y.

## weight

Weights for the observations.

weight must be the same size as y. The elements in weight cannot be 0. If an element in weight is less than 0, this node uses the absolute value of the element. If you do not wire an input to weight, this node sets all elements in weight to 1.

## error in

Error conditions that occur before this node runs.

The node responds to this input according to standard error behavior.

Standard Error Behavior

Many nodes provide an error in input and an error out output so that the node can respond to and communicate errors that occur while code is running. The value of error in specifies whether an error occurred before the node runs. Most nodes respond to values of error in in a standard, predictable way.

error in does not contain an error error in contains an error
If no error occurred before the node runs, the node begins execution normally.

If no error occurs while the node runs, it returns no error. If an error does occur while the node runs, it returns that error information as error out.

If an error occurred before the node runs, the node does not execute. Instead, it returns the error in value as error out.

Default: No error

## degree

Order of polynomials that form the B-spline curve and fit to the data set.

Default: 3

## parameter selection

Method that computes the interim knot vector.

Name Value Description
equally spaced 0 Uses the equally-spaced method.
chord length 1 Uses the chord length method.
centripetal 2 Uses the centripetal method.

Default: centripetal

## best B-Spline fit y

Y-values of the B-Spline curve that best fit the input data set.

## best B-Spline fit x

X-values of the B-Spline curve that best fit the input data set.

## error out

Error information.

The node produces this output according to standard error behavior.

Standard Error Behavior

Many nodes provide an error in input and an error out output so that the node can respond to and communicate errors that occur while code is running. The value of error in specifies whether an error occurred before the node runs. Most nodes respond to values of error in in a standard, predictable way.

error in does not contain an error error in contains an error
If no error occurred before the node runs, the node begins execution normally.

If no error occurs while the node runs, it returns no error. If an error does occur while the node runs, it returns that error information as error out.

If an error occurred before the node runs, the node does not execute. Instead, it returns the error in value as error out.

## residue

Weighted mean square error of the fitted model.

## Algorithm for Calculating the B-Spline Fit

This node calculates best B-Spline fit x and best B-Spline fit y by minimizing the residue according to the following equation:

$\frac{1}{N}\underset{i=0}{\overset{N-1}{\sum }}{w}_{i}\cdot {‖\left({x}_{i},{y}_{i}\right)-\left({x\prime }_{i},{y\prime }_{i}\right)‖}^{2}=\frac{1}{N}\underset{i=0}{\overset{N-1}{\sum }}{w}_{i}\cdot \left[{\left({x}_{i}-{x\prime }_{i}\right)}^{2}+{\left({y}_{i}-{y\prime }_{i}\right)}^{2}\right]$

where

• N is the length of y
• wi is the ith element of weight
• (xi, yi) is the ith pair of the input sequences (x, y)
• (x'i, y'i) is the ith pair of (best B-Spline fit x, best B-Spline fit y)
• The norm symbols (||) on both sides of the function compute the |2 norm of a vector

The standard B-Spline basis functions construct the B-Spline curve (x'i, y'i).

The following illustration shows a typical B-Spline Fit result.

Where This Node Can Run:

Desktop OS: Windows

FPGA: This product does not support FPGA devices

Web Server: Not supported in VIs that run in a web application