From aa8f62acf46a3b9d05ca675044edac15213b7095 Mon Sep 17 00:00:00 2001 From: Arun Isaac Date: Tue, 23 Feb 2021 16:18:55 +0530 Subject: Implement uniform-true-volume without log. Logarithmic functions trip up when their parameter is 0. * src/oracles.sc (uniform-true-volume): Implement without log. --- src/oracles.sc | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/oracles.sc b/src/oracles.sc index 173ac75..4182683 100644 --- a/src/oracles.sc +++ b/src/oracles.sc @@ -24,13 +24,12 @@ ;; TODO: Verify the accuracy of this function for non-trivial a, b. (define (uniform-true-volume dimension -params) (double (unsigned int) void*) - (let* ((params (const uniform-params*) (convert-type -params uniform-params*))) - (return (- (exp (+ (ln-volume-of-ball dimension) - (* dimension (log (: params b))) - (- (log (+ dimension 1))))) - (exp (+ (ln-volume-of-ball dimension) - (* dimension (log (: params a))) - (- (log (+ dimension 1))))))))) + (let* ((params uniform-params* (convert-type -params uniform-params*))) + (return (* (volume-of-ball dimension) + (- (/ (gsl-pow-uint (: params b) (+ dimension 1)) + (+ dimension 1)) + (/ (gsl-pow-uint (: params a) (+ dimension 1)) + (+ dimension 1))))))) (define (beta-extent-oracle r x -params) (double (const gsl-rng*) (const gsl-vector*) void*) (let* ((params (const beta-params*) (convert-type -params beta-params*))) -- cgit v1.2.3