jeudi 10 novembre 2016

How to randomly generate a probability to determine which procedures should be performed? (C++)

I'm a primary learner of C++ and recently I'm doing a simulation of language competition(sociophysics) in my study project.

I need to start with the population=1 who speaks language [0]. Each people will give birth and produce 1 child. The child may mutate his/her original language (originally same as parents) to another language [1] with a mutation probability P (input value). The things I need to do is: after Nth generation, how many people speak [0] and how many people speak [1].

So, how to randomly generate a mutation probability p in the range of 0 ~ 1 (or 0~100%)? Furthermore,if a random generated mutation probability is p=0.88, what does this probability means compare with the theoretical mutation probability (e.g.input value p=0.21)? Does the child mutate or not?




Aucun commentaire:

Enregistrer un commentaire