本文整理汇总了C++中CData::UpdateFullVector方法的典型用法代码示例。如果您正苦于以下问题:C++ CData::UpdateFullVector方法的具体用法?C++ CData::UpdateFullVector怎么用?C++ CData::UpdateFullVector使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CData
的用法示例。
在下文中一共展示了CData::UpdateFullVector方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CalculateInitProbA
void CParam::CalculateInitProbA(CData &Data) {
// initial value of Y_out_compact and z_out
int count_out = 0; int count_in = 0;
ColumnVector z_out_large(toolarge_nout);
Matrix Y_out_compact_large(toolarge_nout,n_var_independent);
while ( (count_in < Data.n_sample) && (count_out < toolarge_nout) ) {
int k = rdiscrete_fn(pi);
ColumnVector mu_k = Mu.column(k); // Note that mu_k is Mu.column(k)
ColumnVector y_compact_i = rMVN_fn( mu_k,LSIGMA[k-1] );
ColumnVector x_compact_i = exp_ColumnVector(y_compact_i);
ColumnVector x_i(Data.n_var) ;
Data.UpdateFullVector(x_compact_i, x_i);
Data.update_full_x_for_balance_edit(x_i);
if (Data.PassEdits(x_i)) {
count_in++;
} else {
count_out++;
Y_out_compact_large.row(count_out) = y_compact_i.t();
z_out_large(count_out)=k;
}
}
Matrix Y_out_compact = Y_out_compact_large.rows(1,count_out) ; // cut extra space
ColumnVector z_out = z_out_large.rows(1,count_out) ; // cut extra space
// calculate n_z and Sum_groupX
Matrix Y_aug_compact = Y_in_compact & Y_out_compact;
ColumnVector z_aug = z_in & z_out;
int n_out = z_out.nrows();
Prob_A = (1.0 * Data.n_sample / (Data.n_sample+n_out));
}
示例2: z_out_large
void CParam::S4_Z_out(CData &Data) {
int count_out = 0, count_in = 0;
ColumnVector z_out_large(toolarge_nout);
Matrix Y_out_compact_large(toolarge_nout,n_var_independent);
Matrix X_aux(n_sample,n_var);
while ( (count_in < n_sample) && (count_out < toolarge_nout) ) {
int k = rdiscrete_fn(pi);
ColumnVector mu_k = Mu.column(k); // Note that mu_k is Mu.column(k)
ColumnVector y_compact_i = rMVN_fn( mu_k, LSIGMA[k-1] );
// ADDED by HANG to check infinity value of x_full_i
int check_infinity = 0 ;
if (y_compact_i.maximum()>700){
check_infinity = 1 ;
if ( msg_level >= 1 ) {
Rprintf( " Warning: x_out from N(Mu_k,Sigma_k) > exp(700). There is no harm for convergence and inference, but the computation may get slower if you see this warning too often, e.g. every iteration\n");
}
}
if (check_infinity==0){
ColumnVector x_compact_i = exp_ColumnVector(y_compact_i);
ColumnVector x_full_i(n_var) ;
Data.UpdateFullVector(x_compact_i,x_full_i);
Data.update_full_x_for_balance_edit(x_full_i);
// do not need to consdier min(x_full_i)>0 since x_compact_i=exp(y_compact_i)
if (Data.PassEdits(x_full_i)) {
X_aux.row(++count_in) = x_full_i.t();
} else {
Y_out_compact_large.row(++count_out) = y_compact_i.t();
z_out_large(count_out)=k;
}
} // if (check_infinity==0) : ADDED by HANG
} // while ( (count_in < n_sample) && (count_out < toolarge_nout) )
Matrix Y_out_compact = Y_out_compact_large.rows(1,count_out) ; // cut extra space
ColumnVector z_out = z_out_large.rows(1,count_out) ; // cut extra space
Prob_A = 1.0 * n_sample / (n_sample+count_out) ;
// calculate n_z and Sum_groupX
Data.UpdateCompactMatrix(Y_in_compact,Y_in);
Y_aug_compact = Y_in_compact & Y_out_compact;
z_aug = z_in & z_out;
int n_aug = z_aug.nrows() ;
n_z = 0 ;
X_bar = Matrix(n_var_independent,K); X_bar= 0.0 ;
for (int i_aug=1; i_aug<=n_aug; i_aug++) {
int k = z_aug(i_aug);
n_z(k) = n_z(k) + 1 ;
RowVector y_compact_t = Y_aug_compact.row(i_aug);
ColumnVector y_i_compact = y_compact_t.t() ;
X_bar.column(k) += y_i_compact;
}
for (int k = 1; k <= K; k++) {
if (n_z(k) > 0) {
X_bar.column(k) *= (1.0/n_z(k));
}
}
}