Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create initial distribution range for opinion models #249

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

tommybru
Copy link

@tommybru tommybru commented Aug 17, 2023

For opinion models, this PR seeks to adds optional params to set the range of initial distribution, allowing greater control of model and initial network.

💻 Changing functionality: Allow setting initial distribution range for opinion models

Issue or RFC Endorsed by NDlib's Maintainers

#250

Description of the Change

For the opinion models where nodes have a status of [0,1] or [-1,1] (including AlgorithmicBias, WHK, etc.), it is desirable to be able to set the range of the distribution of the initial status. This fine-tuned control of the starting population can be useful, for instance, in allowing developers to test how models are able to break out of that initial range or to simulate dynamics based on extreme populations.

This PR adds two optional params, init_dist_lower and init_dist_upper that are then used in the random real value sampling of the selected models.

Alternate Designs

An alternative would have been to update add_model_initial_configuration, however this method seems reserved for node statuses like Infected and Susceptible, not numerical status values. In addition, add_model_initial_configuration asks for setting a specific subset of nodes, but we want to be able to control the initial distribution range of all nodes.

The selected models already had overrides for setting the initial status using real values. This extends that override directly in-line by setting the range of where those real values are drawn from.

Possible Drawbacks

The range attribute of a parameter does not seem to be verified for any params (including existing params like epsilon, gamma. Therefore, despite setting the correct ranges of [0,1] or [-1,1], these are not enforced and can allow initial condition bounds outside of them.

Verification Process

I have created multiple different models with various values set for the init_dist_lower and init_dist_upper params. Because they are directly fed into np.random.uniform, it is easy to verify that they accurately set the range: Here, I set init_dist_lower = 0.95 init_dist_upper = 1

Screen Shot 2023-08-16 at 8 51 36 PM

Without these params set, we can verify the default behavior preserves the original intended range of the AlgorithmicBias model:

Screen Shot 2023-08-16 at 8 52 16 PM

Note: Some models have had their distributions changed to np.random.uniform, however this is just a specific sub-version of np.random.random_sample() with a defined range. In fact, np.random.uniform uses np.random.random_sample() under-the-hood. (Source)

Release Notes

  • Create initial distribution range for opinion models

For opinion models, adds optional params to set the range of initial distribution, allowing greater control of model and initial network
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant