2.8.2 averagexy

Menu Information

The function has no menu option and can only called programmatically.

Brief Information

Average or concatenate multiple curves with option to customize output

Command Line Usage

  1. averagexy iy:=(Plot(1), Plot(2)) method:=concatenate x:=myX y:=myY;
  2. averagexy iy:=((1,2),(3, 4)) method:=ave avex:=common interp:=linear x:=5 y:=6;

Variables

Display
Name
Variable
Name
I/O
and
Type
Default
Value
Description
Input iy

Input

XYRange

<active>
Specifies multiple curves to be averaged or concatenated.
Method method

Input

int

0
Average Method

Option list:

  • ave:Average
    Average the input curves by consolidating the same X values and averaging their corresponding Y values.
  • concatenate:Concatenate
    Concatenates the input curves.
Averaged X avex

Input

int

2
This is available only when Average is selected for Method. It specifies the method to determine the X values of the averaged curve.

Option list:

  • same:Same as Source X
    Use the X values of all input curves as the averaged curve's X. X values within tolerance specified by toler will be treated as the same x and averaged.
  • common:Common X Range
    Create an X dataset of npts from the largest minimum X of all datasets to the smallest maximum X of all datasets and calculate Y using the interp setting.
  • full:Full X Range
    Create an X dataset of npts from the smallest minimum X of all datasets to the largest maximum X of all datasets and calculate Y using the interp setting.
  • custom:Custom
    Create an X dataset of npts from xmin to xmax and calculate Y using the interp setting.
  • trace:Follow Curve Trace
    Compute the X values of the averaged curve by trace interpolation, which can create a new curve with a shape similar to the input curves. For more details, please refer to Algorithm below.
Tolerance for Common X Values toler

Input

double

1e-8
This is available only when Average is selected for method and same is selected for avex. It is used to check if the X values of input curves are the same.
Number of Points npts

Input

int

<auto>
This is available when Average is selected for Method and Averaged X is not set to Same as Source X. It specifies the number of points of the interpolated curves. In the dialog box, it computes a number automatically if Auto is checked. You can also uncheck Auto and specify the values directly.
X Minimum xmin

Input

double

<auto>
This is editable only when Custom is selected for Average X. It specifies the minimum X value of the averaged curve. In the dialog box, it computes a number automatically if Auto is checked. You can also uncheck Auto and specify the values directly. This variable is read-only if Common X Range or Full X Range is selected for Averaged X.
X Maximum xmax

Input

double

<auto>
This is editable only when Custom is selected for Average X. It specifies the maximum X value of the averaged curve. In the dialog box, it computes a number automatically if Auto is checked. You can also uncheck Auto and specify the values directly. This variable is read-only if Common X Range or Full X Range is selected for Averaged X.
Interpolate interp

Input

int

0
This is available only when Average X is not set to Same as Source X. It specifies the method to interpolate the Y values when averaging the input curves.

Option list:

Sort X sortx

Input

int

1
It is available only when Concatenate is selected for Method. It specifies the method to sort the X values of the averaged curve. Y values will be reordered accordingly.

Option list:

  • none:None
    Do not sort the X values.
  • ascend: Ascending
    Sort the X values ascendingly.
  • descend: Descending
    Sort the X values descendingly
X x

Output

vector

<optional>
Specifies the column for output averaged X values.
Y y

Output

vector

<optional>
Specifies the column for output averaged Y values.
Std Dev sd

Output

vector

<optional>
This variable is available only when the Method is set to Average. It specifies whether or not to compute the standard deviations of the averaged curve.
Std Err se

Output

vector

<optional>
This variable is available only when the Method is set to Average. It specifies whether or not to compute the standard errors of the averaged curve.
N n

Output

vector

<optional>
This variable is available only when the Method is set to Average. It specifies whether or not to compute the counts of input data points that correspond to each averaged X value.
Minimum min

Input

int

0
This variable is available only when the Method is set to Average. It specifies whether or not to output the minimum value.
Maximum max

Input

int

0
This variable is available only when the Method variable is set to Average. It specifies whether or not to output the maximum value.
SD times 2 sd2

Input

int

0
This variable is available only when the Method variable is set to Average. It specifies whether or not to compute the standard deviation times 2.
SD times 3 sd3

Input

int

0
This variable is available only when the Method variable is set to Average. It specifies whether or not to compute the standard deviation times 3.

Description

This function calculates the average of the input curves or concatenates them, and then outputs the X, Y value as vectors, along with any other selected outputs.

If the Method variable is set to Concatenate, the input ranges will be joined to form a larger data set. Otherwise, the averaged Y values for the input curves will be computed.

The interpolation is performed on all the input curves' y values on a uniform X range for the averaged curve. Or, you can simply join the x values of all the input curves to form a larger data set. In this case, you can specify a tolerance and the minor differences in x values are ignored.

If x values of input curves are not monotonic, the curves are sorted first and then Origin averages these monotonic curves. For average computation, the standard deviations, standard errors and number of points that correspond to each X value can be also output.

Examples

The following script command is used to average two curves data in the active worksheet using linear interpolation on the X values.

averagexy iy:=((col(1),col(2)),(col(3), col(4))) method:=ave avex:=common x:=<new> y:= <new>;

Then two columns are added to the input worksheet. One stores the x values and other stores the y values of the averaged curve.

Algorithm

When the Method variable is set to Concatenate, all the input ranges are simply joined together. Otherwise, average Y values are computed for the input curves. For computing the X values of the averaged curve, this X-Function provides five methods.

For more information about the method of computing the x values, please refer to the algorithm of avecurves.

Related X-Functions

avecurves