commit cd6eb5203c169c5bc67f6bf0cf8df48bb786061d
parent 65756a359be71ff26a66b7559d50b8b47c9a2957
Author: NunoSempere <nuno.sempere@protonmail.com>
Date: Sun, 16 Jul 2023 17:59:53 +0200
add some thoughts to scratchpad and readme
Diffstat:
3 files changed, 16 insertions(+), 6 deletions(-)
diff --git a/scratchpad/scratchpad b/scratchpad/scratchpad
Binary files differ.
diff --git a/scratchpad/scratchpad.c b/scratchpad/scratchpad.c
@@ -21,7 +21,7 @@
return error; \
} \
} while (0)
-#define NUM_SAMPLES 10
+#define NUM_SAMPLES 1000000
struct box {
int empty;
@@ -399,7 +399,7 @@ void test_and_time_sampler_float(char* cdf_name, float cdf_float(float), uint32_
if (sample.empty) {
printf("Error in sampler function for %s", cdf_name);
} else {
- printf("%f\n", sample.content);
+ // printf("%f\n", sample.content);
}
}
clock_t end = clock();
@@ -416,7 +416,7 @@ void test_and_time_sampler_box(char* cdf_name, struct box cdf_box(float), uint32
if (sample.empty) {
printf("Error in sampler function for %s", cdf_name);
} else {
- printf("%f\n", sample.content);
+ // printf("%f\n", sample.content);
}
}
clock_t end = clock();
@@ -451,7 +451,7 @@ int main()
for (int i = 0; i < NUM_SAMPLES; i++) {
float normal_sample = sampler_normal_0_1(seed);
- printf("%f\n", normal_sample);
+ // printf("%f\n", normal_sample);
}
clock_t end_2 = clock();
@@ -460,6 +460,11 @@ int main()
// Test box sampler
test_and_time_sampler_box("cdf_beta", cdf_beta, seed);
+ // Ok, this is slower than python!!
+ // Partly this is because I am using a more general algorithm,
+ // which applies to any cdf
+ // But I am also using really anal convergence conditions.
+ // This could be optimized.
free(seed);
return 0;
diff --git a/to-do.md b/to-do.md
@@ -6,6 +6,11 @@
- [x] Chain various mixture functions
- [ ] Have some more complicated & realistic example
- [ ] Add summarization functions, like mean, std, 90% ci (or all c.i.?)
-- [ ] Add beta distribution
+- [x] Add beta distribution
+ - See <https://stats.stackexchange.com/questions/502146/how-does-numpy-generate-samples-from-a-beta-distribution> for a faster method.
- [ ] Use OpenMP for acceleration
-- [ ] Add function to get sample when given a cdf
+- [x] Add function to get sample when given a cdf
+- [ ] Don't have a single header file.
+- [ ] Structure project a bit better
+- [ ] Add README
+- [ ] Publish