Crossings Minimization  1.0
Statistics.h File Reference

Interface for a Statistics class with methods for computing min, median, mean, max, and standard deviation. More...

#include <stdio.h>
Include dependency graph for Statistics.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  statistics_struct
 

Typedefs

typedef struct statistics_structStatistics
 

Functions

Statistics init_statistics (int size)
 
double get_min (Statistics s)
 
double get_median (Statistics s)
 
double get_mean (Statistics s)
 
double get_max (Statistics s)
 
double get_standard_deviation (Statistics s)
 
int get_number_of_data_points (Statistics s)
 
void add_data (Statistics s, double data_point)
 
void print_statistics (Statistics s, FILE *output_stream, const char *format)
 
void free_statistics (Statistics s)
 

Detailed Description

Interface for a Statistics class with methods for computing min, median, mean, max, and standard deviation.

Author
Matt Stallmann
Date
2009/05/18

Migrate changes back to C-Utilities

Definition in file Statistics.h.

Typedef Documentation

◆ Statistics

typedef struct statistics_struct * Statistics

Function Documentation

◆ add_data()

◆ free_statistics()

void free_statistics ( Statistics  s)

◆ get_max()

◆ get_mean()

◆ get_median()

◆ get_min()

double get_min ( Statistics  s)

Definition at line 42 of file Statistics.c.

References statistics_struct::data.

Referenced by print_graph_statistics(), and print_statistics().

◆ get_number_of_data_points()

int get_number_of_data_points ( Statistics  s)

Definition at line 75 of file Statistics.c.

References statistics_struct::number_of_data_points.

Referenced by print_statistics().

◆ get_standard_deviation()

double get_standard_deviation ( Statistics  s)

Definition at line 65 of file Statistics.c.

References statistics_struct::data, get_mean(), and statistics_struct::number_of_data_points.

Referenced by print_statistics().

Here is the call graph for this function:

◆ init_statistics()

Statistics init_statistics ( int  size)
Parameters
sizethe maximum number of data items
Returns
a new instance of the class
Todo:
allow for unlimited capacity

Data invariant: the data array remains sorted in increasing order; this is obviously inefficient but this class is not intended for large data sets. The sorting is done via insertion sort, so it will be efficient if the data comes in increasing order.

Definition at line 26 of file Statistics.c.

References statistics_struct::array_size, statistics_struct::data, statistics_struct::number_of_data_points, and statistics_struct::sum.

Referenced by free_statistics(), print_channel_degree_statistics(), print_degree_statistics(), print_graph_statistics(), print_layer_degree_statistics(), and print_stats().

◆ print_statistics()

void print_statistics ( Statistics  s,
FILE *  output_stream,
const char *  format 
)

Prints statistics in the form (tab separated items) min median mean max stdev N

Parameters
formatthe printf format to use for each statistic, e.g. "%5.2f"

Definition at line 127 of file Statistics.c.

References get_max(), get_mean(), get_median(), get_min(), get_number_of_data_points(), and get_standard_deviation().

Referenced by free_statistics(), print_channel_degree_statistics(), print_degree_statistics(), print_layer_degree_statistics(), and print_stats().

Here is the call graph for this function: