Simulation of Twins

Simulation of Twins preview image

1 collaborator

Default-person Daniel Griffin (Author)

Tags

(This model has yet to be categorized with any tags)
Visible to everyone | Changeable by everyone
Model was written in NetLogo 6.0.4 • Viewed 69 times • Downloaded 6 times • Run 0 times
Download the 'Simulation of Twins' modelDownload this modelEmbed this model

Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)


WHAT IS IT?

Here is a simulation of the birth rates amongt twins. There are multiple populations where agents can move around freely. There are chances of twins being born and even larger chance that a twin wont be born. Here the model can input the twin birth rates from actual live statistics or statistics made by the user.

HOW TO USE IT

-To use the model you must first select your creation type in the drop down menu.

-Choose the variable statistics you want your agents to reproduce, die or to be created.

-Click SETUP, this allows for the clearing of all outputs and information on screen.

-You must now choose how your agents want to reproduce click from the birthing drop down.

-Before you click GO you have the ability to let the agents die during their simulation.

-Click GO to let the agents simulate.

Options which can be change

SLIDER TO CHANCE THE POPULATION OF AGENTS

SLIDER TO CHANGE HOW MANY SINGLETONS AND TWINS ARE POPULATED

SLIDER TO CHANGE THE CHANCE OF HAVING A TWIN

SLIDER TO CHANGE THE CHANCE OF AGENT DEATH

SLIDER TO CHANGE THE MAXIMUM AGE OF AGENT

DROPDOWN FOR WAYS TO GENERATE AGENTS

DROPDOWN FOR WAYS TO REPRODUCE AGENTS

WHAT TO LOOK OUT FOR

We can model the birth rates for both twin and non twin where we can almost guess generations. However though this model is a chance not a true figure, we can guess what rate twins can be born. Look out for the output graph to see if the rate of twins fluctuates or steady's. Everytime the application simulates the statisitcs will always differ. Look at the slider options to simulate various results.

CREATOR

NAME: Daniel Joseph Griffin STUDENT ID: eeu69a EMAIL :eeu69a@bangor.ac.uk

-- please note that some of the work was from the help of --

Wilensky, U. (1997). NetLogo Simple Birth Rates model. http://ccl.northwestern.edu/netlogo/models/SimpleBirthRates. Center for Connected Learning and Computer-Based Modeling, Northwestern University, Evanston, IL.

Comments and Questions

Please start the discussion about this model! (You'll first need to log in.)

Click to Run Model

globals
[
  girl-nontwin      ; population of PINK turtles i.e girl NON TWIN
  boy-nontwin       ; population of BLUE turtles i.e boy NON TWIN

  boy-twin          ; population of MAGENTA turtles i.e boy TWIN
  girl-twin         ; population of YELLOW turtles i.e girl NON TWIN
  dead-count

  boy-nontwin-turt        ; percentage of turtles for this agent
  girl-nontwin-turt       ; percentage of turtles for this agent
  boy-twin-turt           ; percentage of turtles for this agent
  girl-twin-turt          ; percentage of turtles for this agent

  percentage-of-twin      ; slider percentage of twins chance
  birth-tick
]

turtles-own
[
  fertility            ; the whole number part of fertility
  fertility-remainder  ; the fractional part (after the decimal point)
  singleton?           ; TRUE/FALSE if singleton or not
  age                  ; agent age default 0
]

to setup
  set toggle-death? true  ; turn option for death ON as default
  clear-output            ; clear output function
  setup-experiment        ; run the to method called 'setup-experiment'
end 

to setup-experiment
  clear-globals
  clear-patches
  clear-turtles
  clear-all-plots
  clear-ticks

  if CHOOSE-CREATION = "CREATE TURTLES BY PERCENTAGE" [create]            ; option to create turtles by a percentage
  if CHOOSE-CREATION = "CREATE TURTLES BY COMPUTER GENERATION" [create2]  ; option to create turtles by generation
  if CHOOSE-CREATION = "CREATE TURTLES BY EQUAL AMOUNT" [create3]         ; option to create turtles by equal amount
  set percentage-of-twin  precision (100 - percentage-of-singleton) 4     ; set percentage of twin from singleton difference

  reset-ticks
end 

to create
  create-turtles population
  [
    setxy random-xcor random-ycor                           ; randomize turtle locations
    set singleton? false                                    ; singleton set as default false
    set color pink                                          ; set default color to pink
    set size 3                                              ; default size 3
    set shape "person"                                      ; default shape as person
  ]

    let %singleton percentage-of-singleton                  ; percentage of singletons
    let %twin 100 - percentage-of-singleton                 ; percentage of twins = singletons - 100
    let n count turtles                                     ; number of turtles on output

    let singleTurtles round(((%singleton / 100) * n))       ; find the whole number of singletons as %
    let multiTurtles n - singleTurtles                      ; make the twins the other %

    ask n-of singleTurtles turtles [                        ; asking the percentage of singeltons turtles
      set singleton? true                                   ; setting the singletons to true
  ]

    let halfN round(n / 2)                                  ; setting a variable to half of the current population
    ask n-of halfN turtles [                                ; asking for half of the turtles
      ifelse singleton?                                     ; if singleton then set their colors
      [
        set color blue                                      ; setting the color blue if singleton
      ]
      [
        set color magenta                                   ; else set to magenta
      ]
    ]

    ask turtles with [ color = pink ]                       ; asking turtles who are pink
    [
      if not singleton?                                     ; if pink is not singleton
      [
        set color yellow                                    ; set them to yellow
      ]
    ]
end 

to create2


  create-turtles population              ; CITING Uri Wilisky, Simple Birth Rates Netlogo 1997.
  [
    setxy random-xcor random-ycor        ; randomize turtle locations
    let r random 100                     ; make r be random number 0 - 99
    set color red                        ; set default color red
    ifelse (r < boy-nontwin-percentage)  ; if r is less than the percentage slider
      [
        set color blue                   ; make them blue
        set singleton? true              ; set singelton to true
    ]
    [
      ifelse (r >= boy-nontwin-percentage) and (r < girl-nontwin-percentage)       ; if r more than last slider and < nextslider
      [
        set color pink                                                             ; set color to pink
        set singleton? true                                                        ; set singleton to true
      ]
    [
        ifelse (r >= girl-nontwin-percentage) and (r < boy-twin-percentage)        ; if r more than last slider and < nextslider
        [
          set color magenta                                                        ; set color to magenta
          set singleton? false                                                     ; set singelton to false
        ]
        [
          if (r >= boy-twin-percentage) and (r < girl-twin-percentage)             ; if r more than last slider and < nextslider
          [
            set color yellow                                                       ; set color to yellow
            set singleton? false                                                   ; set singelton to false
          ]
        ]
      ]
    ]
    set size 3                            ; set size 3
    set shape "person"                    ; set shape to person
  ]
end 

to create3
  create-turtles population
  [
    setxy random-xcor random-ycor                      ; randomize turtle locations

    let n count turtles                                ; set n to be number of turtles i.e. population
    let r random 4                                     ; make r to be random number between 0 and 3

    if r = 0 [set color blue set singleton? true]      ; if r is 0 then make turtle blue and set singleton to true
    if r = 1 [set color pink set singleton? true]      ; if r is 1 then make turtle pink and set singleton to true
    if r = 2 [set color magenta set singleton? false]  ; if r is 2 then make turtle magenta and set singleton to false
    if r = 3 [set color yellow set singleton? false]   ; if r is 2 then make turtle yellow and set singleton to false
    set size 3                                         ; set the size of agent to 3
    set shape "person"                                 ; set the shape of agent to person
  ]
end 

to go


  ifelse CHOOSE-BIRTHING = "GIVE BIRTH BY ACTUAL MEANS" [reproduce1] [reproduce2]   ; if dropdown equals "" then do command 1 else 2
  tick                                                                              ; make the ticks go increment

  if ticks >= 90 [stop]                                                            ; if ticks more than or equal to 300 stop simulation
  if toggle-death? [death death-age]                                                ; if switch on do to death methods
  set percentage-of-twin 100 - percentage-of-singleton                              ; set the monitor to be exact twin amount for slider
  ask turtles [wander set age 1 + age]
end 

to wander
  rt random-float 30 - random-float 30  ; make agent right turn by random float - random float
  fd 1                                  ; make agent go forward by 3
end 

to reproduce1                                     ; CITING Uri Wilisky, Simple Birth Rates Netlogo 1997.

let chosen-col [blue pink]                        ; make list to be two color, no twin colors
let chosen-col-twin [magenta yellow]              ; make list to be two color, twin colors

let rg (range 18 80 1)                            ; make a range between 18 and 80, increament by 1

  if ticks > one-of rg  [                         ; if ticks more than one of the numbers in range

ask turtles with [color = pink]                   ; all turtles with the color pink
  [
    set fertility floor girl-nontwin-fertility    ; from the fertility slider get the whole number
    set fertility-remainder girl-nontwin-fertility - (floor girl-nontwin-fertility)                         ; make a variable to be the remainder of the slider

    if any? turtles with [color = blue or color = magenta] in-radius 0.7                                    ; if any turtles who are blue or magenta in radius of 0.7
    [
      ifelse (random-float 100) < (100 * fertility-remainder)                                               ; ifelse for the fertility remainder to decide how to hatch
        [hatch fertility + 1 [ wander ifelse random 100 < chance-of-twin[set color one-of chosen-col-twin set age 0][set color one-of chosen-col set age 0]]]
      [ hatch fertility      [ wander ifelse random 100 < chance-of-twin[set color one-of chosen-col-twin set age 0][set color one-of chosen-col set age 0]]]
      ifelse any? turtles-here with [color = blue or color = pink] [set singleton? true][set singleton? false]     ; if any turtles at this point with color set their singleton attribute
      ]
    ]

  ask turtles with [color = yellow]
  [
    set fertility floor girl-nontwin-fertility ;floor shows nearest whole number
    set fertility-remainder girl-nontwin-fertility - (floor girl-nontwin-fertility)

    if any? turtles with [color = blue or color = magenta] in-radius 0.7
    [
      ifelse (random-float 100) < (100 * fertility-remainder)
        [hatch fertility + 1  [ wander ifelse random 100 < chance-of-twin[set color one-of chosen-col-twin set age 0][set color one-of chosen-col set age 0]]]
      [ hatch fertility     [ wander ifelse random 100 < chance-of-twin[set color one-of chosen-col-twin set age 0][set color one-of chosen-col set age 0]]]
      ifelse any? turtles-here with [color = blue or color = pink] [set singleton? true][set singleton? false]
      ]
    ]
  ]
end 

to reproduce2                                     ; CITING Uri Wilisky, Simple Birth Rates Netlogo 1997.

   ask turtles
  [
    ifelse color = pink or color = yellow
    [
      set fertility floor girl-twin-fertility ;floor shows nearest whole number
      set fertility-remainder girl-twin-fertility - (floor girl-twin-fertility)
    ]
    [
      set fertility floor girl-nontwin-fertility
      set fertility-remainder girl-nontwin-fertility - (floor girl-nontwin-fertility)
    ]
    ifelse (random-float 100) < (100 * fertility-remainder)
      [ hatch fertility + 1 [ wander ]]
    [ hatch fertility     [ wander ]]
  ]
end 

to death
  let number-of-turtles count turtles             ; make a variable to be number of turtles
  if number-of-turtles <= population [ stop ]     ; if the number of turtles excedes population stop the simulation

  ask turtles                                     ; ask all turtles
  [
    if random-float 100 < chance-to-die [ die ]   ; if random number less than chance to die then kill agents
    set dead-count dead-count + 1                 ; set the deadcount to increament
  ]
end 

to death-age
  ask turtles [                    ; ask all turtles
  if age > age-of-death [ die ]]   ; if age is more than slider age then kill turtles
end 

to increment-age
  let age-in-ticks birth-tick - ticks
  if (age-in-ticks > 0) and (age-in-ticks mod 5 = 0) [
    set age (1 + age)
  ]
end 

There is only one version of this model, created almost 5 years ago by Daniel Griffin.

Attached files

File Type Description Last updated
Simulation of Twins.png preview Preview for 'Simulation of Twins' almost 5 years ago, by Daniel Griffin Download

This model does not have any ancestors.

This model does not have any descendants.