libtpcmodel
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines
Functions
pearson.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include "include/pearson.h"
Include dependency graph for pearson.c:

Go to the source code of this file.

Functions

int pearson (double *x, double *y, int nr, double *k, double *kSD, double *b, double *bSD, double *r, double *ySD)
int pearson2 (double *x, double *y, char *is, int nr, double *k, double *kSD, double *b, double *bSD, double *r, double *ySD)
int pearson3 (double *x, double *y, int nr, double *k, double *kSD, double *b, double *bSD, double *r, double *ySD)
int pearson4 (double *x, double *y, int nr, double start, double end, double *k, double *kSD, double *b, double *bSD, double *r, double *ySD)
int best_pearson (double *x, double *y, int nr, int min_nr, int *first, int *last, double *k, double *kSD, double *b, double *bSD, double *r, double *ySD)
int mean (double *x, double *y, int nr, double *xmean, double *xsd, double *ymean, double *ysd)
int regr_line (double *x, double *y, int n, double *m, double *c)
int highest_slope (double *x, double *y, int n, int slope_n, double *m, double *c, double *xi, double *xh)
int highest_slope_after (double *x, double *y, int n, int slope_n, double x_start, double *m, double *c, double *xi, double *xh)

Function Documentation

int best_pearson ( double *  x,
double *  y,
int  nr,
int  min_nr,
int *  first,
int *  last,
double *  k,
double *  kSD,
double *  b,
double *  bSD,
double *  r,
double *  ySD 
)

Find the best linear fit to double data (x[], y[]) with nr points. Data may contain NaN's, which are not used.

Returns:
Returns the nr of points actually used, or 0, in case of error.
Parameters:
xData x values
yData y values
nrNumber of data sample values
min_nrMinimum nr of data points to use
firstIndex [0..last-2] of the first point to use initially, and after fitting
lastIndex [first+1..nr-1] of the last point to use initially, and after fitting
kslope
kSDS.D. of slope
by axis intercept
bSDS.D. of y axis intercept
rPearson's correlation coefficient, r
ySDResidual variance of y values

Definition at line 315 of file pearson.c.

References pearson(), and PEARSON_TEST.

Here is the call graph for this function:

int highest_slope ( double *  x,
double *  y,
int  n,
int  slope_n,
double *  m,
double *  c,
double *  xi,
double *  xh 
)

Finds the regression line with the highest slope for x,y data

Returns:
Return 0 if ok.
Parameters:
xAn array of x axis values
yAn array of y axis values
nThe number of values in x and y arrays
slope_nThe number of samples used to fit the line
mPointer where calculated slope is written; NULL if not needed
cPointer where calculated y axis intercept is written; NULL if not needed
xiPointer where calculated x axis intercept is written; NULL if not needed
xhPointer where the place (x) of the highest slope is written; NULL if not needed

Definition at line 479 of file pearson.c.

References regr_line().

Here is the call graph for this function:

int highest_slope_after ( double *  x,
double *  y,
int  n,
int  slope_n,
double  x_start,
double *  m,
double *  c,
double *  xi,
double *  xh 
)

Finds the regression line with the highest slope for x,y data after specified x.

Returns:
Return 0 if ok.
Parameters:
xAn array of x axis values
yAn array of y axis values
nThe number of values in x and y arrays
slope_nThe number of samples used to fit the line
x_startEstimation start x value, samples with smaller x are ignored; can usually be set to zero
mPointer where calculated slope is written; NULL if not needed
cPointer where calculated y axis intercept is written; NULL if not needed
xiPointer where calculated x axis intercept is written; NULL if not needed
xhPointer where the place (x) of the highest slope is written; NULL if not needed

Definition at line 530 of file pearson.c.

References regr_line().

Here is the call graph for this function:

int mean ( double *  x,
double *  y,
int  nr,
double *  xmean,
double *  xsd,
double *  ymean,
double *  ysd 
)

Calculates the mean and SD of data. Data (y data) may contain NaN's.

Returns:
Returns !=0 in case of an error.
Parameters:
xData x values
yData y values
nrNumber of data sample values
xmeanCalculated x mean
xsdCalculated SD of x mean
ymeanCalculated y mean
ysdCalculated SD of y mean

Definition at line 402 of file pearson.c.

Referenced by pivot_lep().

int pearson ( double *  x,
double *  y,
int  nr,
double *  k,
double *  kSD,
double *  b,
double *  bSD,
double *  r,
double *  ySD 
)

Calculate slope and intercept of a line and Pearson's correlation coefficient.

Returns:
If successful, function returns value 0.
Parameters:
xdata x values
ydata y values
nrnumber of data sample values
kslope
kSDS.D. of slope
by axis intercept
bSDS.D. of y axis intercept
rPearson's correlation coefficient, r
ySDResidual variance of y values

Definition at line 82 of file pearson.c.

References PEARSON_TEST.

Referenced by best_pearson(), pearson2(), pearson3(), and pearson4().

int pearson2 ( double *  x,
double *  y,
char *  is,
int  nr,
double *  k,
double *  kSD,
double *  b,
double *  bSD,
double *  r,
double *  ySD 
)

Calculate slope and intercept of a line and Pearson's correlation coefficient Array char is[] specifies whether single (x,y) points are used in the fit.

Returns:
If successful, function returns value 0.
Parameters:
xdata x values
ydata y values
isSwitch values: 0=do not use this point
nrnumber of data sample values
kslope
kSDS.D. of slope
by axis intercept
bSDS.D. of y axis intercept
rPearson's correlation coefficient, r
ySDResidual variance of y values

Definition at line 175 of file pearson.c.

References pearson().

Here is the call graph for this function:

int pearson3 ( double *  x,
double *  y,
int  nr,
double *  k,
double *  kSD,
double *  b,
double *  bSD,
double *  r,
double *  ySD 
)

Calculate slope and intercept of a line and Pearson's correlation coefficient Data points may contain NaN's.

Returns:
If successful, function returns value 0.
Parameters:
xdata x values
ydata y values
nrnumber of data sample values
kslope
kSDS.D. of slope
by axis intercept
bSDS.D. of y axis intercept
rPearson's correlation coefficient, r
ySDResidual variance of y values

Definition at line 218 of file pearson.c.

References pearson().

Here is the call graph for this function:

int pearson4 ( double *  x,
double *  y,
int  nr,
double  start,
double  end,
double *  k,
double *  kSD,
double *  b,
double *  bSD,
double *  r,
double *  ySD 
)

Calculate slope and intercept of a line and Pearson's correlation coefficient Data points may contain NaN's. Fit start and end times are specified.

Returns:
If successful, function returns value 0.
Parameters:
xdata x values
ydata y values
nrnumber of data sample values
startfit start time
endfit end time
kslope
kSDS.D. of slope
by axis intercept
bSDS.D. of y axis intercept
rPearson's correlation coefficient, r
ySDResidual variance of y values

Definition at line 260 of file pearson.c.

References pearson(), and PEARSON_TEST.

Here is the call graph for this function:

int regr_line ( double *  x,
double *  y,
int  n,
double *  m,
double *  c 
)

Calculates regression line slope (m) and y axis intercept.

Returns:
Returns 0 if ok.
Parameters:
xAn array of x axis values
yAn array of y axis values
nThe number of values in x and y arrays
mPointer where calculated slope is written
cPointer where calculated y axis intercept

Definition at line 445 of file pearson.c.

Referenced by highest_slope(), and highest_slope_after().