Skip to content

Commit

Permalink
fixed initial guess for m
Browse files Browse the repository at this point in the history
  • Loading branch information
xyang619 committed Aug 26, 2015
1 parent ee3f6a4 commit 3458629
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions src/ParamExp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,21 @@ ParamExp::ParamExp(int K) :
K(K)
{
lambda = new double[K];
prop = new double[K];
for (int i = 0; i < K; ++i)
{
lambda[i] = 1.0 * rand() / RAND_MAX;
prop[i] = 1.0 / K;
}
prop = new double[K];
double tmp = 0;
for (int i = 0; i < (K - 1); ++i)
{
prop[i] = rand() / (1.0 * K * RAND_MAX);
tmp += prop[i];
}
//ensure sum to one
prop[K - 1] = 1 - tmp;

// double tmp = 0;
// for (int i = 0; i < (K - 1); ++i)
// {
// prop[i] = rand() / (1.0 * K * RAND_MAX);
// tmp += prop[i];
// }
// //ensure sum to one
// prop[K - 1] = 1 - tmp;
}

/* another constructor
Expand Down

0 comments on commit 3458629

Please sign in to comment.