diff options
Diffstat (limited to 'experiments/cube.c')
-rw-r--r-- | experiments/cube.c | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/experiments/cube.c b/experiments/cube.c new file mode 100644 index 0000000..845688c --- /dev/null +++ b/experiments/cube.c @@ -0,0 +1,46 @@ +/* How does the cube fare with unbiased extent sampling? + */ + +#include <stdio.h> +#include <gsl/gsl_vector.h> +#include "oracles.h" +#include "extent-sampling.h" + +#define DIMENSION_START 5 +#define DIMENSION_STEP 5 +#define DIMENSION_STOP 50 + +#define TRIALS 100 + +#define RTOL 0.1 +#define EDGE 1.0 + +double cube_oracle (const gsl_vector* x) { + return cube_extent_oracle(x, EDGE); +} + +int main () +{ + gsl_rng_env_setup(); + gsl_rng* r = gsl_rng_alloc(gsl_rng_default); + + FILE* fp = fopen("cube-window.dat", "w"); + printf("dimension\tsamples\n"); + fprintf(fp, "dimension\tsamples\n"); + for (int dim=DIMENSION_START; dim<=DIMENSION_STOP; dim+=DIMENSION_STEP) { + unsigned int total_samples=0; + for (int i=0; i<TRIALS; i++) { + unsigned int number_of_samples; + volume_window(cube_oracle, cube_true_volume(EDGE, dim), r, dim, RTOL, &number_of_samples); + total_samples += number_of_samples; + } + double average_samples = ((double)total_samples)/TRIALS; + printf("%d\t%g\n", dim, average_samples); + fprintf(fp, "%d\t%g\n", dim, average_samples); + fflush(NULL); + } + fclose(fp); + + gsl_rng_free(r); + return 0; +} |