33 ColumnVector expectedValue(DimensionGet());
35 for (
int i=0; i<NumComponentsGet();i++)
36 expectedValue = expectedValue + ( (*_componentPdfs)[i]->ExpectedValueGet() * (double)((*_componentWeights)[i]) );
48 unsigned int expectedValue =0;
49 double probState = 0.0;
50 double mostProbState = -1.0;
51 int numStates = ((
DiscretePdf*)((*_componentPdfs)[0]))->NumStatesGet();
52 for (
int i=0; i<NumComponentsGet();i++)
54 if(numStates != ((
DiscretePdf*)((*_componentPdfs)[i]))->NumStatesGet())
56 cerr <<
"Mixture::ExpectedValueGet failed since the different components in the mixture don't have the same number of states" << endl;
60 for (
int j=0; j<numStates ;j++ )
63 for (
int i=0; i<NumComponentsGet();i++)
65 probState += ( ((double)(*_componentPdfs)[i]->ProbabilityGet(j)) * (
double)((*_componentWeights)[i]) );
67 if (probState > mostProbState)
69 expectedValue = (
unsigned int)j;
70 mostProbState = probState;
85 double probState = 0.0;
86 double mostProbState = -1.0;
87 int numStates = ((
DiscretePdf*)((*_componentPdfs)[0]))->NumStatesGet();
88 for (
int i=0; i<NumComponentsGet();i++)
90 if(numStates != ((
DiscretePdf*)((*_componentPdfs)[i]))->NumStatesGet())
92 cerr <<
"Mixture::ExpectedValueGet failed since the different components in the mixture don't have the same number of states" << endl;
96 for (
int j=0; j< numStates;j++ )
99 for (
int i=0; i<NumComponentsGet();i++)
101 probState += ( ((double)(*_componentPdfs)[i]->ProbabilityGet(j)) * (
double)((*_componentWeights)[i]) );
103 if (probState > mostProbState)
106 mostProbState = probState;
109 return expectedValue;
118 double expectedValue;
120 for (
int i=0; i<NumComponentsGet();i++)
121 expectedValue = expectedValue + ( (*_componentPdfs)[i]->ExpectedValueGet() * (double)((*_componentWeights)[i]) );
122 return expectedValue;
Class representing a PDF on a discrete variable.
T ExpectedValueGet() const
Get the expected value E[x] of the pdf.