Plot Smoothing Example
Model was written in NetLogo 5.0.4
•
Viewed 529 times
•
Downloaded 95 times
•
Run 0 times
Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)
WHAT IS IT?
This code example shows you how to plot a "smoothed" version of a jagged line. When you run the model, the black line is the original line, and the blue line is the smoothed version.
The amount of smoothing is controlled by the SMOOTHNESS slider.
The black line is generated by doing a one-dimensional random walk.
THINGS TO NOTICE
The very simple method used to do smoothing causes the smoothed line to lag a bit behind the original line, that is, it appear shifted to the right.
CREDITS AND REFERENCES
Thanks to Ed Hazzard for suggesting this example.
Comments and Questions
Please start the discussion about this model!
(You'll first need to log in.)
Click to Run Model
globals [n smoothed] to setup clear-all set n 0 set smoothed 0 reset-ticks end to go ;; the variable N does a random walk set n n + one-of [-1 0 1] tick ;; Here's where we calculate the smoothed version of N. ;; This one line is the heart of the whole example. set smoothed smoothness * smoothed + (1 - smoothness) * n end ; Public Domain: ; To the extent possible under law, Uri Wilensky has waived all ; copyright and related or neighboring rights to this model.
There are 10 versions of this model.
Attached files
File | Type | Description | Last updated | |
---|---|---|---|---|
Plot Smoothing Example.png | preview | Preview for 'Plot Smoothing Example' | over 12 years ago, by Uri Wilensky | Download |
This model does not have any ancestors.
This model does not have any descendants.