M. Drew LaMar
October 17, 2016
“The productive modeler simply assumes that software mistakes are inevitable and continually searches for them.”
- Railsback & Grimm
resize-world
in setup
!ifelse (xcor >= min-marriage-age)
[ show "If" ]
[ show "Else" ]
ifelse (xcor >= min-marriage-age) and
(random-float 1.0 < 0.1)
[ show "If" ]
[ show "Else" ]
ifelse (xcor >= min-marriage-age) and
(random-float 1.0 < 0.1)
[ set married? true ]
[ show "Else" ]
scale-color
to color turtles or patches based on their variables.label
and plabel
to check turtle or patch information.step
button.to dostuff
show "Starting procedure X"
; Do stuff
show "Ending procedure X"
end
observer> show word "num turtles = " count turtles
observer: "num turtles = 0"
Use parameters and initial data at the extreme values, and possibly outside normal ranges (e.g. \( q = 1.0 \))
and
Edit: This slide has been modified from lecture to correct an error.
Question: Is the probability butterflies move to the highest neighbor patch really \( q \)?
Answer: No. It is the approximate proportion \[ q + \frac{1-q}{8}. \]
For \( q = 0.4 \), we would expect the butterfly to move to the highest neighbor patch with probability 0.475.
file-type
file-print
file-open
file-close
mydata <- read.csv("TestOutput.csv", header=FALSE)
str(mydata)
'data.frame': 1000 obs. of 9 variables:
$ V1: num 15.8 14.9 17.1 17.8 16.4 ...
$ V2: num 15.6 15.6 15.6 17 16.3 ...
$ V3: num 16.3 15.5 16.9 18.5 17.1 ...
$ V4: num 14.7 17 18.4 19.2 18.4 ...
$ V5: num 15.6 15.7 16.4 19.1 16.9 ...
$ V6: num 14.8 16.3 17.7 19.8 17.7 ...
$ V7: num 15.5 16.4 16.3 17.7 15.6 ...
$ V8: num 15.5 15.5 17.8 18.3 17.8 ...
$ V9: num 15.6 17 18.4 17 15.6 ...
Note: There were errors here during lecture. The code below has been changed to correct the error. I will discuss in class on Wednesday.
moved.to.highest <- sapply(1:1000, function (x) {max(mydata[x,1:8]) == mydata[x,9]})
moved.to.highest <- as.integer(moved.to.highest)
prop.test(sum(moved.to.highest), 1000)
1-sample proportions test with continuity correction
data: sum(moved.to.highest) out of 1000, null probability 0.5
X-squared = 23.409, df = 1, p-value = 1.31e-06
alternative hypothesis: true p is not equal to 0.5
95 percent confidence interval:
0.3922385 0.4543604
sample estimates:
p
0.423