streaming_algorithms  0.0.5
A collection of streaming data algorithms
Classes | Typedefs | Functions
running_stats.h File Reference

Calculates the running count, mean, variance, and standard deviation. More...

#include <stddef.h>
Include dependency graph for running_stats.h:

Go to the source code of this file.

Classes

struct  sa_running_stats
 

Typedefs

typedef struct sa_running_stats sa_running_stats
 

Functions

void sa_init_running_stats (sa_running_stats *s)
 Zeros out the stats counters. More...
 
void sa_add_running_stats (sa_running_stats *s, double d)
 Value to add to the running stats. More...
 
double sa_variance_running_stats (sa_running_stats *s)
 Returns the variance of the stats. More...
 
double sa_sd_running_stats (sa_running_stats *s)
 Returns the corrected sample standard deviation of the stats. More...
 
double sa_usd_running_stats (sa_running_stats *s)
 Returns the uncorrected sample standard deviation of the stats. More...
 
char * sa_serialize_running_stats (sa_running_stats *s, size_t *len)
 Serialize the internal state to a buffer. More...
 
int sa_deserialize_running_stats (sa_running_stats *s, const char *buf, size_t len)
 Restores the internal state from the serialized output. More...
 

Detailed Description

Calculates the running count, mean, variance, and standard deviation.

Definition in file running_stats.h.

Typedef Documentation

Function Documentation

void sa_add_running_stats ( sa_running_stats s,
double  d 
)

Value to add to the running stats.

Parameters
sStat structure
dValue to add
int sa_deserialize_running_stats ( sa_running_stats s,
const char *  buf,
size_t  len 
)

Restores the internal state from the serialized output.

Parameters
sStat structure
bufBuffer containing the output of serialize_running_stats
lenLength of the buffer
Returns
0 = success 1 = invalid buffer length 2 = invalid count value
void sa_init_running_stats ( sa_running_stats s)

Zeros out the stats counters.

Parameters
sStat structure to zero out
double sa_sd_running_stats ( sa_running_stats s)

Returns the corrected sample standard deviation of the stats.

Parameters
sStat structure
Returns
double Standard deviation of the stats up to this point
char* sa_serialize_running_stats ( sa_running_stats s,
size_t *  len 
)

Serialize the internal state to a buffer.

Parameters
sStat structure
lenLength of the returned buffer
Returns
char* Serialized representation MUST be freed by the caller
double sa_usd_running_stats ( sa_running_stats s)

Returns the uncorrected sample standard deviation of the stats.

Parameters
sStat structure
Returns
double Uncorrected standard deviation of the stats up to this point
double sa_variance_running_stats ( sa_running_stats s)

Returns the variance of the stats.

Parameters
sStat structure
Returns
double Variance of the stats up to this point