simplify unneeded imports, use nested functions a bit more

This commit is contained in:
NunoSempere 2023-11-19 19:25:42 +00:00
parent e61918f107
commit 93e13bad9c
22 changed files with 5 additions and 45 deletions

View File

@ -1,5 +1,4 @@
#include "../../../squiggle.h" #include "../../../squiggle.h"
#include <stdint.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>

View File

@ -1,5 +1,4 @@
#include "../../../squiggle.h" #include "../../../squiggle.h"
#include <stdint.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>

View File

@ -1,29 +1,7 @@
#include "../../../squiggle.h" #include "../../../squiggle.h"
#include <stdint.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
// Estimate functions
double sample_0(uint64_t* seed)
{
return 0;
}
double sample_1(uint64_t* seed)
{
return 1;
}
double sample_few(uint64_t* seed)
{
return sample_to(1, 3, seed);
}
double sample_many(uint64_t* seed)
{
return sample_to(2, 10, seed);
}
int main() int main()
{ {
// set randomness seed // set randomness seed
@ -34,6 +12,11 @@ int main()
double p_b = 0.5; double p_b = 0.5;
double p_c = p_a * p_b; double p_c = p_a * p_b;
double sample_0(uint64_t* seed){ return 0; }
double sample_1(uint64_t* seed) { return 1; }
double sample_few(uint64_t* seed) { return sample_to(1, 3, seed); }
double sample_many(uint64_t* seed) { return sample_to(2, 10, seed); }
int n_dists = 4; int n_dists = 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 (*samplers[])(uint64_t*) = { sample_0, sample_1, sample_few, sample_many }; double (*samplers[])(uint64_t*) = { sample_0, sample_1, sample_few, sample_many };
@ -45,11 +28,5 @@ int main()
} }
printf("Mean: %f\n", array_mean(result_many, n_samples)); printf("Mean: %f\n", array_mean(result_many, n_samples));
// printf("result_many: [");
// for(int i=0; i<100; i++){
// printf("%.2f, ", result_many[i]);
// }
// printf("]\n");
free(seed); free(seed);
} }

View File

@ -1,5 +1,4 @@
#include "../../../squiggle.h" #include "../../../squiggle.h"
#include <stdint.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>

View File

@ -1,5 +1,4 @@
#include "../../../squiggle.h" #include "../../../squiggle.h"
#include <stdint.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>

View File

@ -1,5 +1,4 @@
#include "../../../squiggle.h" #include "../../../squiggle.h"
#include <stdint.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>

View File

@ -1,6 +1,5 @@
#include "../../../squiggle.h" #include "../../../squiggle.h"
#include "../../../squiggle_more.h" #include "../../../squiggle_more.h"
#include <stdint.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>

View File

@ -1,7 +1,6 @@
#include "../../../squiggle.h" #include "../../../squiggle.h"
#include "../../../squiggle_more.h" #include "../../../squiggle_more.h"
#include <math.h> #include <math.h>
#include <stdint.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <time.h> #include <time.h>

View File

@ -1,7 +1,6 @@
#include "../../../squiggle.h" #include "../../../squiggle.h"
#include "../../../squiggle_more.h" #include "../../../squiggle_more.h"
#include <math.h> #include <math.h>
#include <stdint.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <time.h> #include <time.h>

View File

@ -1,6 +1,5 @@
#include "../../../squiggle.h" #include "../../../squiggle.h"
#include "../../../squiggle_more.h" #include "../../../squiggle_more.h"
#include <stdint.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>

View File

@ -1,7 +1,6 @@
#include "../../../squiggle.h" #include "../../../squiggle.h"
#include "../../../squiggle_more.h" #include "../../../squiggle_more.h"
#include <math.h> #include <math.h>
#include <stdint.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>

View File

@ -1,7 +1,6 @@
#include "../../../squiggle.h" #include "../../../squiggle.h"
#include "../../../squiggle_more.h" #include "../../../squiggle_more.h"
#include <math.h> #include <math.h>
#include <stdint.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>

View File

@ -1,7 +1,6 @@
#include "../../../squiggle.h" #include "../../../squiggle.h"
#include "../../../squiggle_more.h" #include "../../../squiggle_more.h"
#include <math.h> #include <math.h>
#include <stdint.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>

View File

@ -1,7 +1,6 @@
#include "../../../squiggle.h" #include "../../../squiggle.h"
#include "../../../squiggle_more.h" #include "../../../squiggle_more.h"
#include <math.h> #include <math.h>
#include <stdint.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>

View File

@ -1,7 +1,6 @@
#include "../../../squiggle.h" #include "../../../squiggle.h"
#include "../../../squiggle_more.h" #include "../../../squiggle_more.h"
#include <math.h> #include <math.h>
#include <stdint.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>

View File

@ -1,7 +1,6 @@
#include "../../../squiggle.h" #include "../../../squiggle.h"
#include "../../../squiggle_more.h" #include "../../../squiggle_more.h"
#include <math.h> #include <math.h>
#include <stdint.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>

View File

@ -1,6 +1,5 @@
#include "../../../squiggle.h" #include "../../../squiggle.h"
#include "../../../squiggle_more.h" #include "../../../squiggle_more.h"
#include <stdint.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>

View File

@ -1,6 +1,5 @@
#include "../../../squiggle.h" #include "../../../squiggle.h"
#include "../../../squiggle_more.h" #include "../../../squiggle_more.h"
#include <stdint.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>