Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

Normal distribution with rand(1,11)

  • tischer_s
  • tischer_s's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
9 years 9 months ago #109527 by tischer_s
Normal distribution with rand(1,11) was created by tischer_s
Hi,

I implemented the randomize function which creates random numbers from 1 to 11:

rand(1,11)

Unfortunately it seems not to follow the normal distribution.

Based on 27 starts these are the outputed numbers:

1
1
1
1
2
3
4
4
4
6
6
6
7
7
7
7
7
8
8
8
8
8
9
10
10
10
11

Unfortunately the number 5 is missing at all and 11, 2, 3 and 9 are implemented quite less...

Can someone tell me that the function really follows a normal distribution?

Best

Sebastian
The topic has been locked.
  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
9 years 9 months ago #109528 by holch
Replied by holch on topic Normal distribution with rand(1,11)
I assume that this is not the order they came in?

And maybe there is a missconception. Rand should create random numbers, not following the normal distribution. With big numbers you should get close to a normal distribution, but there will always be deviations from the normal distribution. So for each draw the chance for a certain number to come up is 1/11.

With 27 draws with 11 numbers to draw from you would expect every number 2-3 times in the sample. So this looks pretty good to me, considering that you had only 27 draws. With 1000 draws you should get much closer to the normal distribution.

n=27 is for sure not a big enough number to judge upon. In my opinion this distribution is still within the normal chance.

I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.

The topic has been locked.
  • tischer_s
  • tischer_s's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
9 years 9 months ago #109530 by tischer_s
Replied by tischer_s on topic Normal distribution with rand(1,11)
Hi holch,

thank you very much for your fast reply.

The numbers came completely unordered I only sorted them to see where numbers are missing.


My sample should be around 1000 people so if you can assure me that with growing sample the normal distribution will be reached :)

Thank you very much for helping and making it clear

Best
Sebastian
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Online
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
9 years 9 months ago #109551 by DenisChenu
Replied by DenisChenu on topic Normal distribution with rand(1,11)
LimeSurvey use php rand function : php.net/manual/function.rand.php then if you fnd a bug in this function, please report it to php dev.
In some condition use hacked phpjs function : phpjs.org/functions/rand/ , if you find a bug in js rand : you can report to us, we look if it's updated in phpjs (but phpjs rand use Math.random() javascript function: if it's broken, you can report to your browser developper(for example microsoft for internet explorer)).

Denis

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
The topic has been locked.
  • tischer_s
  • tischer_s's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
9 years 9 months ago #109593 by tischer_s
Replied by tischer_s on topic Normal distribution with rand(1,11)
Hi DenisChenu,

thank you very very much for your answer.

May you please help me how I can exchange the rand php function with the phpjs version?

Is this one better?

Thank you very much for your help :)

Best
Sebastian

P.S.: The randimizing function is very important since it randomizes my 11 treatments and only should show 1. The number of people receiving the survey is 50.000 so I need to have nearly a normal distribution.
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose