Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

Oky maybe I found the answer...

I wrote a little simulation, the simulation is written in C++.

I read a publication and they told me that I have a number of ERC in a cell, and every generation 95% are retained in the old cell.

now the first program I wrote:

tot_ERC *= 0.95; //(1)

*Edit: I corrected the program, I forgot to convert a float, so now the graph look like this(which althogh is anyway different than using (2)): First method

then I have heard that every ERC has an independent probabilty of 95% to be retained:
so I changed the program like this:

int tot_ERC = cell.get_erc_count();
for (int erc = 0; erc < tot_ERC; ++erc){
     if (get_random_number_between_0_1() > 0.95 && cell.erc_count > 0){
          cell.erc_count -=1;//(2)

second method

In the indipendent probability method, actually the real probability is different from the input. It can be seen in the second image were the real p6 (blue line, fig 2.) is way above the 0.6 that I gave as a input... I don't know the name of this behaviour but I hope is clear...

share|improve this question
(1) is calculating the average population while (2) is simulating a concrete sample of how your population behaves. –  Listing Nov 26 '11 at 15:53
yes I see... that's why I changed the program... –  Pella86 Nov 26 '11 at 15:55
Still not a coherent question. Voting to close. –  Ross Millikan Aug 6 '12 at 4:52

1 Answer 1

I assume for every cell in "tot_ERC" you want to keep it with a probability of 95%. The correct way to do this in a program would be

int temp = 0;
for (int erc = 0; erc < tot_ERC; ++erc){
     if (get_random_number_between_0_1() > 0.95) temp = temp + 1;
tot_ERC = temp;

Your approach actually has a loop where it is not clear how long it will run, also you run it 1 step too long in any case.

share|improve this answer
yes, I edited with the right version... I saw and corrected the mistake before... And now I copied a old version of the code. thx for the answer anyway –  Pella86 Nov 26 '11 at 16:08
Your loop is still running one time too much... –  Listing Nov 26 '11 at 16:18
oh oky... yes I'll correct it :D thx –  Pella86 Nov 26 '11 at 16:22
but I don't think is this the solution... –  Pella86 Nov 26 '11 at 16:48
It is not clear what you want... –  Listing Nov 26 '11 at 16:54

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.