The Normal Distribution and the 68, 95, 99.7 rule, also known as the Empirical Rule. How many turtles will be within a distance of 5 units or 5 patches from the y axis (where xcor = 0)?

random-normal mean standard-deviation

random-normal reports a normally distributed random floating point number.

show random-normal 10.1 5.2  
;;    prints a normally distributed random floating point  
;;    number with a mean of 10.1 and a standard deviation  
;;                                                 of 5.2 


 

powered by NetLogo

view/download model file: NormalDistributionsUpTo5Breeds.nlogo

WHAT IS IT?

This model was developed to illustrate the concept of a normal distribution.


HOW IT WORKS

A random number with a mean of 0 and standard deviation of 5 is generated using a normal distribution (contrast that to a uniform probability distribution by turning the loveTheMiddle switch to OFF).

The random number that is generated is used to locate the turtle's x coordinate in the 2D plane or turtle world grid. The turtles breed and shape it takes will depend upon whether its z-score (number of standard deviations from the mean) is less than 1, or less than 2, or less than 3, or less than 4, or very, very, very rarely greater than or equal to 4.

More on z-scores from YouTube Iowa State Stat Rap video:


Transcription of most of the STAT RAP lyrics.

HOW TO USE IT

Try it out with 1000 turtles, but be sure to try it with 10,000 turtles quite a few times too. It is very hard to get 1 or 2 flowers, but it does happen.


THINGS TO NOTICE

Calculate the numbers to see if you get around 68, 95, and 99.7 percent. This screen snapshot used n = 10000 turtles and we actually got 1 flower.


THINGS TO TRY

Download the model. Change the standard deviation from 5 to 4 or from 5 to 2.5 in the procedures code. Run the model again and notice the change. Change the standard deviation to 3 and change the mean to 5 and see what the output looks like.


RELATED MODELS

countries15model.html where x follows a normal distribution and y follows a normal distribution, but y depends upon or can be predicted or is related to x. IVs and DVs. Linear regression and normal distributions.


CREDITS AND REFERENCES

The inspiring students of CS 1025 01 and 02 from the Fall of 2011.


PROCEDURES

BREED [leaves leave]
BREED [airplanes airplane]
BREED [bugs bug]
BREED [cows cow]
BREED [flags flag]
BREED [flowers flower]


airplanes-own [whereX]

GLOBALS [theX theY]


TO showRandomNormal

    ca
    
    set-default-shape leaves "leaf"
    set-default-shape airplanes "airplane"
    set-default-shape bugs "bug"
    set-default-shape cows "cow"
    set-default-shape flowers "flower"
        
    if withLines [ drawLines ]
    
    repeat howManyTurtles
    [
        ifelse( loveTheMiddle )
        [  
          SET theX random-normal 0 5
        ]
        [
          SET theX random-float 50.0 - 25
        ]
        
        SET theY random 32 - 15
        
        ifelse (abs theX < 5) 
        [ 
           create-leaves 1   [ setxy theX theY set color white]
        ] 
        [ 
           ifelse (abs theX < 10)
           [
               create-bugs 1 [ setxy theX theY set color yellow]
           ]
           [
               ifelse (abs theX < 15)
               [
               create-airplanes 1  [ setxy theX theY
                                     set color sky ]
               ]
               [
                 ifelse (abs theX < 20)
                 [
                    create-cows 1 [ setxy theX theY
                                    set color green ]
                 ]
                 [ 
                    create-flowers 1 [ setxy theX theY set color blue set size 1 ]                 
                 ]
                                   
               ]              
           ]
        ]
        wait 0.001
    ]          
END

TO drawLines
   create-flags 1
   [ 
     setxy -10 -16.5
     set color yellow
     set heading 0
     pd
     fd 33
     pu
     setxy 10 -16.5
     set heading 0
     pd
     fd 33
     
     pu
     set color white
     setxy -5 -16.5
     set heading 0
     pd
     fd 33
     
     pu
     setxy 5 -16.5
     set heading 0
     pd
     fd 33
     
     pu
     set color green
     setxy -15 -16.5
     set heading 0
     pd
     fd 33
     
     pu
     setxy 15 -16.5
     set heading 0
     pd
     fd 33
     
     set color 85
     set pen-size 3
     pu
     setxy 0 -16.5
     set heading 0
     pd
     fd 33
     
     set color 95
     set pen-size 4
     pu
     setxy 20 -16.5
     set heading 0
     pd
     fd 33
     
     pu
     setxy -20 -16.5
     set heading 0
     pd
     fd 33          
     
     ht
     
     
     
   ]
   
     
   
END