@@ -253,50 +253,50 @@ class TimedHumanDeployment : public TimedDeployment, protected HumanDeploymentBa
253
253
254
254
if (copula)
255
255
{
256
- if (Transmission::PerHostAnophParams::numSpecies () > 1 )
257
- throw std::runtime_error (" Gaussian copula: (deployment with availability correlation) only supports one mosquito species" );
258
-
259
- // Use avail that is already weighted?? or Need raw value?
260
- double scaling_factor = (Transmission::PerHostAnophParams::get (0 ).entoAvailabilityFactor * human.perHostTransmission .relativeAvailabilityHet );
261
- double ux = Transmission::PerHostAnophParams::get (0 ).entoAvailability ->cdf (availability / scaling_factor);
262
- double xx = gsl_cdf_ugaussian_Pinv (ux); // Unit interval to Normal
263
-
264
- // Apply the Gaussian copula transformation for correlation
265
- ComponentId cid = subPop;
266
-
267
- /* * human.rng.gauss(0.0, 1.0) is calculated once per component and per human. Re-deployment of
268
- * the same component on the same human must use the same gaussian sample. Therefore we store
269
- * this value in the human the first time it is calculated. */
270
- double g = 0.0 ;
271
- auto it = human.perHostTransmission .copulaGaussianSamples .find (cid);
272
- if (it != human.perHostTransmission .copulaGaussianSamples .end ())
273
- g = it->second ;
274
- else
275
- {
276
- g = human.rng .gauss (0.0 , 1.0 );
277
- human.perHostTransmission .copulaGaussianSamples [cid] = g;
278
- }
279
-
280
- double yy = coverageCorr * xx + g * sqrt (1 - coverageCorr * coverageCorr);
281
-
282
- // Transform back to unit interval
283
- double uy = gsl_cdf_ugaussian_P (yy);
284
-
285
256
// Beta distribution for intervention (Beta distributed)
286
257
double beta_mean = coverage; // Assuming this value is given
287
258
double beta_var = coverageVar; // Given as well
288
259
double alpha = ((1.0 - beta_mean) / beta_var - 1.0 / beta_mean) * (beta_mean * beta_mean);
289
260
double beta = alpha * (1.0 / beta_mean - 1.0 );
290
261
291
- if (alpha < 0 || beta < 0 )
292
- throw std::runtime_error (" Gaussian copula: resulting alpha and beta parameters must be positive " );
262
+ if ( Transmission::PerHostAnophParams::numSpecies () > 1 )
263
+ throw std::runtime_error (" Gaussian copula: (deployment with availability correlation) only supports one mosquito species " );
293
264
294
-
265
+ double ux = Transmission::PerHostAnophParams::get (0 ).entoAvailability ->cdf (human.perHostTransmission .anophEntoAvailabilityRaw [0 ]);
266
+ if (ux < 1 )
267
+ {
268
+ double xx = gsl_cdf_ugaussian_Pinv (ux); // Unit interval to Normal
269
+
270
+ // Apply the Gaussian copula transformation for correlation
271
+ ComponentId cid = subPop;
272
+
273
+ /* * human.rng.gauss(0.0, 1.0) is calculated once per component and per human. Re-deployment of
274
+ * the same component on the same human must use the same gaussian sample. Therefore we store
275
+ * this value in the human the first time it is calculated. */
276
+ double g = 0.0 ;
277
+ auto it = human.perHostTransmission .copulaGaussianSamples .find (cid);
278
+ if (it != human.perHostTransmission .copulaGaussianSamples .end ())
279
+ g = it->second ;
280
+ else
281
+ {
282
+ g = human.rng .gauss (0.0 , 1.0 );
283
+ human.perHostTransmission .copulaGaussianSamples [cid] = g;
284
+ }
285
+ double yy = coverageCorr * xx + g * sqrt (1 - coverageCorr * coverageCorr);
295
286
296
- // Get the final probability from Beta distribution
297
- probability = gsl_cdf_beta_Pinv (uy, alpha, beta);
287
+ // Transform back to unit interval
288
+ double uy = gsl_cdf_ugaussian_P (yy);
289
+
290
+ if (alpha < 0 || beta < 0 )
291
+ throw std::runtime_error (" Gaussian copula: resulting alpha and beta parameters must be positive" );
292
+
293
+ // Get the final probability from Beta distribution
294
+ probability = gsl_cdf_beta_Pinv (uy, alpha, beta);
295
+ }
296
+ else // Gamma with CV=0
297
+ probability = human.rng .beta (alpha, beta);
298
298
299
- // cout << availability << " " << ux << " " << xx << " " << yy << " " << uy << " " << coverageCorr << " " << g << endl; ;
299
+ // cout << availability << " " << probability << " " << alpha << " " << beta << endl;
300
300
301
301
file << availability << " " << probability << endl;
302
302
}
0 commit comments