max@0
|
1 // Copyright (C) 2009-2011 NICTA (www.nicta.com.au)
|
max@0
|
2 // Copyright (C) 2009-2011 Conrad Sanderson
|
max@0
|
3 //
|
max@0
|
4 // This file is part of the Armadillo C++ library.
|
max@0
|
5 // It is provided without any warranty of fitness
|
max@0
|
6 // for any purpose. You can redistribute this file
|
max@0
|
7 // and/or modify it under the terms of the GNU
|
max@0
|
8 // Lesser General Public License (LGPL) as published
|
max@0
|
9 // by the Free Software Foundation, either version 3
|
max@0
|
10 // of the License or (at your option) any later version.
|
max@0
|
11 // (see http://www.opensource.org/licenses for more info)
|
max@0
|
12
|
max@0
|
13
|
max@0
|
14 //! \addtogroup running_stat
|
max@0
|
15 //! @{
|
max@0
|
16
|
max@0
|
17
|
max@0
|
18
|
max@0
|
19 template<typename eT>
|
max@0
|
20 class arma_counter
|
max@0
|
21 {
|
max@0
|
22 public:
|
max@0
|
23
|
max@0
|
24 inline ~arma_counter();
|
max@0
|
25 inline arma_counter();
|
max@0
|
26
|
max@0
|
27 inline const arma_counter& operator++();
|
max@0
|
28 inline void operator++(int);
|
max@0
|
29
|
max@0
|
30 inline void reset();
|
max@0
|
31 inline eT value() const;
|
max@0
|
32 inline eT value_plus_1() const;
|
max@0
|
33 inline eT value_minus_1() const;
|
max@0
|
34
|
max@0
|
35
|
max@0
|
36 private:
|
max@0
|
37
|
max@0
|
38 arma_aligned eT d_count;
|
max@0
|
39 arma_aligned uword i_count;
|
max@0
|
40 };
|
max@0
|
41
|
max@0
|
42
|
max@0
|
43
|
max@0
|
44 //! Class for keeping statistics of a continuously sampled process / signal.
|
max@0
|
45 //! Useful if the storage of individual samples is not necessary or desired.
|
max@0
|
46 //! Also useful if the number of samples is not known beforehand or exceeds
|
max@0
|
47 //! available memory.
|
max@0
|
48 template<typename eT>
|
max@0
|
49 class running_stat
|
max@0
|
50 {
|
max@0
|
51 public:
|
max@0
|
52
|
max@0
|
53 typedef typename get_pod_type<eT>::result T;
|
max@0
|
54
|
max@0
|
55
|
max@0
|
56 inline ~running_stat();
|
max@0
|
57 inline running_stat();
|
max@0
|
58
|
max@0
|
59 inline void operator() (const T sample);
|
max@0
|
60 inline void operator() (const std::complex<T>& sample);
|
max@0
|
61
|
max@0
|
62 inline void reset();
|
max@0
|
63
|
max@0
|
64 inline eT mean() const;
|
max@0
|
65
|
max@0
|
66 inline T var (const uword norm_type = 0) const;
|
max@0
|
67 inline T stddev(const uword norm_type = 0) const;
|
max@0
|
68
|
max@0
|
69 inline eT min() const;
|
max@0
|
70 inline eT max() const;
|
max@0
|
71
|
max@0
|
72 inline T count() const;
|
max@0
|
73
|
max@0
|
74 //
|
max@0
|
75 //
|
max@0
|
76
|
max@0
|
77 private:
|
max@0
|
78
|
max@0
|
79 arma_aligned arma_counter<T> counter;
|
max@0
|
80
|
max@0
|
81 arma_aligned eT r_mean;
|
max@0
|
82 arma_aligned T r_var;
|
max@0
|
83
|
max@0
|
84 arma_aligned eT min_val;
|
max@0
|
85 arma_aligned eT max_val;
|
max@0
|
86
|
max@0
|
87 arma_aligned T min_val_norm;
|
max@0
|
88 arma_aligned T max_val_norm;
|
max@0
|
89
|
max@0
|
90
|
max@0
|
91 friend class running_stat_aux;
|
max@0
|
92 };
|
max@0
|
93
|
max@0
|
94
|
max@0
|
95
|
max@0
|
96 class running_stat_aux
|
max@0
|
97 {
|
max@0
|
98 public:
|
max@0
|
99
|
max@0
|
100 template<typename eT>
|
max@0
|
101 inline static void update_stats(running_stat<eT>& x, const eT sample);
|
max@0
|
102
|
max@0
|
103 template<typename T>
|
max@0
|
104 inline static void update_stats(running_stat< std::complex<T> >& x, const T sample);
|
max@0
|
105
|
max@0
|
106 template<typename T>
|
max@0
|
107 inline static void update_stats(running_stat< std::complex<T> >& x, const std::complex<T>& sample);
|
max@0
|
108
|
max@0
|
109 };
|
max@0
|
110
|
max@0
|
111
|
max@0
|
112
|
max@0
|
113 //! @}
|