RussAbbott
RussAbbott

Reputation: 2738

NetLogo histogram data

I tried posting this to the NetLogo user group on Yahoo but wasn't successful in getting the post accepted. So I'm trying here.

NetLogo can plot histograms. Is there any way to get access to the histogram data, i.e., the data generated for the histogram plot? Thanks.

Upvotes: 1

Views: 338

Answers (1)

StephenGuerin
StephenGuerin

Reputation: 871

Happy Holidays, Russ!

I don't think it's possible to get the values. Though if you wanted to implement your own histogram for data, you could use something like:

to-report calc-histogram [ aList numBars aMaxValue ]
  let minValue min aList
  let interval (aMaxValue - minValue) / numBars
  let hist []
  foreach n-values numBars [?] [
   let lowerBound minValue + (? * interval)
   let upperBound lowerBound + interval
   let x (lowerBound + upperBound) /  2
   let y length filter [? >= lowerBound and ? < upperBound] aList
   set hist lput (list x y ) hist
  ]
  report hist 
end

example usage:

observer> calc-histogram [0 1 18 2 3 4 5 6 7 7 7 9 10 7 15 7 17 18 19 ] 5 20
observer: [[2 4] [6 8] [10 2] [14 1] [18 4]]

Upvotes: 2

Related Questions