当前位置: 首页>>代码示例>>C++>>正文


C++ CData::get_item_by_norm_indicator方法代码示例

本文整理汇总了C++中CData::get_item_by_norm_indicator方法的典型用法代码示例。如果您正苦于以下问题:C++ CData::get_item_by_norm_indicator方法的具体用法?C++ CData::get_item_by_norm_indicator怎么用?C++ CData::get_item_by_norm_indicator使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CData的用法示例。


在下文中一共展示了CData::get_item_by_norm_indicator方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: y_q

void CParam::S2_add(Uniform &randUnif,CData &Data) {
  int n_needtoupdate = 0;
  for (int i_faulty=1; i_faulty<=Data.n_faulty; i_faulty++){
    int i_original = Data.Faulty2Original[i_faulty-1];
    ColumnVector item_by_bal;
    ColumnVector s_i = S_Mat.column(i_faulty);
    ColumnVector item_by_rnorm = Data.get_item_by_norm_indicator(s_i,item_by_bal);

    //Generate from normal distribution
    if ( item_by_rnorm.sum() >= 1 ) { // if no random number, other values by balanc edits remain same
    n_needtoupdate++;
    ColumnVector mu_z_i = Mu.column(z_in(i_original)) ;
    ColumnVector tilde_y_i = Data.log_D_Observed.row(i_original).t();
    ColumnVector s_1_compact = Data.get_compact_vector(item_by_rnorm);
    ColumnVector Mu_1i = subvector(mu_z_i,s_1_compact);

    LowerTriangularMatrix LSigma_1i_i;
    ColumnVector y_q(n_var);
    double log_cond_norm_q = calculate_log_cond_norm(Data, i_original, item_by_rnorm, tilde_y_i, y_q, true, LSigma_1i_i, s_i); // MODIFIED 2015/02/16
    ColumnVector y_i = (Y_in.row(i_original)).t() ;
    // ColumnVector y_part_i = subvector(y_i,item_by_rnorm);

    // Put values from balance edits
    ColumnVector x_q = exp_ColumnVector(y_q) ;
    Data.set_balance_edit_values_for_x_q(s_i, x_q, item_by_bal); // CHANGED by Hang, 2014/12/29

    // double log_cond_norm_i = log_MVN_fn(y_part_i,Mu_1i,LSigma_1i_i);
    double log_cond_norm_i = calculate_log_cond_norm(Data, i_original, item_by_rnorm, tilde_y_i, y_q, false, LSigma_1i_i, s_i); // CHANGED 2015/01/27 , // MODIFIED 2015/02/16

    // Acceptance/Rejection
    if (Data.PassEdits(x_q)) {  // Check constraints
    y_q = log_ColumnVector(x_q) ;
    ColumnVector y_compact_q = Data.get_compact_vector(y_q);
    ColumnVector y_compact_i = Data.get_compact_vector(y_i);
    double log_full_norm_q = log_MVN_fn(y_compact_q,mu_z_i,LSIGMA_i[z_in(i_original)-1],logdet_and_more(z_in(i_original)));
    double log_full_norm_i = log_MVN_fn(y_compact_i,mu_z_i,LSIGMA_i[z_in(i_original)-1],logdet_and_more(z_in(i_original)));

    // Calculate acceptance ratio
    double logNum = log_full_norm_q - log_cond_norm_q;
    double logDen = log_full_norm_i - log_cond_norm_i;
    accept_rate(2) = exp( logNum - logDen );

    if (randUnif.Next() < accept_rate(2)){
      Y_in.row(i_original) = y_q.t();
      is_accept(2)++;
    }
    }
    }
  }
  is_accept(2) = is_accept(2) / n_needtoupdate;
}
开发者ID:QuanliWang,项目名称:EditImputeCont,代码行数:51,代码来源:CParam.cpp


注:本文中的CData::get_item_by_norm_indicator方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。