Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-15 10:17:33

0001 /* rstat/gsl_rstat.h
0002  * 
0003  * Copyright (C) 2015 Patrick Alken
0004  * 
0005  * This program is free software; you can redistribute it and/or modify
0006  * it under the terms of the GNU General Public License as published by
0007  * the Free Software Foundation; either version 3 of the License, or (at
0008  * your option) any later version.
0009  * 
0010  * This program is distributed in the hope that it will be useful, but
0011  * WITHOUT ANY WARRANTY; without even the implied warranty of
0012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0013  * General Public License for more details.
0014  * 
0015  * You should have received a copy of the GNU General Public License
0016  * along with this program; if not, write to the Free Software
0017  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
0018  */
0019 
0020 #ifndef __GSL_RSTAT_H__
0021 #define __GSL_RSTAT_H__
0022 
0023 #include <stdlib.h>
0024 
0025 #undef __BEGIN_DECLS
0026 #undef __END_DECLS
0027 #ifdef __cplusplus
0028 # define __BEGIN_DECLS extern "C" {
0029 # define __END_DECLS }
0030 #else
0031 # define __BEGIN_DECLS /* empty */
0032 # define __END_DECLS /* empty */
0033 #endif
0034 
0035 __BEGIN_DECLS
0036 
0037 typedef struct
0038 {
0039   double p;        /* p-quantile */
0040   double q[5];     /* heights q_i */
0041   int npos[5];     /* positions n_i */
0042   double np[5];    /* desired positions n_i' */
0043   double dnp[5];   /* increments dn_i' */
0044   size_t n;        /* number of data added */
0045 } gsl_rstat_quantile_workspace;
0046 
0047 gsl_rstat_quantile_workspace *gsl_rstat_quantile_alloc(const double p);
0048 void gsl_rstat_quantile_free(gsl_rstat_quantile_workspace *w);
0049 int gsl_rstat_quantile_reset(gsl_rstat_quantile_workspace *w);
0050 int gsl_rstat_quantile_add(const double x, gsl_rstat_quantile_workspace *w);
0051 double gsl_rstat_quantile_get(gsl_rstat_quantile_workspace *w);
0052 
0053 typedef struct
0054 {
0055   double min;      /* minimum value added */
0056   double max;      /* maximum value added */
0057   double mean;     /* current mean */
0058   double M2;       /* M_k = sum_{i=1..n} [ x_i - mean_n ]^k */
0059   double M3;
0060   double M4;
0061   size_t n;        /* number of data points added */
0062   gsl_rstat_quantile_workspace *median_workspace_p; /* median workspace */
0063 } gsl_rstat_workspace;
0064 
0065 gsl_rstat_workspace *gsl_rstat_alloc(void);
0066 void gsl_rstat_free(gsl_rstat_workspace *w);
0067 size_t gsl_rstat_n(const gsl_rstat_workspace *w);
0068 int gsl_rstat_add(const double x, gsl_rstat_workspace *w);
0069 double gsl_rstat_min(const gsl_rstat_workspace *w);
0070 double gsl_rstat_max(const gsl_rstat_workspace *w);
0071 double gsl_rstat_mean(const gsl_rstat_workspace *w);
0072 double gsl_rstat_variance(const gsl_rstat_workspace *w);
0073 double gsl_rstat_sd(const gsl_rstat_workspace *w);
0074 double gsl_rstat_rms(const gsl_rstat_workspace *w);
0075 double gsl_rstat_norm(const gsl_rstat_workspace *w);
0076 double gsl_rstat_sd_mean(const gsl_rstat_workspace *w);
0077 double gsl_rstat_median(gsl_rstat_workspace *w);
0078 double gsl_rstat_skew(const gsl_rstat_workspace *w);
0079 double gsl_rstat_kurtosis(const gsl_rstat_workspace *w);
0080 int gsl_rstat_reset(gsl_rstat_workspace *w);
0081 
0082 __END_DECLS
0083 
0084 #endif /* __GSL_RSTAT_H__ */