diff options
author | Arun Isaac | 2021-06-30 14:46:38 +0530 |
---|---|---|
committer | Arun Isaac | 2021-06-30 14:46:38 +0530 |
commit | ec527081eaaec124c070288befc0815b139ee232 (patch) | |
tree | 8ff66256b3712a07dd139c8d0a7c3c467a5f4792 /src | |
parent | f60a54c593411803a8617c9dcda2f667095d2487 (diff) | |
download | nsmc-ec527081eaaec124c070288befc0815b139ee232.tar.gz nsmc-ec527081eaaec124c070288befc0815b139ee232.tar.lz nsmc-ec527081eaaec124c070288befc0815b139ee232.zip |
Implement window stopping criterion for integrals.
* src/extent-sampling.sc (integral): Implement window stopping
criterion.
Diffstat (limited to 'src')
-rw-r--r-- | src/extent-sampling.sc | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/src/extent-sampling.sc b/src/extent-sampling.sc index 0c0708c..d46f31d 100644 --- a/src/extent-sampling.sc +++ b/src/extent-sampling.sc @@ -78,15 +78,21 @@ (return (* (surface-area-of-ball n) result)))) -(define (integral integrand extent-oracle true-integral r dimension rtol stats) - (void (const integrand-t*) (const extent-oracle-t*) double (const gsl-rng*) (unsigned int) double gsl-rstat-workspace*) - (with-vector x dimension - (do-while (> (rerror (gsl-rstat-mean stats) true-integral) - rtol) - (random-direction-vector r x) - (gsl-rstat-add (integral-per-direction integrand x dimension - (invoke-extent-oracle extent-oracle r x) rtol) - stats)))) +(pre-let* (WINDOW-LENGTH 1000) + (define (integral integrand extent-oracle true-integral r dimension rtol stats) + (void (const integrand-t*) (const extent-oracle-t*) double (const gsl-rng*) (unsigned int) double gsl-rstat-workspace*) + (define accurate-estimates int 0) + (with-vector x dimension + (do-while (< accurate-estimates WINDOW-LENGTH) + (random-direction-vector r x) + (gsl-rstat-add (integral-per-direction integrand x dimension + (invoke-extent-oracle extent-oracle r x) rtol) + stats) + (cond + ((rtol? (gsl-rstat-mean stats) true-integral rtol) + (set+ accurate-estimates 1)) + (else + (set accurate-estimates 0))))))) (define (volume-cone extent-oracle r mean omega-min omega-max number-of-samples variance) (double (const extent-oracle-t*) (const gsl-rng*) (const gsl-vector*) double double (unsigned int) double*) |