libdspl-2.0
Библиотека алгоритмов цифровой обработки сигналов
stat_std.c
1 /*
2 * Copyright (c) 2015-2024 Sergey Bakhurin
3 * Digital Signal Processing Library [http://dsplib.org]
4 *
5 * This file is part of DSPL.
6 *
7 * is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * DSPL is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with Foobar. If not, see <http://www.gnu.org/licenses/>.
19 */
20 
21 
22 #include <stdio.h>
23 #include <stdlib.h>
24 #include <string.h>
25 #include "dspl.h"
26 
27 
28 
29 
30 
31 
32 #ifdef DOXYGEN_ENGLISH
33 
72 #endif
73 #ifdef DOXYGEN_RUSSIAN
74 
115 #endif
116 int DSPL_API stat_std(double* x, int n, double* s)
117 {
118  int k, err;
119  double sum, m;
120  err = mean(x, n, &m);
121  if(err != RES_OK)
122  goto exit_label;
123  sum = (x[0] - m) * (x[0] - m);
124  for(k = 1; k < n; k++)
125  sum += (x[k] - m) * (x[k] - m);
126  (*s) = sqrt(sum / (double)(n-1));
127 exit_label:
128  return err;
129 }
130 
int stat_std(double *x, int n, double *s)
Выборочная оценка стандартного отклонения вещественного вектора x
Definition: stat_std.c:116
#define RES_OK
Функция завершилась корректно. Ошибки отсутствуют.
Definition: dspl.h:558
int sum(double *x, int n, double *s)
Расчет суммы элеметов массива
Definition: sum.c:76
int mean(double *x, int n, double *m)
Выборочная оценка математического ожидания вещественного вектора x
Definition: mean.c:105