forked from personal/squiggle.c
add sample_laplace
This commit is contained in:
parent
91ab0d27dc
commit
fb6edbff0c
|
@ -134,6 +134,10 @@ double sample_beta(double a, double b, uint64_t* seed)
|
||||||
return gamma_a / (gamma_a + gamma_b);
|
return gamma_a / (gamma_a + gamma_b);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
double sample_laplace(double successes, double failures, uint64_t* seed){
|
||||||
|
return sample_beta(successes + 1, failures + 1, seed);
|
||||||
|
}
|
||||||
|
|
||||||
// Array helpers
|
// Array helpers
|
||||||
double array_sum(double* array, int length)
|
double array_sum(double* array, int length)
|
||||||
{
|
{
|
||||||
|
|
|
@ -19,6 +19,7 @@ double sample_to(double low, double high, uint64_t* seed);
|
||||||
|
|
||||||
double sample_gamma(double alpha, uint64_t* seed);
|
double sample_gamma(double alpha, uint64_t* seed);
|
||||||
double sample_beta(double a, double b, uint64_t* seed);
|
double sample_beta(double a, double b, uint64_t* seed);
|
||||||
|
double sample_laplace(double successes, double failures, uint64_t* seed);
|
||||||
|
|
||||||
// Array helpers
|
// Array helpers
|
||||||
double array_sum(double* array, int length);
|
double array_sum(double* array, int length);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user