diff options
| author | Tyge Løvset <[email protected]> | 2020-12-02 09:17:05 +0100 |
|---|---|---|
| committer | Tyge Løvset <[email protected]> | 2020-12-02 09:17:05 +0100 |
| commit | e60e9f398f43ba09a7f0027ac93d4f8f61a9f254 (patch) | |
| tree | 7ddd7067fbe0290562ef3f4756663125fa270d6c /examples | |
| parent | a754aabd160fc02cf44b4a02deaffff9b233387f (diff) | |
| download | STC-modified-e60e9f398f43ba09a7f0027ac93d4f8f61a9f254.tar.gz STC-modified-e60e9f398f43ba09a7f0027ac93d4f8f61a9f254.zip | |
Added better crandom and cvec example.
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/ex_gaussian.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/examples/ex_gaussian.c b/examples/ex_gaussian.c index e61a3156..3ef20e7d 100644 --- a/examples/ex_gaussian.c +++ b/examples/ex_gaussian.c @@ -1,10 +1,10 @@ #include <stdio.h>
#include <time.h>
#include <math.h>
-#include <stc/crandom.h>
-#include <stc/cstr.h>
-#include <stc/cmap.h>
-#include <stc/cvec.h>
+#include "stc/crandom.h"
+#include "stc/cstr.h"
+#include "stc/cmap.h"
+#include "stc/cvec.h"
// Declare int -> int hashmap. Uses typetag 'i' for ints.
using_cmap(i, int, size_t);
@@ -19,7 +19,7 @@ using_cvec(e, cmap_i_entry_t, c_default_del, compare); int main()
{
enum {N = 10000000};
- const double Mean = -12.0, StdDev = 6.0, Mag = 8000.0 / StdDev;
+ const double Mean = -12.0, StdDev = 6.0, Scale = 74;
printf("Demo of gaussian / normal distribution of %d random samples\n", N);
@@ -44,7 +44,7 @@ int main() // Print the gaussian bar chart
cstr_t bar = cstr_init();
c_foreach (i, cvec_e, vhist) {
- size_t n = (size_t) (i.val->second * Mag / N);
+ size_t n = (size_t) (i.val->second * StdDev * Scale * 2.5 / N);
if (n > 0) {
// bar string: take ownership in new str after freeing current.
cstr_take(&bar, cstr_with_size(n, '*'));
|
