tweak: cleanup.
This commit is contained in:
parent
071bf00d7a
commit
d670b89c4d
|
@ -74,7 +74,7 @@ void mixture(gsl_rng * r, double *dists[], double *weights, int n, double *resul
|
||||||
double cummulative_weights[n];
|
double cummulative_weights[n];
|
||||||
cumsum(normalized_weights, cummulative_weights, n);
|
cumsum(normalized_weights, cummulative_weights, n);
|
||||||
|
|
||||||
/* Get N uniformly distributed vars */
|
/* Get N samples, drawn from the different distributions in proportion to their weights. */
|
||||||
for(int i=0; i<N; i++){
|
for(int i=0; i<N; i++){
|
||||||
double p_1 = gsl_rng_uniform(r);
|
double p_1 = gsl_rng_uniform(r);
|
||||||
double p_2 = gsl_rng_uniform(r);
|
double p_2 = gsl_rng_uniform(r);
|
||||||
|
@ -98,8 +98,6 @@ void mixture(gsl_rng * r, double *dists[], double *weights, int n, double *resul
|
||||||
results[i] = dists[index_counter][sample_index];
|
results[i] = dists[index_counter][sample_index];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Main */
|
/* Main */
|
||||||
|
@ -128,7 +126,7 @@ int main(void){
|
||||||
|
|
||||||
/* Generate mixture */
|
/* Generate mixture */
|
||||||
int n = 4;
|
int n = 4;
|
||||||
double weights[] = { 1 - p_c, p_c/2, p_c/4, p_c/4};
|
double weights[] = { 1 - p_c, p_c/2, p_c/4, p_c/4 };
|
||||||
double *dists[] = { dist_none, dist_one, dist_few, dist_many };
|
double *dists[] = { dist_none, dist_one, dist_few, dist_many };
|
||||||
|
|
||||||
mixture(r, dists, weights, n, dist_mixture);
|
mixture(r, dists, weights, n, dist_mixture);
|
||||||
|
|
|
@ -39,6 +39,9 @@ I was very surprised that Node/Squiggle code was almost as fast as the raw C cod
|
||||||
|
|
||||||
The future of this project is uncertain. In most words, I simply forget about this repository.
|
The future of this project is uncertain. In most words, I simply forget about this repository.
|
||||||
|
|
||||||
|
To do:
|
||||||
|
- [ ] Check whether the Squiggle code is producing 1M samples.
|
||||||
|
|
||||||
## Other similar projects
|
## Other similar projects
|
||||||
|
|
||||||
- Squigglepy: <https://github.com/rethinkpriorities/squigglepy>
|
- Squigglepy: <https://github.com/rethinkpriorities/squigglepy>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user