diff options
| author | Tyge Løvset <[email protected]> | 2023-03-30 17:59:08 +0200 |
|---|---|---|
| committer | Tyge Løvset <[email protected]> | 2023-03-30 17:59:08 +0200 |
| commit | a0a290645828c88597efce80f6b0f5a958cefa89 (patch) | |
| tree | 53dc78071653b515a06a60baf4488a1b6d080b32 /misc/examples/gauss2.c | |
| parent | 32df5677c9906661e91aad294e45a258e2eaab18 (diff) | |
| download | STC-modified-a0a290645828c88597efce80f6b0f5a958cefa89.tar.gz STC-modified-a0a290645828c88597efce80f6b0f5a958cefa89.zip | |
Added crand.h - Alternative API to crandom.h, which will be deprecated.
Diffstat (limited to 'misc/examples/gauss2.c')
| -rw-r--r-- | misc/examples/gauss2.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/misc/examples/gauss2.c b/misc/examples/gauss2.c index 7fede5aa..df709d03 100644 --- a/misc/examples/gauss2.c +++ b/misc/examples/gauss2.c @@ -1,7 +1,7 @@ #include <stdio.h> #include <time.h> -#include <stc/crandom.h> +#include <stc/crand.h> #include <stc/cstr.h> // Declare int -> int sorted map. @@ -13,21 +13,21 @@ int main() { enum {N = 5000000}; uint64_t seed = (uint64_t)time(NULL); - stc64_t rng = stc64_new(seed); - const double Mean = round(stc64_randf(&rng)*98.f - 49.f), StdDev = stc64_randf(&rng)*10.f + 1.f, Scale = 74.f; + crand_t rng = crand_init(seed); + const double Mean = round(crand_f64(&rng)*98.f - 49.f), StdDev = crand_f64(&rng)*10.f + 1.f, Scale = 74.f; printf("Demo of gaussian / normal distribution of %d random samples\n", N); printf("Mean %f, StdDev %f\n", Mean, StdDev); // Setup random engine with normal distribution. - stc64_normalf_t dist = stc64_normalf_new(Mean, StdDev); + crand_norm_t dist = crand_norm_init(Mean, StdDev); // Create and init histogram map with defered destruct csmap_int hist = {0}; cstr bar = {0}; c_forrange (N) { - int index = (int)round( stc64_normalf(&rng, &dist) ); + int index = (int)round(crand_norm(&rng, &dist)); csmap_int_insert(&hist, index, 0).ref->second += 1; } |
