# curve¶

## Purpose¶

Computes a one-dimensional smoothing curve.

## Format¶

{ u, v } = curve(x, y, d, s, sigma, G)
Parameters:
• x (Kx1 vector) – x-abscissae (x-axis values).

• y (Kx1 vector) – y-ordinates (y-axis values).

• d (Kx1 vector or scalar) – observation weights.

• s (scalar) – smoothing parameter. If $$s = 0$$, curve performs an interpolation. If d contains standard deviation estimates, a reasonable value for s is K.

• sigma (scalar) – tension factor.

• G (scalar) – grid size factor.

Returns:
• u ((KxG)x1) – vector, x-abscissae, regularly spaced.

• v ((KxG)x1) – vector, y-ordinates, regularly spaced.

## Example:¶

new;

// Generate data
x = seqa(0, .25, 24);
y = 5*x + 4 + 10*rndn(rows(x), 1);

// Observation weights
d = 1;

// Smoothing parameter
s = 2;

// Tension factor
sigma = 1;

// Grid factor;
G = 2;

{ u, v } = curve(x, y, d, s, sigma, G);

// Quick plot of results
plotScatter(x, y);


## Remarks¶

sigma contains the tension factor. This value indicates the curviness desired. If sigma is nearly zero (e.g. .001), the resulting curve is approximately the tensor product of cubic curves. If sigma is large, (e.g. 50.0) the resulting curve is approximately bi-linear. If sigma equals zero, tensor products of cubic curves result. A standard value for sigma is approximately 1.

G is the grid size factor. It determines the fineness of the output grid. For $$G = 1$$, the input and output vectors will be the same size. For $$G = 2$$, the output grid is twice as fine as the input grid, i.e., u and v will have twice as many rows as x and y.

## Source¶

spline.src

Functions spline()