Skip to content

Commit

Permalink
rand: testing input configurations, gamma
Browse files Browse the repository at this point in the history
  • Loading branch information
jgaeddert committed Dec 3, 2023
1 parent d873f8c commit 3a23578
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/random/tests/random_autotest.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
*/

#include "autotest/autotest.h"
#include "liquid.h"
#include "liquid.internal.h"

#define LIQUID_RANDOM_AUTOTEST_NUM_TRIALS (100000)
#define LIQUID_RANDOM_AUTOTEST_ERROR_TOL (0.1)
Expand Down Expand Up @@ -187,5 +187,19 @@ void autotest_random_config()
// exponential: pdf, cdf with valid input, but negative variable
CONTEND_EQUALITY( randexpf_pdf(-2.0f, 2.3f), 0.0f );
CONTEND_EQUALITY( randexpf_cdf(-2.0f, 2.3f), 0.0f );

// gamma: parameters out of range (alpha)
CONTEND_EQUALITY( randgammaf ( -1.0f, 1.0f), 0.0f );
CONTEND_EQUALITY( randgammaf_pdf( 0.0f, -1.0f, 1.0f), 0.0f );
CONTEND_EQUALITY( randgammaf_cdf( 0.0f, -1.0f, 1.0f), 0.0f );
// gamma: parameters out of range (beta)
CONTEND_EQUALITY( randgammaf ( 1.0f, -1.0f), 0.0f );
CONTEND_EQUALITY( randgammaf_pdf( 0.0f, 1.0f, -1.0f), 0.0f );
CONTEND_EQUALITY( randgammaf_cdf( 0.0f, 1.0f, -1.0f), 0.0f );
// gamma: delta function parameter out of range
CONTEND_EQUALITY( randgammaf_delta(-1.0f), 0.0f );
// gamma: pdf, cdf with valid input, but negative variable
CONTEND_EQUALITY( randgammaf_pdf(-2.0f, 1.2f, 2.3f), 0.0f );
CONTEND_EQUALITY( randgammaf_cdf(-2.0f, 1.2f, 2.3f), 0.0f );
}

0 comments on commit 3a23578

Please sign in to comment.