Beispiel #1
0
plJointDistribution createNBJointDist(Variables& variables, Variable& latentVar) {
  const DistValues probValZ = createNBUniVarProbTab( latentVar.cardinality()) ;
  const plProbTable probTabZ(latentVar, probValZ, true);
  
  plComputableObjectList cndProbTab_X_Z = createNBCndTable(variables, latentVar);
  plJointDistribution jointDist(latentVar ^ variables, probTabZ * cndProbTab_X_Z);

  return jointDist;
}
Beispiel #2
0
DistValueMat createNBProbTables( const Variables& variables,  const Variable& latentVar) {
  DistValueMat probTableX;    
  for (size_t var = 0; var < variables.size(); ++var) {
    DistValueVec X_Z;
    for (size_t i = 0; i < latentVar.cardinality(); ++i) {
      const DistValues X_Z_i = createNBUniVarProbTab( variables[var].cardinality() );
      X_Z.push_back(X_Z_i);
    }
    probTableX.push_back(X_Z);
  }    
  return probTableX;
}
Beispiel #3
0
plComputableObjectList createNBCndTable(Variables& variables, Variable& latentVar) {
  plComputableObjectList dataCndTable;
  
  DistValueMat probTableXZ = createNBProbTables(variables, latentVar);
  
  for (size_t x = 0; x < variables.size(); ++x) { 
    plDistributionTable distTab_Xi_Z(variables[x], latentVar); 
    for (size_t h = 0; h < latentVar.cardinality(); ++h) {
      distTab_Xi_Z.push( plProbTable(variables[x], probTableXZ[x][h]), (int)h );
    }
    dataCndTable *= distTab_Xi_Z; // adds the conditional table to result 
  }
    
  return dataCndTable;
}