Skip to content

Commit cbfa7e0

Browse files
committed
Introducing reporter for low numbers of pulls
* If the number of pulls is smaller than 100 an exact reporter for the binomial distribution is used instead of the normal approximation. * The range for the pull slider has been extended, which is reflected in the documentation.
1 parent 8257e2b commit cbfa7e0

File tree

2 files changed

+30
-16
lines changed

2 files changed

+30
-16
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ B/c the normal distribution is a continuous distribution the outcome is rounded
1818

1919
## Variables
2020

21-
Default-values have been set to mirror Zollman's (2010) model. The slider ranges are mostly set to mirror the ranges considered by Rosenstock et al. (2016). The exceptions are:
21+
Default-values have been set to mirror Zollman's (2010) model. The slider ranges are mostly set to mirror the ranges considered by Rosenstock et al. (2016) ( pulls correspond to `n` in Rosenstock et al.(2016)). The exceptions are:
2222

2323
* The signal ranges have a larger interval
24-
* The pulls range doesn't start at 1 but at 100 because of the normal approximation potentially not being accurate enough for low numbers of pulls. ( pulls correspond to `n` in Rosenstock et al.(2016))
24+
2525

2626
### Globals
2727

SocNetABM.nlogo

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
turtles-own [a b theory-jump times-jumped cur-best-th current-theory-info
2-
mytheory successes subj-th-i-signal crit-interact-lock confidence
2+
mytheory successes subj-th-i-signal crit-interact-lock confidence
33
avg-neighbor-signal]
44

55
globals [th-i-signal indiff-count crit-interactions-th1 crit-interactions-th2
6-
confidence-cutoff converged-ticks last-converged-th
6+
confidence-cutoff converged-ticks last-converged-th
77
max-ticks converge-reporters converge-reporters-values
88
run-start-scientists-save rndseed g-confidence g-depressed-confidence]
99

@@ -28,11 +28,11 @@ to setup [rs]
2828
let a2 init-ab
2929
let b2 init-ab
3030
set a list a1 a2
31-
; b contains the denominator of the mean of the beta distribution (i.e.
32-
; alpha + beta): the first (second) entry is the denominator for
31+
; b contains the denominator of the mean of the beta distribution (i.e.
32+
; alpha + beta): the first (second) entry is the denominator for
3333
; theory 1 (2).
3434
set b (list (a1 + b1) (a2 + b2))
35-
; calculate the prior (i.e. mean of the beta distribution) from the random
35+
; calculate the prior (i.e. mean of the beta distribution) from the random
3636
; alphas / betas.
3737
calc-posterior
3838
compute-strategies
@@ -185,6 +185,15 @@ end
185185

186186

187187

188+
; reports a draw from the binomial distribution with n pulls and probability p
189+
to-report binomial [n p]
190+
report length filter [ ?1 -> ?1 < p ] n-values n [random-float 1]
191+
end
192+
193+
194+
195+
196+
188197
; Researchers pull from their respective slot machine:
189198
; the binomial distribution is approximated by the normal distribution with
190199
; the same mean and variance. This approximation is highly accurate for all
@@ -196,6 +205,7 @@ end
196205
to pull
197206
let mysignal item mytheory subj-th-i-signal
198207
set successes [0 0]
208+
ifelse pulls > 100 [
199209
let successes-normal round random-normal
200210
(pulls * mysignal) sqrt (pulls * mysignal * (1 - mysignal) )
201211
ifelse successes-normal > 0 and successes-normal <= pulls [
@@ -205,6 +215,10 @@ to pull
205215
set successes replace-item mytheory successes pulls
206216
]
207217
]
218+
][
219+
let successes-binomial binomial pulls mysignal
220+
set successes replace-item mytheory successes successes-binomial
221+
]
208222
end
209223

210224

@@ -222,7 +236,7 @@ end
222236

223237

224238

225-
; the sharing of information between researchers optionally including
239+
; the sharing of information between researchers optionally including
226240
; critical-interaction
227241
to share
228242
let cur-turtle self
@@ -233,7 +247,7 @@ to share
233247
ask link-neighbors [
234248
ifelse mytheory = cur-turtle-th or not critical-interaction [
235249
set successvec (map + successvec successes)
236-
set pullcounter replace-item mytheory pullcounter
250+
set pullcounter replace-item mytheory pullcounter
237251
(item mytheory pullcounter + pulls)
238252
][
239253
let other-successes successes
@@ -242,7 +256,7 @@ to share
242256
if other-success-ratio > item mytheory [current-theory-info] of
243257
cur-turtle [
244258
ask cur-turtle [
245-
evaluate-critically
259+
evaluate-critically
246260
]
247261
]
248262
ask cur-turtle [
@@ -261,7 +275,7 @@ end
261275

262276

263277
; If researchers communicate with researchers from another theory they might
264-
; interact critically
278+
; interact critically
265279
to evaluate-critically
266280
let actual-prob-suc 0
267281
ifelse mytheory = 0 [
@@ -282,7 +296,7 @@ end
282296

283297

284298

285-
; calculates from a given a (= alpha) and b (= alpha + beta) the belief of a
299+
; calculates from a given a (= alpha) and b (= alpha + beta) the belief of a
286300
; researcher i.e. the mean of the beta distribution
287301
to calc-posterior
288302
set current-theory-info (map / a b)
@@ -399,10 +413,10 @@ SLIDER
399413
288
400414
pulls
401415
pulls
402-
100
416+
1
403417
6000
404418
1000.0
405-
100
419+
1
406420
1
407421
NIL
408422
HORIZONTAL
@@ -609,10 +623,10 @@ B/c the normal distribution is a continuous distribution the outcome is rounded
609623

610624
## Variables
611625

612-
Default-values have been set to mirror Zollman's (2010) model. The slider ranges are mostly set to mirror the ranges considered by Rosenstock et al. (2016). The exceptions are:
626+
Default-values have been set to mirror Zollman's (2010) model. The slider ranges are mostly set to mirror the ranges considered by Rosenstock et al. (2016) ( pulls correspond to `n` in Rosenstock et al.(2016)). The exceptions are:
613627

614628
* The signal ranges have a larger interval
615-
* The pulls range doesn't start at 1 but at 100 because of the normal approximation potentially not being accurate enough for low numbers of pulls. ( pulls correspond to `n` in Rosenstock et al.(2016))
629+
616630

617631
### Globals
618632

0 commit comments

Comments
 (0)