Check out the LimeSurvey source code on GitHub!
Welcome, Guest
Username: Password:

TOPIC: Normal distribution with rand(1,11)

Normal distribution with rand(1,11) 2 years 6 months ago #109527

  • tischer_s
  • tischer_s's Avatar
  • Offline
  • Fresh Lemon
  • Posts: 19
  • Karma: 0
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 administrator has disabled public write access.

Normal distribution with rand(1,11) 2 years 6 months ago #109528

  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Team
  • Posts: 5414
  • Thank you received: 806
  • Karma: 239
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.
Have a look at the manual! It is a really valuable source for information. Here some helpful links:
Manual (EN) | Question Types | [url=https://manual.limesurvey.org/Workarounds[/url]

If you found this answer helpful and it saved you some time please consider a [url=https://donate.limesurvey.org[/url] to the...
The administrator has disabled public write access.

Normal distribution with rand(1,11) 2 years 6 months ago #109530

  • tischer_s
  • tischer_s's Avatar
  • Offline
  • Fresh Lemon
  • Posts: 19
  • Karma: 0
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 administrator has disabled public write access.

Normal distribution with rand(1,11) 2 years 6 months ago #109551

  • DenisChenu
  • DenisChenu's Avatar
  • Online
  • Moderator Lime
  • Posts: 9555
  • Thank you received: 1372
  • Karma: 389
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 (Need support ?).
A bug not reported is a bug not corrected. | 2.61lts version improved | Need plugins for LimeSurvey ?
The administrator has disabled public write access.

Normal distribution with rand(1,11) 2 years 5 months ago #109593

  • tischer_s
  • tischer_s's Avatar
  • Offline
  • Fresh Lemon
  • Posts: 19
  • Karma: 0
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 administrator has disabled public write access.
Time to create page: 0.274 seconds
Imprint                   Privacy policy         General Terms & Conditions         Revocation information and revocation form