From 774d54ed817d1bdc32028a9e4ca1cab5a458ee4d Mon Sep 17 00:00:00 2001 From: NunoSempere Date: Sat, 24 Feb 2024 23:33:09 -0300 Subject: [PATCH] very small division tweaks --- ROADMAP.md | 1 + squiggle.c | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/ROADMAP.md b/ROADMAP.md index fdad72e..2226307 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -8,6 +8,7 @@ - [x] Give examples of new functions - [x] Reference commit with cdf functions, even though deleted - [ ] Post on suckless subreddit +- [ ] Look into instead? - [ ] Drive in a few more real-life applications - [ ] US election modelling? - [ ] Look into using size_t instead of int for sample numbers diff --git a/squiggle.c b/squiggle.c index ec0d4a2..3f2f4d3 100644 --- a/squiggle.c +++ b/squiggle.c @@ -50,7 +50,7 @@ double sample_unit_normal(uint64_t* seed) // // See: double u1 = sample_unit_uniform(seed); double u2 = sample_unit_uniform(seed); - double z = sqrt(-2.0 * log(u1)) * sin(2 * PI * u2); + double z = sqrt(-2.0 * log(u1)) * sin(2.0 * PI * u2); return z; } @@ -90,7 +90,7 @@ double sample_normal_from_90_ci(double low, double high, uint64_t* seed) // 5. If we want a 90% confidence interval from high to low, // we can set mean = (high + low)/2; the midpoint, and L = high-low, // Normal([high + low]/2, [high - low]/(2 * 1.6448536269514722)) - double mean = (high + low) / 2.0; + double mean = (high + low) * 0.5; double std = (high - low) / (2.0 * NORMAL90CONFIDENCE); return sample_normal(mean, std, seed); }