29 : calc_cov(in_calc_cov)
90 if( sample.is_empty() )
95 if( sample.is_finite() == false )
97 arma_warn(
true,
"running_stat_vec: sample ignored as it has non-finite elements");
107 template<
typename eT>
108 template<
typename T1>
121 if( sample.is_empty() )
126 if( sample.is_finite() == false )
128 arma_warn(
true,
"running_stat_vec: sample ignored as it has non-finite elements");
138 template<
typename eT>
167 template<
typename eT>
180 template<
typename eT>
216 template<
typename eT>
247 template<
typename eT>
292 template<
typename eT>
305 template<
typename eT>
318 template<
typename eT>
335 template<
typename eT>
351 const eT* sample_mem = sample.
memptr();
352 eT* r_mean_mem = x.
r_mean.memptr();
354 eT* min_val_mem = x.
min_val.memptr();
355 eT* max_val_mem = x.
max_val.memptr();
369 tmp2 = tmp1*
trans(tmp1);
376 x.
r_cov *= (N_minus_1/N);
377 x.
r_cov += tmp2 / N_plus_1;
381 for(
uword i=0; i<n_elem; ++i)
383 const eT val = sample_mem[i];
385 if(val < min_val_mem[i])
387 min_val_mem[i] = val;
390 if(val > max_val_mem[i])
392 max_val_mem[i] = val;
395 const eT r_mean_val = r_mean_mem[i];
396 const eT tmp = val - r_mean_val;
398 r_var_mem[i] = N_minus_1/N * r_var_mem[i] + (tmp*tmp)/N_plus_1;
400 r_mean_mem[i] = r_mean_val + (val - r_mean_val)/N_plus_1;
421 const eT* sample_mem = sample.
memptr();
422 eT* r_mean_mem = x.
r_mean.memptr();
423 eT* min_val_mem = x.
min_val.memptr();
424 eT* max_val_mem = x.
max_val.memptr();
427 for(
uword i=0; i<n_elem; ++i)
429 const eT val = sample_mem[i];
432 min_val_mem[i] = val;
433 max_val_mem[i] = val;
465 typedef typename std::complex<T> eT;
467 const T N = x.counter.value();
473 const uword n_elem = sample.n_elem;
474 const eT* sample_mem = sample.memptr();
475 eT* r_mean_mem = x.r_mean.memptr();
476 T* r_var_mem = x.r_var.memptr();
477 eT* min_val_mem = x.min_val.memptr();
478 eT* max_val_mem = x.max_val.memptr();
479 T* min_val_norm_mem = x.min_val_norm.memptr();
480 T* max_val_norm_mem = x.max_val_norm.memptr();
482 const T N_plus_1 = x.counter.value_plus_1();
483 const T N_minus_1 = x.counter.value_minus_1();
485 if(x.calc_cov ==
true)
490 tmp1 = sample - x.r_mean;
492 if(sample.n_cols == 1)
501 x.r_cov *= (N_minus_1/N);
502 x.r_cov += tmp2 / N_plus_1;
506 for(
uword i=0; i<n_elem; ++i)
508 const eT& val = sample_mem[i];
511 if(val_norm < min_val_norm_mem[i])
513 min_val_norm_mem[i] = val_norm;
514 min_val_mem[i] = val;
517 if(val_norm > max_val_norm_mem[i])
519 max_val_norm_mem[i] = val_norm;
520 max_val_mem[i] = val;
523 const eT& r_mean_val = r_mean_mem[i];
525 r_var_mem[i] = N_minus_1/N * r_var_mem[i] +
std::norm(val - r_mean_val)/N_plus_1;
527 r_mean_mem[i] = r_mean_val + (val - r_mean_val)/N_plus_1;
533 arma_debug_check( (sample.is_vec() ==
false),
"running_stat_vec(): given sample is not a vector");
535 x.r_mean.set_size(sample.n_rows, sample.n_cols);
537 x.r_var.zeros(sample.n_rows, sample.n_cols);
539 if(x.calc_cov ==
true)
541 x.r_cov.zeros(sample.n_elem, sample.n_elem);
544 x.min_val.set_size(sample.n_rows, sample.n_cols);
545 x.max_val.set_size(sample.n_rows, sample.n_cols);
547 x.min_val_norm.set_size(sample.n_rows, sample.n_cols);
548 x.max_val_norm.set_size(sample.n_rows, sample.n_cols);
551 const uword n_elem = sample.n_elem;
552 const eT* sample_mem = sample.memptr();
553 eT* r_mean_mem = x.r_mean.memptr();
554 eT* min_val_mem = x.min_val.memptr();
555 eT* max_val_mem = x.max_val.memptr();
556 T* min_val_norm_mem = x.min_val_norm.memptr();
557 T* max_val_norm_mem = x.max_val_norm.memptr();
559 for(
uword i=0; i<n_elem; ++i)
561 const eT& val = sample_mem[i];
565 min_val_mem[i] = val;
566 max_val_mem[i] = val;
568 min_val_norm_mem[i] = val_norm;
569 max_val_norm_mem[i] = val_norm;
arma_inline arma_warn_unused bool is_vec() const
returns true if the object can be interpreted as a column or row vector
arma_inline arma_warn_unused eT * memptr()
returns a pointer to array of eTs used by the matrix
static void update_stats(running_stat_vec< eT > &x, const Mat< eT > &sample)
update statistics to reflect new sample
arma_inline const eOp< T1, eop_sqrt > sqrt(const Base< typename T1::elem_type, T1 > &A)
T count() const
number of samples so far
const Mat< eT > & mean() const
mean or average value
const uword n_cols
number of columns in the matrix (read-only)
#define arma_debug_assert_same_size
arma_aligned Mat< eT > min_val
arma_aligned Mat< eT > r_cov
arma_inline const T1 & conj(const Base< typename T1::pod_type, T1 > &A)
const uword n_elem
number of elements in the matrix (read-only)
const uword n_rows
number of rows in the matrix (read-only)
const Mat< eT > & min() const
vector with minimum values
arma_warn_unused T1::pod_type norm(const Base< typename T1::elem_type, T1 > &X, const uword k, const typename arma_float_or_cx_only< typename T1::elem_type >::result *junk=0)
arma_aligned arma_counter< T > counter
arma_inline const Op< T1, op_strans > strans(const Base< typename T1::elem_type, T1 > &X, const typename arma_cx_only< typename T1::elem_type >::result *junk=0)
Mat< T > stddev(const uword norm_type=0) const
standard deviation
arma_inline const Op< T1, op_htrans > trans(const Base< typename T1::elem_type, T1 > &X)
static arma_inline T1 & rw(const T1 &x)
internal function to allow modification of data declared as read-only
arma_aligned Mat< T > min_val_norm
arma_aligned Mat< eT > r_mean
arma_aligned Mat< T > max_val_norm
#define arma_extra_debug_sigprint_this
arma_aligned Mat< T > r_var
const Mat< T > & var(const uword norm_type=0)
variance
arma_aligned Mat< eT > tmp2
const Mat< eT > & max() const
vector with maximum values
running_stat_vec(const bool in_calc_cov=false)
#define arma_extra_debug_sigprint
void arma_cold arma_warn(const bool state, const T1 &x)
print a message to the warn stream
arma_aligned Mat< eT > max_val
get_pod_type< eT >::result T
arma_aligned Mat< eT > tmp1
const Mat< eT > & cov(const uword norm_type=0)
covariance
const running_stat_vec & operator=(const running_stat_vec &in_rsv)
void reset()
set all statistics to zero
arma_aligned Mat< T > r_var_dummy
arma_hot void operator()(const Base< T, T1 > &X)
arma_aligned Mat< eT > r_cov_dummy