Comparing explanatory power and explanatory goodness
Model was written in NetLogo 6.4.0
•
Viewed 13 times
•
Downloaded 0 times
•
Run 0 times
Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)
Comments and Questions
Please start the discussion about this model!
(You'll first need to log in.)
Click to Run Model
breed [power-seekers power-seeker] breed [goodness-seekers goodness-seeker] turtles-own [ count-h1 ; number of times h1 is better than h2 count-h2 ; number of times h2 is better than h1 prior-h1 ; prior credence in h1 prior-h2 ; prior credence in h1 prop-h1 ; credence that h1 is the best explanation prop-h2 ; credence that h2 is the best explanation strategy ; update strategy truth-alignment ; tracks whether the agent aligns with the ground truth k1 ; variable to make calculations of EG_1 and EG_2 simpler k2 ; variable to make calculations of EG_1 and EG_2 simpler EP_1 ; value of power for h1 EP_2 ; value of power for h2 EG_1 ; value of goodness for h1 EG_2 ; value of goodness for h2 preferred-hypothesis ; truth-alignment variable ] patches-own [ likelihood-h1 ; represents strength of evidence for h2 on this patch – i.e., P(e|h1) likelihood-h2 ; represents strength of evidence for h2 on this patch – i.e., P(e|h2) ] ; initialize the world to setup clear-all setup-patches setup-turtles reset-ticks end ; create evidence patches to setup-patches ask patches [ set likelihood-h1 max list 0 min list 1 (random-normal avg-likelihood-h1 0.2) ; each patch has P(e|h1) between 0.001 and the number assigned by the slider if likelihood-h1 < 0.0001 [ set likelihood-h1 0.001 ] ; ensures NetLogo doesn't go crazy with logarithms of small numbers set likelihood-h2 max list 0 min list 1 (random-normal avg-likelihood-h2 0.2) ; each patch has P(e|h2) between 0.001 and the number assigned by the slider if likelihood-h2 < 0.001 [ set likelihood-h2 0.001 ] ; ensures NetLogo's doesn't go crazy with logarithms of small numbers ; calculate set color based on the dominant likelihood let likelihood-diff likelihood-h1 - likelihood-h2 if likelihood-diff > 1 [ set pcolor scale-color green likelihood-diff 0 1 ; darker green as likelihood-diff increases ] if likelihood-diff < 1 [ set pcolor scale-color green (1 - likelihood-diff) 0 1 ; lighter green as likelihood-diff decreases ] if likelihood-diff = 0 [ set pcolor green ; set to pure green when the likelihoods are the same ] ] end ; create agents to setup-turtles create-power-seekers number-of-turtles-each [ set color red set count-h1 0 set count-h2 0 set prop-h1 0 set prop-h2 0 set prior-h1 max list 0 min list 1 (random-normal avg-prior-h1-power-seekers sd-priors-ps) if prior-h1 > 1 [set prior-h1 1] set prior-h2 (1 - prior-h1) if prior-h1 > 1 [set prior-h1 1] set strategy "power" setxy random-xcor random-ycor ] create-goodness-seekers number-of-turtles-each [ set color blue set count-h1 0 set count-h2 0 set prop-h1 0 set prop-h2 0 set prior-h1 max list 0 min list 1 (random-normal avg-prior-h1-goodness-seekers sd-priors-gs) if prior-h1 > 1 [set prior-h1 1] set prior-h2 (1 - prior-h1) if prior-h1 > 1 [set prior-h1 1] set strategy "goodness" ; strategy type setxy random-xcor random-ycor ; place them randomly in the world ] end ; main update loop to go ask turtles [ move update ] update-plot update-plot1 update-histogram update-disagreement-plot if ticks = 100 [ stop ] ;stopping condition tick end ; turtles move randomly to move rt random 360 fd 1 end ;;;;;;;;;;;;;;;;;;;STRATEGIES;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; set strategies to update let evidence-here-h1 [likelihood-h1] of patch-here let evidence-here-h2 [likelihood-h2] of patch-here ;print (word "Likelihoods: likelihood-h1=" evidence-here-h1 " likelihood-h2=" evidence-here-h2) if strategy = "power" [ ;power-seekers strategy let P_e (evidence-here-h1 * prior-h1 + evidence-here-h2 * prior-h2) ; computes P(e) using the rule of total probability set EP_1 (log evidence-here-h1 10) - (log P_e 10) ;explanatory power for h_1 set EP_2 (log evidence-here-h2 10) - (log P_e 10) ;explanatory power for h_2 if EP_1 > EP_2 [set count-h1 count-h1 + 1] ;comparison procedure if EP_2 > EP_1 [set count-h2 count-h2 + 1] ;comparison procedure if p-s-bayes-updating? [ ;updating procedure set prior-h1 (evidence-here-h1 * prior-h1 / P_e) ; updating P(h1) set prior-h2 (evidence-here-h2 * prior-h2 / P_e) ; updating P(h2) if prior-h1 > 1 [set prior-h1 1] ; to avoid anomalous priors if prior-h2 > 1 [set prior-h2 1] ; to avoid anomalous priors ] ifelse (count-h1 + count-h2) > 0 [ ;ensures NetLogo will be able to calculate the fraction below set prop-h1 (count-h1 / (count-h1 + count-h2)) ; prop. h1 is the best set prop-h2 (count-h2 / (count-h1 + count-h2)) ; prop. h2 is the best set prop-h1 max list 0 min list 1 prop-h1 ; clamp values set prop-h2 max list 0 min list 1 prop-h2 ; clamp values ] [ set prop-h1 0 set prop-h2 0 ] ; truth-alignment procedure for power-seekers set preferred-hypothesis ifelse-value (EP_1 > EP_2) ["h1"] ["h2"] ;picks out the selected hypothesis ifelse preferred-hypothesis = ground-truth [set truth-alignment truth-alignment + 1] [set truth-alignment truth-alignment - 1] ;truth alignment counting if truth-alignment > ticks [set truth-alignment ticks] ; clamp values ] if strategy = "goodness" [;goodness-seekers strategy let P_e (evidence-here-h1 * prior-h1 + evidence-here-h2 * prior-h2); computes P(e) using the rule of total probability ifelse prior-h1 < (10 ^ -300) [set k1 -300] [set k1 log prior-h1 10] ; k1 facilitates NetLogo's handling the log of very low numbers ifelse prior-h2 < (10 ^ -300) [set k2 -300] [set k2 log prior-h2 10]; k1 facilitates NetLogo's handling the log of very low numbers set EG_1 (log evidence-here-h1 10) - log P_e 10 + (0.5 * k1) ; explanatory goodness for h1 set EG_2 (log evidence-here-h2 10) - log P_e 10 + (0.5 * k2) ; explanatory goodness for h2 if EG_1 > EG_2 [set count-h1 count-h1 + 1] ;comparison procedure if EG_2 > EG_1 [set count-h2 count-h2 + 1] ;comparison procedure if g-s-bayes-updating? [ ;updating procedure set prior-h1 (evidence-here-h1 * prior-h1 / P_e) ; updating P(h1) set prior-h2 (evidence-here-h2 * prior-h2 / P_e) ; updating P(h2) if prior-h1 > 1 [set prior-h1 1] ; to avoid anomalous priors if prior-h2 > 1 [set prior-h2 1] ; to avoid anomalous priors ] ifelse (count-h1 + count-h2) > 0 [ ;ensures NetLogo will be able to calculate the fraction below set prop-h1 (count-h1 / (count-h1 + count-h2)) ; prop. h1 is the best set prop-h2 (count-h2 / (count-h1 + count-h2)) ; prop. h2 is the best set prop-h1 max list 0 min list 1 prop-h1 ; clamp values set prop-h2 max list 0 min list 1 prop-h2 ; clamp values ] [ set prop-h1 0 set prop-h2 0 ] ; truth-alignment procedure for goodness-seekers set preferred-hypothesis ifelse-value (EG_1 > EG_2) ["h1"] ["h2"] ;picks out the selected hypothesis ifelse preferred-hypothesis = ground-truth [set truth-alignment truth-alignment + 1] [set truth-alignment truth-alignment - 1] ;truth alignment counting if truth-alignment > ticks [set truth-alignment ticks] ; clamp values ] end ;;;;;;;;;;;;;PLOTS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; update plot for prop(h1) to update-plot set-current-plot "Average Proportion h1 is the Best over Time" set-current-plot-pen "Power-Seekers" plotxy ticks mean [prop-h1] of power-seekers set-current-plot-pen "Goodness-Seekers" plotxy ticks mean [prop-h1] of goodness-seekers end ; display results: average credence over time for both groups to plot-results set-current-plot "Average Proportion h1 is the Best over Time" set-current-plot-pen "Power-Seekers" plotxy ticks mean [prop-h1] of power-seekers set-current-plot-pen "Goodness-Seekers" plotxy ticks mean [prop-h1] of goodness-seekers end ; update truth-alignment plot to update-plot1 set-current-plot "Truth Alignment Over Time" set-current-plot-pen "Power-Seekers" plotxy ticks mean [truth-alignment] of power-seekers set-current-plot-pen "Goodness-Seekers" plotxy ticks mean [truth-alignment] of goodness-seekers end ; display results: truth alignment over time for both groups to plot-results1 set-current-plot "Truth Alignment Over Time" set-current-plot-pen "Power-Seekers" plotxy ticks mean [truth-alignment] of power-seekers set-current-plot-pen "Goodness-Seekers" plotxy ticks mean [truth-alignment] of goodness-seekers end ; update priors distribution histogram to update-histogram set-current-plot "Prior Distributions" clear-plot set-current-plot-pen "Distribution h1 PS" histogram [prior-h1] of power-seekers set-current-plot-pen "Distribution h1 GS" histogram [prior-h1] of goodness-seekers end ; update disagreement plot to update-disagreement-plot set-current-plot "Disagreement on the BE over Time" set-current-plot-pen "Power-Seekers" plotxy ticks standard-deviation [prop-h1] of power-seekers set-current-plot-pen "Goodness-Seekers" plotxy ticks standard-deviation [prop-h1] of goodness-seekers end ;##################################################################################################
There is only one version of this model, created 11 days ago by Gesiel da Silva.
Attached files
File | Type | Description | Last updated | |
---|---|---|---|---|
Comparing explanatory power and explanatory goodness.png | preview | Preview for 'Comparing explanatory power and explanatory goodness' | 11 days ago, by Gesiel da Silva | Download |
This model does not have any ancestors.
This model does not have any descendants.