Skip to content

Commit

Permalink
model: Drawing activities from a power law model
Browse files Browse the repository at this point in the history
  • Loading branch information
amritagos committed Oct 13, 2023
1 parent cc0adc9 commit dde9a86
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/models/ActivityDrivenModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,18 @@ Seldon::ActivityAgentModel::ActivityAgentModel( int n_agents, Network & network,
agents_current_copy( std::vector<AgentT>( 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
for( size_t i = 0; i < agents.size(); i++ )
{
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)) );
}
}

Expand Down

0 comments on commit dde9a86

Please sign in to comment.