Random walk 1-D

Random walk 1-D preview image

1 collaborator

Suman_saurabh Suman Saurabh (Author)

Tags

(This model has yet to be categorized with any tags)
Visible to everyone | Changeable by everyone
Model was written in NetLogo 6.2.2 • Viewed 120 times • Downloaded 22 times • Run 0 times
Download the 'Random walk 1-D' modelDownload this modelEmbed this model

Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)


WHAT IS IT?

The model simulates the random walk of an agent in the world in one dimension. It reports the distance walked and location of the agent with each step. The model also has two additional monitors which reports the mean and standard deviation of the location of the agent.

HOW IT WORKS

  • Randomly moves the agent forward and then randomly moves it backward
  • Keeps track of the distance and location of agent with every move
  • Reports the location's statistical average and standard deviation in monitor
  • Also, presents a histogram of the frequency of location (x cordinate) the agnet have been over time.

HOW TO USE IT

  • Setup button to create the world
  • Select the setp size for agent
  • Select a bias if you want
  • Use the forver loop go button to run the simulation.

THINGS TO NOTICE

  • Notice the mean, standard deviation and histogram of the location of the agent over time

THINGS TO TRY

  • Aadd bias and see the effect on the mean, standard deviation and histogram.

EXTENDING THE MODEL

  • Create a two dimensional movement of agent and set the monitors for each cordinate (x and y) as well as radius from original location and angle the agent has moved to.

NETLOGO FEATURES

  • This model uses the list datatype in the netlogo
  • Also standrd deviation and mean mathematical functions in netlogo.

RELATED MODELS

(models in the NetLogo Models Library and elsewhere which are of related interest)

CREDITS AND REFERENCES

Copyright@ 2022. Suman Saurabh (sumanan047@gmail.com; saurabh@utexas.edu).

Comments and Questions

Please start the discussion about this model! (You'll first need to log in.)

Click to Run Model

;; This code simulates random walk in one dimension by an agent in netlogo
;;Author: Suman Saurabh (saurabh@utexas.edu)
globals[loc-list]

turtles-own [loc dist]

to setup
  clear-all;
  create-turtles 1
  ask turtles[
    set shape "person"
    set color red
    set size 3
    set heading 90                                     ;; sets the heading for agent towards positive x-cordinate movement
    set loc xcor
    set dist 0
  ]
  set loc-list [0]
  reset-ticks;
end 

to go

  ask turtles[
  let tempi xcor                                       ;; declares a temporary variable that keeps the current x-cordinate of agent
  pen-down                                             ;; so that when agent moves, it marks the patch/path
  fd random size-of-step + add-bias                    ;; randomly selects the stepsize from 0 to maximum of size-of-step and then moves the agent forward. The add-bias will add bias to the moevement of agent
  let tempn xcor                                       ;; declares another variable that keeps the new x-cordinate value
  set dist dist + abs (tempi - tempn)                  ;; updates the distance travelled by agent
  bk random size-of-step                               ;; randomly selects the stepsize from 0 to maximum of size-of-step and then moves the agent backwards
  let tempf xcor                                       ;; updated x-cordinate of the agent
  set dist dist + abs (tempn - tempf)                  ;; updates the distance travelled by agent
  set loc-list lput xcor loc-list
  ]
  tick
end 

to-report mean-loc
  report mean loc-list
end 

to-report std-loc
  report standard-deviation loc-list
end 

;;Copyright 2022 @ Suman Saurabh (sumanan047@gmail.com; saurabh@utexas.edu)

There is only one version of this model, created over 3 years ago by Suman Saurabh.

Attached files

File Type Description Last updated
Random walk 1-D.png preview Preview for 'Random walk 1-D' over 3 years ago, by Suman Saurabh Download

This model does not have any ancestors.

This model does not have any descendants.