Skip to content

Commit

Permalink
test beta geometric distribution.
Browse files Browse the repository at this point in the history
  • Loading branch information
zzjjzzgggg committed Jul 14, 2017
1 parent 379aaec commit 767570b
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions test/test_mathutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,16 @@ double pr(int x, double mu, double theta) {
}

int main(int argc, char *argv[]) {
int n = 10;
double mu = .2, theta = .01, alpha = mu / theta, beta = (1 - mu) / theta,
sum = 0, sum2 = SpecFun::BetaBinomial(0, n, alpha, beta);
int n = 15;
double mu = .3, theta = .01, alpha = mu / theta, beta = (1 - mu) / theta,
sum = SpecFun::BetaBinomial(0, n, alpha, beta);

for (int i = 1; i <= n; i++) {
double val = SpecFun::BetaGeometric(i, alpha, beta);
printf("%d: %.6f, %.6f\n", i, val, pr(i, mu, theta));
sum += val;
sum2 += pr(i, mu, theta);
}
printf("\n%.4f, %.4f\n", sum, sum2);
printf("\n%.4f\n", sum);

return 0;
}

0 comments on commit 767570b

Please sign in to comment.