Instrument Neutral Distributed Interface INDI  1.9.5
stats.c
Go to the documentation of this file.
1 /*
2  * libDSPAU - a digital signal processing library for astronomy usage
3  * Copyright (C) 2017 Ilia Platone <info@iliaplatone.com>
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
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU 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, see <http://www.gnu.org/licenses/>.
17  */
18 
19 #include "dsp.h"
20 
21 double* dsp_stats_histogram(dsp_stream_p stream, int size)
22 {
23  int k;
24  double* out = (double*)malloc(sizeof(double)*size);
25  double mx = dsp_stats_max(stream->buf, stream->len);
26  double mn = dsp_stats_min(stream->buf, stream->len);
27  for(k = 1; k < size; k++) {
28  out[k] = dsp_stats_range_count(stream->buf, stream->len, mn + (k - 1) * (mx - mn / size), mn + k * (mx - mn / size));
29  }
30  return out;
31 }
32 
dsp.h
dsp_stats_range_count
#define dsp_stats_range_count(buf, len, lo, hi)
Counts value occurrences into stream.
Definition: dsp.h:495
dsp_stats_histogram
double * dsp_stats_histogram(dsp_stream_p stream, int size)
Histogram of the inut stream.
Definition: stats.c:21
dsp_stream_t
Contains a set of informations and data relative to a buffer and how to use it.
Definition: dsp.h:175
dsp_stats_min
#define dsp_stats_min(buf, len)
Gets the minimum value of the input stream.
Definition: dsp.h:382
dsp_stream_t::len
int len
The buffers length.
Definition: dsp.h:178
dsp_stats_max
#define dsp_stats_max(buf, len)
Gets the maximum value of the input stream.
Definition: dsp.h:398
dsp_stream_t::buf
dsp_t * buf
buffer
Definition: dsp.h:184