diff options
| author | Guillaume Horel <guillaume.horel@gmail.com> | 2018-10-12 13:02:57 -0400 |
|---|---|---|
| committer | Guillaume Horel <guillaume.horel@gmail.com> | 2018-10-12 13:02:57 -0400 |
| commit | 664496f99c15f94975ab90627ded8b7648c663ee (patch) | |
| tree | e147a8de346477c1f8b6bae950ccef20e98ae868 | |
| parent | 109d75585d8000885fa3834c22451bc7c4694a3c (diff) | |
| download | lossdistrib-664496f99c15f94975ab90627ded8b7648c663ee.tar.gz | |
shortcuts
| -rw-r--r-- | src/lossdistrib.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/lossdistrib.c b/src/lossdistrib.c index 47867b9..e472a44 100644 --- a/src/lossdistrib.c +++ b/src/lossdistrib.c @@ -393,9 +393,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){ + if(rho == 1.) { return((double)(Z<=qnorm(p, 0, 1, 1, 0))); - }else{ + } else if (rho == 0.) { + return p; + } else { return( pnorm( (qnorm(p, 0, 1, 1, 0) - sqrt(rho) * Z)/sqrt(1 - rho), 0, 1, 1, give_log)); } } @@ -419,9 +421,11 @@ void shockprobvec2(const double p, const double rho, const double* Z, const int } double shockseverity(double S, double Z, double rho, double p){ - if(p==0){ + if(p == 0.) { return 0; - }else{ + } else if (rho == 0.) { + return S; + } else { return( exp(shockprob(S * p, rho, Z, 1) - shockprob(p, rho, Z, 1)) ); } } |
