0

I'm still having problems with [histogram].

I have a global variable (age-sick) that stores the age of the turtles when they got sick...and I want to plot the distribution: histogram age-sick

However I do not want the absolute number of turtles who got sick per every age, rather the relative one. Is there a way to do so?

GhettiG
  • 91
  • 9
  • What you mean, “the relative one”? Can you explain it more? – Seth Tisue Jun 02 '16 at 12:18
  • Suppose I have this list: (1112345555)...the `histogram` function plots 5 bars: the first of height 3, the second, third and fourth of height 1 and the last of height 4. Instead I want the first bar to be 30%, the second, third and fourth 10% and the last 40%...is there a way? – GhettiG Jun 06 '16 at 08:01
  • How is that materially any different? The heights end up the same, proportionally. – Seth Tisue Jun 06 '16 at 11:48
  • I get your point...but on the same plot I want two histograms...the age distribution when agents got sick and the actual age distribution of the agents...this is the reason why I want to normalize everything between 0 and 1000 (or 100) – GhettiG Jun 07 '16 at 09:05
  • I see. Then the `histogram` primitive won't help you; you'll have to roll your own. It's a bit sad that you can't reuse the underlying binning functionality of `histogram`; see https://github.com/NetLogo/NetLogo/issues/367 – Seth Tisue Jun 07 '16 at 13:31

1 Answers1

0

I have tried to overcome the problem in the following way:​​

let age-freq (list)
let i 0
while [ i <= (max age-sick)] [
let a filter [? = i] age-sick
repeat (length a / length age-sick * 1000) [set age-freq lput i age-freq]
set i i + 1]
histogram age-freq]
Fabian N.
  • 3,807
  • 2
  • 23
  • 46
GhettiG
  • 91
  • 9