From c8ed97f5982178ce587fbed4b8a2e118f0f9892a Mon Sep 17 00:00:00 2001 From: Guillaume Horel Date: Mon, 15 Oct 2018 16:24:00 -0400 Subject: handle rho=1. properly --- src/lossdistrib.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/lossdistrib.c b/src/lossdistrib.c index e472a44..6e43a36 100644 --- a/src/lossdistrib.c +++ b/src/lossdistrib.c @@ -394,7 +394,11 @@ void recovdist(const double *dp, const double *pp, const int *n, const double *w double shockprob(double p, double rho, double Z, int give_log){ if(rho == 1.) { - return((double)(Z<=qnorm(p, 0, 1, 1, 0))); + if( give_log ) { + abort(); + } else { + return (double)(Z <= qnorm(p, 0, 1, 1, 0)); + } } else if (rho == 0.) { return p; } else { @@ -425,6 +429,8 @@ double shockseverity(double S, double Z, double rho, double p){ return 0; } else if (rho == 0.) { return S; + } else if (rho == 1.) { + return Z <= qnorm(S * p, 0, 1, 1, 0) ? 1. : 0.; } else { return( exp(shockprob(S * p, rho, Z, 1) - shockprob(p, rho, Z, 1)) ); } -- cgit v1.2.3-70-g09d2