Skip to content

Commit 8257e2b

Browse files
committed
Moving calc-confidence & erf to protocol.nls.
* They seem to better fit in there. * removing initialization of current-theory-info from setup b/c it's superfluous
1 parent e0e301d commit 8257e2b

File tree

2 files changed

+79
-80
lines changed

2 files changed

+79
-80
lines changed

SocNetABM.nlogo

Lines changed: 0 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ to setup [rs]
3232
; alpha + beta): the first (second) entry is the denominator for
3333
; theory 1 (2).
3434
set b (list (a1 + b1) (a2 + b2))
35-
set current-theory-info [0 0]
3635
; calculate the prior (i.e. mean of the beta distribution) from the random
3736
; alphas / betas.
3837
calc-posterior
@@ -335,85 +334,6 @@ to set-researcher-colors
335334
set color turquoise
336335
]
337336
end
338-
339-
340-
341-
342-
343-
; Calculates how confident the researcher is in the fact that her current best
344-
; theory is actually the best theory (i.e. how unlikely it is that she will
345-
; change her mind). This calculation only makes sense in case researchers have
346-
; converged.
347-
to calc-confidence
348-
if converged-ticks = 0 [
349-
set g-depressed-confidence false
350-
]
351-
if g-depressed-confidence [stop]
352-
let stop? false
353-
ask turtles [
354-
if stop? [stop]
355-
let belief-to-beat item ((mytheory + 1) mod 2) current-theory-info
356-
* strategy-threshold
357-
let cur-theory mytheory
358-
if converged-ticks = 0 [
359-
set avg-neighbor-signal mean [item cur-theory subj-th-i-signal] of
360-
(turtle-set link-neighbors self)
361-
]
362-
; if the scientist would be given sufficient time for her belief to
363-
; converge to the average signal of her and her link-neighbors, would
364-
; this be enough for her to abandon her current theory? If so, she's not
365-
; confident enough.
366-
if avg-neighbor-signal <= belief-to-beat [
367-
set confidence 0
368-
set stop? true
369-
set g-depressed-confidence true
370-
stop
371-
]
372-
; the following calculations are based on probability maximization of the
373-
; normal-distribution. This is separately documented at [placeholder].
374-
let alpha item mytheory a
375-
let varepsilon avg-neighbor-signal - belief-to-beat
376-
let delta item mytheory current-theory-info - belief-to-beat
377-
if (2 * alpha - 1) * delta <= belief-to-beat [
378-
set confidence 0
379-
set stop? true
380-
stop
381-
]
382-
let exit-probability 0.5 + 0.5 * erf (
383-
((0 - 2 * alpha + 1) * delta + belief-to-beat)
384-
/ (sqrt((0 - 2 * alpha * delta + delta + belief-to-beat)
385-
* (belief-to-beat + varepsilon) * (0 - 1 + belief-to-beat + varepsilon)
386-
/ (varepsilon * (belief-to-beat + delta)))
387-
* (belief-to-beat + delta)))
388-
ifelse exit-probability > 0 [
389-
set confidence 1 - exit-probability
390-
][
391-
set confidence 1
392-
]
393-
]
394-
ifelse stop? [
395-
set g-confidence 0
396-
][
397-
set g-confidence reduce * [confidence] of turtles
398-
]
399-
end
400-
401-
402-
403-
404-
405-
; reports a numerical approximation for the error-function function on its
406-
; negative domain, therefore the argument (x) must be smaller than 0. For
407-
; sources see infotab.
408-
to-report erf [x]
409-
let t (1 - .5 * x)
410-
report exp ( 0 - x ^ 2 - 1.26551223 + 1.00002368 / t
411-
+ .37409196 / t ^ 2 + 0.09678418 / t ^ 3
412-
- .18628806 / t ^ 4 + .27886807 / t ^ 5
413-
- 1.13520398 / t ^ 6 + 1.48851587 / t ^ 7
414-
- .82215223 / t ^ 8 + .17087277 / t ^ 9)
415-
/ t - 1
416-
end
417337
@#$#@#$#@
418338
GRAPHICS-WINDOW
419339
210

protocol.nls

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,85 @@ end
6262

6363

6464

65+
; Calculates how confident the researcher is in the fact that her current best
66+
; theory is actually the best theory (i.e. how unlikely it is that she will
67+
; change her mind). This calculation only makes sense in case researchers have
68+
; converged.
69+
to calc-confidence
70+
if converged-ticks = 0 [
71+
set g-depressed-confidence false
72+
]
73+
if g-depressed-confidence [stop]
74+
let stop? false
75+
ask turtles [
76+
if stop? [stop]
77+
let belief-to-beat item ((mytheory + 1) mod 2) current-theory-info
78+
* strategy-threshold
79+
let cur-theory mytheory
80+
if converged-ticks = 0 [
81+
set avg-neighbor-signal mean [item cur-theory subj-th-i-signal] of
82+
(turtle-set link-neighbors self)
83+
]
84+
; if the scientist would be given sufficient time for her belief to
85+
; converge to the average signal of her and her link-neighbors, would
86+
; this be enough for her to abandon her current theory? If so, she's not
87+
; confident enough.
88+
if avg-neighbor-signal <= belief-to-beat [
89+
set confidence 0
90+
set stop? true
91+
set g-depressed-confidence true
92+
stop
93+
]
94+
; the following calculations are based on probability maximization of the
95+
; normal-distribution. This is separately documented at [placeholder].
96+
let alpha item mytheory a
97+
let varepsilon avg-neighbor-signal - belief-to-beat
98+
let delta item mytheory current-theory-info - belief-to-beat
99+
if (2 * alpha - 1) * delta <= belief-to-beat [
100+
set confidence 0
101+
set stop? true
102+
stop
103+
]
104+
let exit-probability 0.5 + 0.5 * erf (
105+
((0 - 2 * alpha + 1) * delta + belief-to-beat)
106+
/ (sqrt((0 - 2 * alpha * delta + delta + belief-to-beat)
107+
* (belief-to-beat + varepsilon) * (0 - 1 + belief-to-beat + varepsilon)
108+
/ (varepsilon * (belief-to-beat + delta)))
109+
* (belief-to-beat + delta)))
110+
ifelse exit-probability > 0 [
111+
set confidence 1 - exit-probability
112+
][
113+
set confidence 1
114+
]
115+
]
116+
ifelse stop? [
117+
set g-confidence 0
118+
][
119+
set g-confidence reduce * [confidence] of turtles
120+
]
121+
end
122+
123+
124+
125+
126+
127+
; reports a numerical approximation for the error-function function on its
128+
; negative domain, therefore the argument (x) must be smaller than 0. For
129+
; sources see infotab.
130+
to-report erf [x]
131+
let t (1 - .5 * x)
132+
report exp ( 0 - x ^ 2 - 1.26551223 + 1.00002368 / t
133+
+ .37409196 / t ^ 2 + 0.09678418 / t ^ 3
134+
- .18628806 / t ^ 4 + .27886807 / t ^ 5
135+
- 1.13520398 / t ^ 6 + 1.48851587 / t ^ 7
136+
- .82215223 / t ^ 8 + .17087277 / t ^ 9)
137+
/ t - 1
138+
end
139+
140+
141+
142+
143+
65144
; reports 1 if scientists converged on the best theory (th1) by the end of the
66145
; run, 0 otherwise
67146
to-report successful-run

0 commit comments

Comments
 (0)