summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuillaume Horel <guillaume.horel@gmail.com>2018-10-15 16:24:00 -0400
committerGuillaume Horel <guillaume.horel@gmail.com>2018-10-15 16:24:00 -0400
commitc8ed97f5982178ce587fbed4b8a2e118f0f9892a (patch)
treefcb51ddde07578aad32a2ad3511a440b58f4d3cb
parent664496f99c15f94975ab90627ded8b7648c663ee (diff)
downloadlossdistrib-c8ed97f5982178ce587fbed4b8a2e118f0f9892a.tar.gz
handle rho=1. properly
-rw-r--r--src/lossdistrib.c8
1 files changed, 7 insertions, 1 deletions
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)) );
}