⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ---prob graphs basic.nlogo

📁 NETLOGO
💻 NLOGO
📖 第 1 页 / 共 2 页
字号:
globals [  event  total-attempts  total-successes  counter  counter-list   successes-per-sample-list  attempts-this-sample  successes-this-sample  samples-counter ]to setup  ;; resets everything to appropriate initial values  ca  set event "-"  set total-attempts 0    set total-successes 0  set counter 0    set counter-list []  set attempts-this-sample 0  set successes-this-sample 0  set samples-counter 0  set successes-per-sample-list []endto go  if samples-counter = how-many-samples? [stop]  set total-attempts total-attempts + 1  set counter counter + 1  select-and-check  update-and-plotend    to select-and-check    ;; This procedure simulates a chance event by randomly selecting a number between 1 and  ;; sample-space-size, for instance between 1 and 5, as if you are rolling a die with 5  ;; sides. Next, the procedure checks to see if this event (what you "rolled") happens to  ;; be '1.' A '1' is a success. Note that 'random' reports a number between 0 and value,  ;; so "random 1" is only 0, and "random 2" is 0 or 1. That is why we have to add 1.  set event ( 1 + random sample-space-size )  if  event = 1    [     set total-successes total-successes + 1     set counter-list lput counter counter-list     set counter 0     set successes-this-sample successes-this-sample + 1    ]endto update-and-plot  ;; updates values for each of the three plots  update-and-plot-m/n  update-and-plot-Attempts  update-and-plot-successesendto update-and-plot-m/n  set-current-plot "m/n convergence to limiting value"  plot (total-successes / total-attempts)endto update-and-plot-Attempts  if length counter-list = 0 [stop]  set-current-plot "Attempts-until-Success Distribution"    ;; setting the range just beyond the maximum value (e.g.,5 beyond but it could be more or less)  ;; helps the eye pick up that the right-most value is indeed the maximum value  set-plot-x-range 0 ( (max counter-list) + 5)  histogram-list counter-listendto update-and-plot-successes  set attempts-this-sample attempts-this-sample + 1  if attempts-this-sample = sample-size   [    set successes-per-sample-list lput successes-this-sample successes-per-sample-list    set-current-plot "Successes-per-Sample Distribution"        ;; This line adjusts the top range of the x-axis so as to stabilize and centralize    ;; the distribution. The idea is to try and keep the emergent graph shape in the    ;; middle of the plot. The 'ceiling' primitive keeps the maximum range value an integer.    set-plot-x-range 0 ( max ( list plot-x-max                                    ( 3 + ( ceiling ( 2 * mean successes-per-sample-list ) ) ) ) )    histogram-list successes-per-sample-list    set attempts-this-sample 0    set successes-this-sample 0    set samples-counter samples-counter + 1       ]end; *** NetLogo Model Copyright Notice ***;; This model was created as part of the project:; PARTICIPATORY SIMULATIONS: NETWORK-BASED DESIGN FOR SYSTEMS LEARNING IN; CLASSROOMS.  The project gratefully acknowledges the support of the; National Science Foundation (REPP program) -- grant number REC #9814682.;; Copyright 2002 by Uri Wilensky.  Updated 2003.  All rights reserved.;; Permission to use, modify or redistribute this model is hereby granted,; provided that both of the following requirements are followed:; a) this copyright notice is included.; b) this model will not be redistributed for profit without permission;    from Uri Wilensky.; Contact Uri Wilensky for appropriate licenses for redistribution for; profit.;; To refer to this model in academic publications, please use:; Wilensky, U. (2002).  NetLogo Prob Graphs Basic model.; http://ccl.northwestern.edu/netlogo/models/ProbGraphsBasic.; Center for Connected Learning and Computer-Based Modeling,; Northwestern University, Evanston, IL.;; In other publications, please use:; Copyright 1998 by Uri Wilensky.  All rights reserved.  See; http://ccl.northwestern.edu/netlogo/models/ProbGraphsBasic; for terms of use.;; *** End of NetLogo Model Copyright Notice ***@#$#@#$#@GRAPHICS-WINDOW24030495681707.01101110111CC-WINDOW5623743718Command Center0BUTTON9955178101NILgoT1TOBSERVERTNILBUTTON45583101NILsetupNIL1TOBSERVERTNILPLOT20155543238m/n convergence to limiting valueAttemptsSuccesses per Attempts0.0100.00.01.0truefalsePLOT201239543399Attempts-until-Success DistributionRun LengthFrequency1.050.00.010.0truefalsePENS"default" 1.0 1 -16777216 trueSLIDER6199181232sample-space-sizesample-space-size110211NILPLOT201398543559Successes-per-Sample DistributionSuccessesFrequency0.010.00.025.0truefalsePENS"default" 1.0 1 -16777216 trueSLIDER9481181514sample-sizesample-size01001051NILSLIDER7395181428how-many-samples?how-many-samples?01000300101NILMONITOR547132646181NILtotal-attempts31MONITOR67786734135ratetotal-successes / total-attempts31MONITOR54755646104total-successestotal-successes01TEXTBOX548109674127________________     =MONITOR546399693448NILsuccesses-this-sample31MONITOR9515181564NILattempts-this-sample31MONITOR546239603288NILcounter31MONITOR8429181478NILsamples-counter31MONITOR442560543609maxmax successes-per-sample-list31MONITOR201560305609minmin successes-per-sample-list31MONITOR322560426609meanmean successes-per-sample-list31TEXTBOX6103136199The program will record and plot the random occurrence of the event "1" among other integers in the sample space of size...MONITOR546290603339meanmean counter-list31TEXTBOX3121040228speed sliderMONITOR140118190

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -