コード例 #1
0
AbstractModel::SufficientStatisticsVector
MultivariateModel
::GetSufficientStatistics(const Realizations &R, const Observations& Obs) 
{
  /// Computation of the suffisient statistics of the model
  /// Basically, it is a vector (named S1 to S9) of vectors
  
  /// S1 <- y_ij * eta_ij    &    S2 <- eta_ij * eta_ij
  VectorType S1(m_NbTotalOfObservations), S2(m_NbTotalOfObservations);
  auto itS1 = S1.begin(), itS2 = S2.begin();
  for(size_t i = 0; i < m_NumberOfSubjects; ++i)
  {
      for(size_t j = 0; j < Obs.GetNumberOfTimePoints(i); ++j)
      {
          VectorType PC = ComputeParallelCurve(i, j);
          *itS1 = dot_product(PC, Obs.GetSubjectCognitiveScore(i, j));
          *itS2 = PC.squared_magnitude();
          ++itS1, ++itS2;
      }
  }
  
  /// S3 <- Ksi_i   &    S4 <- Ksi_i * Ksi_i
  VectorType S3 = R.at("Ksi");
  VectorType S4 = R.at("Ksi") % R.at("Ksi");
  
  /// S5 <- Tau_i   &    S6 <- Tau_i * Tau_i
  VectorType S5 = R.at("Tau");
  VectorType S6 = R.at("Tau") % R.at("Tau");
  
  /// S7 <- G 
  VectorType S7(1, R.at("G", 0));
  
  /// S8 <- beta_k
  VectorType S8((m_ManifoldDimension-1) * m_NbIndependentSources);
  ScalarType * itS8 = S8.memptr();
  for(size_t i = 0; i < S8.size(); ++i)
      itS8[i] = R.at("Beta#" + std::to_string(i), 0);
  
  /// S8 <- delta_k
  VectorType S9(m_ManifoldDimension - 1);
  ScalarType * itS9 = S9.memptr();
  for(size_t i = 1; i < S9.size(); ++i)
      itS9[i] = R.at("Delta#" + std::to_string(i), 0);

  return {S1, S2, S3, S4, S5, S6, S7, S8, S9};
  
}