From dde9a86344000b9a5e4e23ee0c52be1917594b3b Mon Sep 17 00:00:00 2001 From: amritagos Date: Fri, 13 Oct 2023 20:53:12 +0000 Subject: [PATCH] model: Drawing activities from a power law model --- src/models/ActivityDrivenModel.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/models/ActivityDrivenModel.cpp b/src/models/ActivityDrivenModel.cpp index c79fcfd..1f12e37 100644 --- a/src/models/ActivityDrivenModel.cpp +++ b/src/models/ActivityDrivenModel.cpp @@ -8,9 +8,10 @@ Seldon::ActivityAgentModel::ActivityAgentModel( int n_agents, Network & network, agents_current_copy( std::vector( n_agents ) ), gen( gen ) { - // TODO: take this from simulation std::uniform_real_distribution<> dis( -1, 1 ); // Opinion initial values std::uniform_real_distribution<> dist_activity( 0, 1 ); // Uniform random variable for activities + gamma = 2.1; + eps = 0.01; // Initial conditions for the opinions, initialize to [-1,1] // The activities should be drawn from a power law distribution @@ -18,6 +19,7 @@ Seldon::ActivityAgentModel::ActivityAgentModel( int n_agents, Network & network, { agents[i].data.opinion = dis( gen ); // Draw the opinion value // Draw from a power law distribution (1-gamma)/(1-eps^(1-gamma)) * a^(-gamma) + agents[i].data.activity = std::pow( (1-std::pow(eps,(1-gamma)) ) * dist_activity( gen ) + std::pow(eps,(1-gamma)) , (1/(1-gamma)) ); } }