streaming_algorithms
0.0.5
A collection of streaming data algorithms
|
Piece_wise parabolic predicition (P2). More...
#include <stddef.h>
Go to the source code of this file.
Typedefs | |
typedef struct sa_p2_quantile | sa_p2_quantile |
typedef struct sa_p2_histogram | sa_p2_histogram |
Functions | |
sa_p2_quantile * | sa_create_p2_quantile (double p) |
Allocates and initializes the data structure. More... | |
void | sa_init_p2_quantile (sa_p2_quantile *p2q) |
Zeros out the quantile. More... | |
double | sa_add_p2_quantile (sa_p2_quantile *p2q, double x) |
Updates the quantile with the provided observation. More... | |
unsigned long long | sa_count_p2_quantile (sa_p2_quantile *p2q, unsigned short marker) |
Returns the number of observations that are less than or equal to the marker. More... | |
double | sa_estimate_p2_quantile (sa_p2_quantile *p2q, unsigned short marker) |
Returns the estimated quantile value for the specified marker. More... | |
void | sa_destroy_p2_quantile (sa_p2_quantile *p2q) |
Free the associated memory. More... | |
char * | sa_serialize_p2_quantile (sa_p2_quantile *p2q, size_t *len) |
Serialize the internal state to a buffer. More... | |
int | sa_deserialize_p2_quantile (sa_p2_quantile *p2q, const char *buf, size_t len) |
Restores the internal state from the serialized output. More... | |
sa_p2_histogram * | sa_create_p2_histogram (unsigned short buckets) |
Allocates and initializes the data structures. More... | |
void | sa_init_p2_histogram (sa_p2_histogram *p2h) |
Zeros out the histogram counters. More... | |
void | sa_add_p2_histogram (sa_p2_histogram *p2h, double x) |
Updates the histogram with the provided observation. More... | |
unsigned long long | sa_count_p2_histogram (sa_p2_histogram *p2h, unsigned short marker) |
Gets the number of observations that are less than or equal to the marker. More... | |
double | sa_estimate_p2_histogram (sa_p2_histogram *p2h, unsigned short marker) |
Gets the estimated quantile value for the specified marker. More... | |
void | sa_destroy_p2_histogram (sa_p2_histogram *p2h) |
Free the associated memory. More... | |
char * | sa_serialize_p2_histogram (sa_p2_histogram *p2h, size_t *len) |
Serialize the internal state to a buffer. More... | |
int | sa_deserialize_p2_histogram (sa_p2_histogram *p2h, const char *buf, size_t len) |
Restores the internal state from the serialized output. More... | |
Piece_wise parabolic predicition (P2).
Dynamic calculation of quantiles and histograms without storing observations. http://www.cs.wustl.edu/~jain/papers/ftp/psqr.pdf
Definition in file p2.h.
typedef struct sa_p2_histogram sa_p2_histogram |
typedef struct sa_p2_quantile sa_p2_quantile |
void sa_add_p2_histogram | ( | sa_p2_histogram * | p2h, |
double | x | ||
) |
Updates the histogram with the provided observation.
p2h | Histogram struct |
x | Observation to add |
double sa_add_p2_quantile | ( | sa_p2_quantile * | p2q, |
double | x | ||
) |
Updates the quantile with the provided observation.
p2q | Quantile struct |
x | Observation to add |
unsigned long long sa_count_p2_histogram | ( | sa_p2_histogram * | p2h, |
unsigned short | marker | ||
) |
Gets the number of observations that are less than or equal to the marker.
p2h | Histogram struct |
marker | Selects the percentile (marker/buckets) |
unsigned long long sa_count_p2_quantile | ( | sa_p2_quantile * | p2q, |
unsigned short | marker | ||
) |
Returns the number of observations that are less than or equal to the marker.
p2q | Quantile struct |
marker | Selects the percentile 0 = min 1 = p/2 2 = p 3 = (1+p)/2 4 = max |
sa_p2_histogram* sa_create_p2_histogram | ( | unsigned short | buckets | ) |
Allocates and initializes the data structures.
buckets | Number of histogram buckets |
sa_p2_quantile* sa_create_p2_quantile | ( | double | p | ) |
Allocates and initializes the data structure.
p | p_quantile to calculate (e.g. 0.5 == median) |
int sa_deserialize_p2_histogram | ( | sa_p2_histogram * | p2h, |
const char * | buf, | ||
size_t | len | ||
) |
Restores the internal state from the serialized output.
p2h | Histogram struct |
buf | Buffer containing the output of serialize_p2_histogram |
len | Length of the buffer |
int sa_deserialize_p2_quantile | ( | sa_p2_quantile * | p2q, |
const char * | buf, | ||
size_t | len | ||
) |
Restores the internal state from the serialized output.
p2q | Quantile struct |
buf | Buffer containing the output of serialize_p2_quantile |
len | Length of the buffer |
void sa_destroy_p2_histogram | ( | sa_p2_histogram * | p2h | ) |
Free the associated memory.
p2h | Histogram struct |
void sa_destroy_p2_quantile | ( | sa_p2_quantile * | p2q | ) |
Free the associated memory.
p2q | Quantile struct |
double sa_estimate_p2_histogram | ( | sa_p2_histogram * | p2h, |
unsigned short | marker | ||
) |
Gets the estimated quantile value for the specified marker.
p2h | Histogram struct |
marker | Selects the percentile (marker/buckets) |
double sa_estimate_p2_quantile | ( | sa_p2_quantile * | p2q, |
unsigned short | marker | ||
) |
Returns the estimated quantile value for the specified marker.
p2q | Quantile struct |
marker | 0-4 see sa_count_p2_quantile |
void sa_init_p2_histogram | ( | sa_p2_histogram * | p2h | ) |
Zeros out the histogram counters.
p2h | Histogram struct |
void sa_init_p2_quantile | ( | sa_p2_quantile * | p2q | ) |
Zeros out the quantile.
p2q | Quantile struct |
char* sa_serialize_p2_histogram | ( | sa_p2_histogram * | p2h, |
size_t * | len | ||
) |
Serialize the internal state to a buffer.
p2h | Histogram struct |
len | Length of the returned buffer |
char* sa_serialize_p2_quantile | ( | sa_p2_quantile * | p2q, |
size_t * | len | ||
) |
Serialize the internal state to a buffer.
p2q | Quantile struct |
len | Length of the returned buffer |