Skip to content

Commit bc75c39

Browse files
committed
added description for Ripley's-K
1 parent 44414c8 commit bc75c39

1 file changed

Lines changed: 15 additions & 28 deletions

File tree

Code Examples/Extensions Examples/sr/Ripleys-K Example.nlogox

Lines changed: 15 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -41,19 +41,18 @@ to setup
4141
;; create 20 turtles at random positions
4242
create-turtles 20
4343
[
44-
set xcor random-xcor
45-
set ycor random-ycor
44+
set heading random 360
45+
fd random-float (max-pycor - 2)
4646
]
4747
4848
reset-ticks
4949
end
5050
5151
to go
5252
;; let the turtles walk around randomly
53-
ask turtles
54-
[
53+
ask turtles [
5554
right random 360
56-
forward random 10
55+
forward random 3
5756
]
5857
5958
;; send agent variables into an R data-frame
@@ -68,17 +67,17 @@ to go
6867
sr:run "K <- Kest(agppp)"
6968
7069
clear-plot
71-
update-plots
70+
update-plots ; update code is in the plot's update commands
7271
end
7372
7473
7574
; Public Domain:
7675
; To the extent possible under law, Uri Wilensky has waived all
7776
; copyright and related or neighboring rights to this model.]]></code>
7877
<widgets>
79-
<view x="479" wrappingAllowedX="true" y="57" frameRate="30.0" minPycor="-16" height="334" showTickCounter="true" patchSize="10.0" fontSize="10" wrappingAllowedY="true" width="334" tickCounterLabel="ticks" maxPycor="16" updateMode="1" maxPxcor="16" minPxcor="-16"></view>
78+
<view x="455" wrappingAllowedX="true" y="57" frameRate="30.0" minPycor="-16" height="334" showTickCounter="true" patchSize="10.0" fontSize="10" wrappingAllowedY="true" width="334" tickCounterLabel="ticks" maxPycor="16" updateMode="1" maxPxcor="16" minPxcor="-16"></view>
8079
<button x="7" y="97" height="35" disableUntilTicks="true" forever="false" kind="Observer" width="63">go</button>
81-
<plot x="75" autoPlotX="true" yMax="1.0" autoPlotY="true" yAxis="K(r)" y="55" xMin="0.0" height="355" legend="false" xMax="1.0" yMin="0.0" width="353" xAxis="r" display="Ripley's K function">
80+
<plot x="75" autoPlotX="true" yMax="1.0" autoPlotY="true" yAxis="K(r)" y="55" xMin="0.0" height="355" legend="true" xMax="1.0" yMin="0.0" width="353" xAxis="r" display="Ripley's K function">
8281
<setup></setup>
8382
<update><![CDATA[;; get results from R
8483
let ripl_k sr:runresult "K$iso"
@@ -94,14 +93,14 @@ foreach ripl
9493
set-current-plot "Ripley's K function"
9594
set-current-plot-pen "K(r)"
9695
plotxy (item 0 ?1) (item 1 ?1)
97-
set-current-plot-pen "theo"
96+
set-current-plot-pen "theoretical"
9897
plotxy (item 0 ?1) (item 2 ?1)
9998
]]]></update>
10099
<pen interval="1.0" mode="0" display="K(r)" color="-16777216" legend="true">
101100
<setup></setup>
102101
<update></update>
103102
</pen>
104-
<pen interval="1.0" mode="0" display="theo" color="-2674135" legend="true">
103+
<pen interval="1.0" mode="0" display="theoretical" color="-2674135" legend="true">
105104
<setup></setup>
106105
<update></update>
107106
</pen>
@@ -111,39 +110,27 @@ foreach ripl
111110
</widgets>
112111
<info><![CDATA[## WHAT IS IT?
113112
114-
This model demonstrates
113+
This model demonstrates using the Simple R extension (sr) to run Ripley's K=function to analyze data. Ripley's K-function is used to find out if data are clustered, dispersed or randomly distributed.
115114
116115
## HOW IT WORKS
117116
118-
This section could explain what rules the agents use to create the overall behavior of the model.
117+
The agents are basically placed randomly and the Ripleys K is run on their locations. Each time you press `go` they move randomly again and recalculated Ripley's K.
119118
120119
## HOW TO USE IT
121120
122-
This section could explain how to use the model, including a description of each of the items in the interface tab.
121+
Press `setup` and then `go`. Sometimes you will get an error "Extension exception: object 'agppp' not found...". In this case, just `setup` and `go` again, as it usually has to do with data being produced randomly which creates an error given how this model is coded.
123122
124123
## THINGS TO NOTICE
125124
126-
This section could give some ideas of things for the user to notice while running the model.
125+
Notice the difference between the actual Ripley’s K-function on the data, `R(k)`, and the theoretical value.
127126
128127
## THINGS TO TRY
129128
130-
This section could give some ideas of things for the user to try to do (move sliders, switches, etc.) with the model.
131-
132-
## EXTENDING THE MODEL
133-
134-
This section could give some ideas of things to add or change in the procedures tab to make the model more complicated, detailed, accurate, etc.
135-
136-
## NETLOGO FEATURES
137-
138-
This section could point out any especially interesting or unusual features of NetLogo that the model makes use of, particularly in the Procedures tab. It might also point out places where workarounds were needed because of missing features.
129+
Try changing how the turtles are arranged and see what that does to Ripley's K.
139130
140131
## RELATED MODELS
141132
142-
This section could give the names of models in the NetLogo Models Library or elsewhere which are of related interest.
143-
144-
## CREDITS AND REFERENCES
145-
146-
This section could contain a reference to the model's URL on the web if it has one, as well as any other necessary credits or references.
133+
For more examples of the Simple R Extension, see the other example models in the `sr` folder.
147134
148135
<!-- 2025 -->]]></info>
149136
<turtleShapes>

0 commit comments

Comments
 (0)