Debian Codegraph @

external/gsl/gsl_statistics__variance_source.c

raw symbols SCIP
1 /* statistics/variance_source.c
2 *
3 * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2007 Jim Davies, Brian Gough
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or (at
8 * your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 */
19
20 static double
21 FUNCTIONcxx . . $ `./templates_on.h:227:9`!(compute,variance) (const BASEcxx . . $ `./templates_on.h:65:9`! data[], const size_t stride, const size_t n, const double mean);
22
23 static double
24 FUNCTIONcxx . . $ `./templates_on.h:227:9`!(compute,variance) (const BASEcxx . . $ `./templates_on.h:65:9`! data[], const size_t stride, const size_t n, const double mean)
25 {
26 /* takes a dataset and finds the variance */
27
28 long double variance = 0 ;
29
30 size_t i;
31
32 /* find the sum of the squares */
33 for (i = 0; i < n; i++)
34 {
35 const long double delta = (data[i * stride] - mean);
36 variance += (delta * delta - variance) / (i + 1);
37 }
38
39 return variance ;
40 }
41
42
43 double
44 FUNCTIONcxx . . $ `./templates_on.h:227:9`!(gsl_stats,variance_with_fixed_mean) (const BASEcxx . . $ `./templates_on.h:65:9`! data[], const size_t stride, const size_t n, const double mean)
45 {
46 const double variance = FUNCTIONcxx . . $ `./templates_on.h:227:9`!(compute,variance) (data, stride, n, mean);
47 return variance;
48 }
49
50 double
51 FUNCTIONcxx . . $ `./templates_on.h:227:9`!(gsl_stats,sd_with_fixed_mean) (const BASEcxx . . $ `./templates_on.h:65:9`! data[], const size_t stride, const size_t n, const double mean)
52 {
53 const double variance = FUNCTIONcxx . . $ `./templates_on.h:227:9`!(compute,variance) (data, stride, n, mean);
54 const double sd = sqrt (variance);
55
56 return sd;
57 }
58
59
60
61 double
62 FUNCTIONcxx . . $ `./templates_on.h:227:9`!(gsl_stats,variance_m) (const BASEcxx . . $ `./templates_on.h:65:9`! data[], const size_t stride, const size_t n, const double mean)
63 {
64 const double variance = FUNCTIONcxx . . $ `./templates_on.h:227:9`!(compute,variance) (data, stride, n, mean);
65
66 return variance * ((double)n / (double)(n - 1));
67 }
68
69 double
70 FUNCTIONcxx . . $ `./templates_on.h:227:9`!(gsl_stats,sd_m) (const BASEcxx . . $ `./templates_on.h:65:9`! data[], const size_t stride, const size_t n, const double mean)
71 {
72 const double variance = FUNCTIONcxx . . $ `./templates_on.h:227:9`!(compute,variance) (data, stride, n, mean);
73 const double sd = sqrt (variance * ((double)n / (double)(n - 1)));
74
75 return sd;
76 }
77
78 double
79 FUNCTIONcxx . . $ `./templates_on.h:227:9`!(gsl_stats,variance) (const BASEcxx . . $ `./templates_on.h:65:9`! data[], const size_t stride, const size_t n)
80 {
81 const double mean = FUNCTIONcxx . . $ `./templates_on.h:227:9`!(gsl_stats,mean) (data, stride, n);
82 return FUNCTIONcxx . . $ `./templates_on.h:227:9`!(gsl_stats,variance_m)(data, stride, n, mean);
83 }
84
85 double
86 FUNCTIONcxx . . $ `./templates_on.h:227:9`!(gsl_stats,sd) (const BASEcxx . . $ `./templates_on.h:65:9`! data[], const size_t stride, const size_t n)
87 {
88 const double mean = FUNCTIONcxx . . $ `./templates_on.h:227:9`!(gsl_stats,mean) (data, stride, n);
89 return FUNCTIONcxx . . $ `./templates_on.h:227:9`!(gsl_stats,sd_m) (data, stride, n, mean);
90 }