From cd452a636c8cf87898e6a6d27317f298ffb24efa Mon Sep 17 00:00:00 2001 From: Moritz Sallermann Date: Sun, 24 Mar 2024 20:31:59 +0000 Subject: [PATCH] ActivityDrivenModel: Use the copula Use the copula to generate correlated activities and reluctances. Co-authored-by: Amrita Goswami --- src/models/ActivityDrivenModel.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/models/ActivityDrivenModel.cpp b/src/models/ActivityDrivenModel.cpp index 0a0ba06..00c60c9 100644 --- a/src/models/ActivityDrivenModel.cpp +++ b/src/models/ActivityDrivenModel.cpp @@ -69,6 +69,8 @@ void ActivityDrivenModel::get_agents_from_power_law() power_law_distribution<> dist_activity( eps, gamma ); truncated_normal_distribution<> dist_reluctance( reluctance_mean, reluctance_sigma, reluctance_eps ); + bivariate_gaussian_copula copula( covariance_factor, dist_activity, dist_reluctance ); + auto mean_activity = dist_activity.mean(); // Initial conditions for the opinions, initialize to [-1,1] @@ -77,18 +79,16 @@ void ActivityDrivenModel::get_agents_from_power_law() { network.agents[i].data.opinion = dis_opinion( gen ); // Draw the opinion value - if( !mean_activities ) - { // Draw from a power law distribution (1-gamma)/(1-eps^(1-gamma)) * a^(-gamma) - network.agents[i].data.activity = dist_activity( gen ); - } - else - { - network.agents[i].data.activity = mean_activity; - } + auto res = copula( gen ); + network.agents[i].data.activity = res[0]; if( use_reluctances ) { - network.agents[i].data.reluctance = dist_reluctance( gen ); + network.agents[i].data.reluctance = res[1]; + } + if( mean_activities ) + { + network.agents[i].data.activity = mean_activity; } }