Grasshopper

algorithmic modeling for Rhino

Hi everyone, I've got a set of numbers and i'm trying to find an algorithm that allows me to extract the mode (the number that appears more times in the set) from it, but i really can't find a way.

And what if i want to add a tollerance to the algorithm? what i mean is:

in a set like:

1.00

2.00

2.00

2.00

2.10

3.01

3.04

4.95

5.00

5.00

5.01

5.02

5.09

6.01

7.00

7.50

The mode is 2.00 because that's the most frequent value, but adding a sort of tollerance like 0,1 (e.g.) the mode changes to circa 5, bacause accepted values are 4.95, 5.00, 5.00, 5.01, 5.02, 5.09.

I know that this can be a difficult question, but there is someone of good will out there? Thanks a lot:)

Views: 1746

Replies to This Discussion

Never heard of the term "mode" being used that way.

Attachments:

Never heard of the term "mode" being used that way.

Mode, Median, and Mean are the three typical statistical measures of a set. There's nothing in GH to compute the median or mode directly but there are of course many ways of doing it yourself.

In addition to your excellent solution, here's a geometric approach which uses the [Point Groups] component. It has full control over the tolerance and returns the average value of all values that were within tolerance of each other.

Attachments:

Very interesting.  I must have known about this use of "mode" at one time but don't remember ever using it.

Instead of the "-x" expression, you can get the same result by reversing the sorted list of averages, eh?

How have I missed 'PGroups' until now!  Very cool.

I like the greater flexibility in using distance for "tolerance".  Thanks for the Master Class.

Instead of the "-x" expression, you can get the same result by reversing the sorted list of averages, eh?

Yes indeed, but you'd have to reverse both lists. This way the sorting is correct right from the start. It's a matter of preference I guess.

Thank you for your suggestions... Both were so helpful!

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service