Statistics for MySQL  1.1
 All Classes Files Functions Variables Typedefs Macros Pages
Classes | Functions
corr.c File Reference

Pearson correlation coeffient. More...

#include "sqlstat.h"
Include dependency graph for corr.c:

Go to the source code of this file.

Classes

struct  corr_storage
 Storage for corr function. More...
 

Functions

my_bool corr_init (UDF_INIT *initid, UDF_ARGS *args, char *message)
 Called before first usage of function. More...
 
void corr_reset (UDF_INIT *initid, UDF_ARGS *args, char *is_null, char *error)
 Reset function and add first group member Calls clear and add. More...
 
void corr_clear (UDF_INIT *initid, char *is_null, char *error)
 Called at start of group. More...
 
void corr_add (UDF_INIT *initid, UDF_ARGS *args, char *is_null, char *error)
 Add a member of the group. More...
 
double corr (UDF_INIT *initid, UDF_ARGS *args, char *is_null, char *error)
 Retrieve correlation coefficient. Called at end of group. More...
 
void corr_deinit (UDF_INIT *initid)
 Called after last access to function. More...
 

Detailed Description

Pearson correlation coeffient.

CREATE AGGREGATE FUNCTION corr RETURNS REAL SONAME 'libsqlstat.so';
SELECT corr(x,y) FROM mytab;
DROP FUNCTION corr;

Definition in file corr.c.

Function Documentation

double corr ( UDF_INIT *  initid,
UDF_ARGS *  args,
char *  is_null,
char *  error 
)

Retrieve correlation coefficient. Called at end of group.

Parameters
initidfunction description
argsargument values
is_nullresult is NULL
errorerror message
Returns
correlation coefficient

Definition at line 172 of file corr.c.

void corr_add ( UDF_INIT *  initid,
UDF_ARGS *  args,
char *  is_null,
char *  error 
)

Add a member of the group.

The counter and sums are updated

Parameters
initidfunction description
argsargument values
is_null
errorerror message

Definition at line 134 of file corr.c.

Here is the caller graph for this function:

void corr_clear ( UDF_INIT *  initid,
char *  is_null,
char *  error 
)

Called at start of group.

The counter and sums are cleared.

Parameters
initidfunction description
is_null
errorerror message

Definition at line 113 of file corr.c.

Here is the caller graph for this function:

corr_deinit ( UDF_INIT *  initid)

Called after last access to function.

Deallocate memory for counter and sums.

Parameters
initid

Definition at line 201 of file corr.c.

my_bool corr_init ( UDF_INIT *  initid,
UDF_ARGS *  args,
char *  message 
)

Called before first usage of function.

Check parameters.
Indicate type of return value.
Allocate memory for counter and sums.

Parameters
initidfunction description
argsparameters
messageerror message
Returns
success = 0

Definition at line 59 of file corr.c.

void corr_reset ( UDF_INIT *  initid,
UDF_ARGS *  args,
char *  is_null,
char *  error 
)

Reset function and add first group member Calls clear and add.

Parameters
initidfunction description
argsargument values
is_null
errorerror message
Deprecated:
Reset is only called by MySQL 4.0 and below. It is implemented for backwards compatibility.

Definition at line 99 of file corr.c.

Here is the call graph for this function: