Classes | |
class | arma_counter< eT > |
class | running_stat< eT > |
Class for keeping statistics of a continuously sampled process / signal. Useful if the storage of individual samples is not necessary or desired. Also useful if the number of samples is not known beforehand or exceeds available memory. More... | |
class | running_stat_aux |
Functions | |
arma_counter::~arma_counter () | |
arma_counter::arma_counter () | |
const arma_counter & | arma_counter::operator++ () |
void | arma_counter::operator++ (int) |
void | arma_counter::reset () |
eT | arma_counter::value () const |
eT | arma_counter::value_plus_1 () const |
eT | arma_counter::value_minus_1 () const |
running_stat::~running_stat () | |
running_stat::running_stat () | |
void | running_stat::operator() (const T sample) |
update statistics to reflect new sample | |
void | running_stat::operator() (const std::complex< T > &sample) |
update statistics to reflect new sample (version for complex numbers) | |
void | running_stat::reset () |
set all statistics to zero | |
eT | running_stat::mean () const |
mean or average value | |
T | running_stat::var (const u32 norm_type=0) const |
variance | |
T | running_stat::stddev (const u32 norm_type=0) const |
standard deviation | |
eT | running_stat::min () const |
minimum value | |
eT | running_stat::max () const |
maximum value | |
template<typename eT > | |
static void | running_stat_aux::update_stats (running_stat< eT > &x, const eT sample) |
update statistics to reflect new sample | |
template<typename T > | |
static void | running_stat_aux::update_stats (running_stat< std::complex< T > > &x, const T sample) |
update statistics to reflect new sample (version for complex numbers) | |
template<typename T > | |
static void | running_stat_aux::update_stats (running_stat< std::complex< T > > &x, const std::complex< T > &sample) |
alter statistics to reflect new sample (version for complex numbers) |
arma_counter< eT >::~arma_counter | ( | ) | [inline, inherited] |
Definition at line 24 of file running_stat_meat.hpp.
arma_counter< eT >::arma_counter | ( | ) | [inline, inherited] |
Definition at line 33 of file running_stat_meat.hpp.
const arma_counter< eT > & arma_counter< eT >::operator++ | ( | ) | [inline, inherited] |
Definition at line 45 of file running_stat_meat.hpp.
References arma_counter< eT >::d_count, and arma_counter< eT >::i_count.
Referenced by arma_counter< eT >::operator++().
void arma_counter< eT >::operator++ | ( | int | ) | [inline, inherited] |
Definition at line 67 of file running_stat_meat.hpp.
References arma_counter< eT >::operator++().
00068 { 00069 operator++(); 00070 }
void arma_counter< eT >::reset | ( | ) | [inline, inherited] |
Definition at line 77 of file running_stat_meat.hpp.
References arma_counter< eT >::d_count, and arma_counter< eT >::i_count.
Referenced by running_stat_vec< eT >::reset(), and running_stat< eT >::reset().
eT arma_counter< eT >::value | ( | ) | const [inline, inherited] |
Definition at line 88 of file running_stat_meat.hpp.
References arma_counter< eT >::d_count, and arma_counter< eT >::i_count.
Referenced by running_stat_vec< eT >::cov(), running_stat_vec< eT >::stddev(), running_stat_vec_aux::update_stats(), running_stat_aux::update_stats(), running_stat_vec< eT >::var(), and running_stat< eT >::var().
eT arma_counter< eT >::value_plus_1 | ( | ) | const [inline, inherited] |
Definition at line 99 of file running_stat_meat.hpp.
References arma_counter< eT >::d_count, and arma_counter< eT >::i_count.
Referenced by running_stat_vec_aux::update_stats(), and running_stat_aux::update_stats().
eT arma_counter< eT >::value_minus_1 | ( | ) | const [inline, inherited] |
Definition at line 119 of file running_stat_meat.hpp.
References arma_counter< eT >::d_count, and arma_counter< eT >::i_count.
Referenced by running_stat_vec< eT >::cov(), running_stat_vec< eT >::stddev(), running_stat_vec_aux::update_stats(), running_stat_aux::update_stats(), running_stat_vec< eT >::var(), and running_stat< eT >::var().
running_stat< eT >::~running_stat | ( | ) | [inline, inherited] |
Definition at line 139 of file running_stat_meat.hpp.
running_stat< eT >::running_stat | ( | ) | [inline, inherited] |
Definition at line 147 of file running_stat_meat.hpp.
00148 : r_mean ( eT(0)) 00149 , r_var (typename running_stat<eT>::T(0)) 00150 , min_val ( eT(0)) 00151 , max_val ( eT(0)) 00152 , min_val_norm(typename running_stat<eT>::T(0)) 00153 , max_val_norm(typename running_stat<eT>::T(0)) 00154 { 00155 arma_extra_debug_sigprint_this(this); 00156 }
void running_stat< eT >::operator() | ( | const T | sample | ) | [inline, inherited] |
update statistics to reflect new sample
Definition at line 164 of file running_stat_meat.hpp.
References arma_check(), arma_isfinite(), and running_stat_aux::update_stats().
00165 { 00166 arma_extra_debug_sigprint(); 00167 00168 arma_check( (arma_isfinite(sample) == false), "running_stat: non-finite sample given" ); 00169 00170 running_stat_aux::update_stats(*this, sample); 00171 }
void running_stat< eT >::operator() | ( | const std::complex< T > & | sample | ) | [inline, inherited] |
update statistics to reflect new sample (version for complex numbers)
Definition at line 179 of file running_stat_meat.hpp.
References arma_check(), arma_isfinite(), and running_stat_aux::update_stats().
00180 { 00181 arma_extra_debug_sigprint(); 00182 00183 isnt_same_type<eT, std::complex< typename running_stat<eT>::T > >::check(); 00184 00185 arma_check( (arma_isfinite(sample) == false), "running_stat: non-finite sample given" ); 00186 00187 running_stat_aux::update_stats(*this, sample); 00188 }
void running_stat< eT >::reset | ( | ) | [inline, inherited] |
set all statistics to zero
Definition at line 196 of file running_stat_meat.hpp.
References running_stat< eT >::counter, running_stat< eT >::max_val, running_stat< eT >::max_val_norm, running_stat< eT >::min_val, running_stat< eT >::min_val_norm, running_stat< eT >::r_mean, running_stat< eT >::r_var, and arma_counter< eT >::reset().
00197 { 00198 arma_extra_debug_sigprint(); 00199 00200 typedef typename running_stat<eT>::T T; 00201 00202 counter.reset(); 00203 00204 r_mean = eT(0); 00205 r_var = T(0); 00206 00207 min_val = eT(0); 00208 max_val = eT(0); 00209 00210 min_val_norm = T(0); 00211 max_val_norm = T(0); 00212 }
eT running_stat< eT >::mean | ( | ) | const [inline, inherited] |
mean or average value
Definition at line 220 of file running_stat_meat.hpp.
References running_stat< eT >::r_mean.
00222 { 00223 arma_extra_debug_sigprint(); 00224 00225 return r_mean; 00226 }
running_stat< eT >::T running_stat< eT >::var | ( | const u32 | norm_type = 0 |
) | const [inline, inherited] |
variance
Definition at line 234 of file running_stat_meat.hpp.
References running_stat< eT >::counter, running_stat< eT >::r_var, arma_counter< eT >::value(), and arma_counter< eT >::value_minus_1().
00236 { 00237 arma_extra_debug_sigprint(); 00238 00239 const T N = counter.value(); 00240 00241 if(N > T(1)) 00242 { 00243 if(norm_type == 0) 00244 { 00245 return r_var; 00246 } 00247 else 00248 { 00249 const T N_minus_1 = counter.value_minus_1(); 00250 return (N_minus_1/N) * r_var; 00251 } 00252 } 00253 else 00254 { 00255 return T(0); 00256 } 00257 }
running_stat< eT >::T running_stat< eT >::stddev | ( | const u32 | norm_type = 0 |
) | const [inline, inherited] |
standard deviation
Definition at line 265 of file running_stat_meat.hpp.
References sqrt().
00267 { 00268 arma_extra_debug_sigprint(); 00269 00270 return std::sqrt( (*this).var(norm_type) ); 00271 }
eT running_stat< eT >::min | ( | ) | const [inline, inherited] |
minimum value
Definition at line 279 of file running_stat_meat.hpp.
References running_stat< eT >::min_val.
00281 { 00282 arma_extra_debug_sigprint(); 00283 00284 return min_val; 00285 }
eT running_stat< eT >::max | ( | ) | const [inline, inherited] |
maximum value
Definition at line 293 of file running_stat_meat.hpp.
References running_stat< eT >::max_val.
00295 { 00296 arma_extra_debug_sigprint(); 00297 00298 return max_val; 00299 }
void running_stat_aux::update_stats | ( | running_stat< eT > & | x, | |
const eT | sample | |||
) | [inline, static, inherited] |
update statistics to reflect new sample
Definition at line 307 of file running_stat_meat.hpp.
References running_stat< eT >::counter, running_stat< eT >::max_val, running_stat< eT >::min_val, running_stat< eT >::r_mean, running_stat< eT >::r_var, arma_counter< eT >::value(), arma_counter< eT >::value_minus_1(), and arma_counter< eT >::value_plus_1().
Referenced by running_stat< eT >::operator()(), and running_stat_aux::update_stats().
00308 { 00309 arma_extra_debug_sigprint(); 00310 00311 typedef typename running_stat<eT>::T T; 00312 00313 const T N = x.counter.value(); 00314 00315 if(N > T(0)) 00316 { 00317 if(sample < x.min_val) 00318 { 00319 x.min_val = sample; 00320 } 00321 00322 if(sample > x.max_val) 00323 { 00324 x.max_val = sample; 00325 } 00326 00327 const T N_plus_1 = x.counter.value_plus_1(); 00328 const T N_minus_1 = x.counter.value_minus_1(); 00329 00330 // note: variance has to be updated before the mean 00331 00332 const eT tmp = sample - x.r_mean; 00333 00334 x.r_var = N_minus_1/N * x.r_var + (tmp*tmp)/N_plus_1; 00335 00336 x.r_mean = x.r_mean + (sample - x.r_mean)/N_plus_1; 00337 //x.r_mean = (N/N_plus_1)*x.r_mean + sample/N_plus_1; 00338 //x.r_mean = (x.r_mean + sample/N) * N/N_plus_1; 00339 } 00340 else 00341 { 00342 x.r_mean = sample; 00343 x.min_val = sample; 00344 x.max_val = sample; 00345 00346 // r_var is initialised to zero 00347 // in the constructor and reset() 00348 } 00349 00350 x.counter++; 00351 }
void running_stat_aux::update_stats | ( | running_stat< std::complex< T > > & | x, | |
const T | sample | |||
) | [inline, static, inherited] |
update statistics to reflect new sample (version for complex numbers)
Definition at line 359 of file running_stat_meat.hpp.
References running_stat_aux::update_stats().
00360 { 00361 arma_extra_debug_sigprint(); 00362 00363 running_stat_aux::update_stats(x, std::complex<T>(sample)); 00364 }
void running_stat_aux::update_stats | ( | running_stat< std::complex< T > > & | x, | |
const std::complex< T > & | sample | |||
) | [inline, static, inherited] |
alter statistics to reflect new sample (version for complex numbers)
Definition at line 372 of file running_stat_meat.hpp.
References norm().
00373 { 00374 arma_extra_debug_sigprint(); 00375 00376 typedef typename std::complex<T> eT; 00377 00378 const T sample_norm = std::norm(sample); 00379 const T N = x.counter.value(); 00380 00381 if(N > T(0)) 00382 { 00383 if(sample_norm < x.min_val_norm) 00384 { 00385 x.min_val_norm = sample_norm; 00386 x.min_val = sample; 00387 } 00388 00389 if(sample_norm > x.max_val_norm) 00390 { 00391 x.max_val_norm = sample_norm; 00392 x.max_val = sample; 00393 } 00394 00395 const T N_plus_1 = x.counter.value_plus_1(); 00396 const T N_minus_1 = x.counter.value_minus_1(); 00397 00398 x.r_var = N_minus_1/N * x.r_var + std::norm(sample - x.r_mean)/N_plus_1; 00399 00400 x.r_mean = x.r_mean + (sample - x.r_mean)/N_plus_1; 00401 //x.r_mean = (N/N_plus_1)*x.r_mean + sample/N_plus_1; 00402 //x.r_mean = (x.r_mean + sample/N) * N/N_plus_1; 00403 } 00404 else 00405 { 00406 x.r_mean = sample; 00407 x.min_val = sample; 00408 x.max_val = sample; 00409 x.min_val_norm = sample_norm; 00410 x.max_val_norm = sample_norm; 00411 00412 // r_var is initialised to zero 00413 // in the constructor and reset() 00414 } 00415 00416 x.counter++; 00417 }