Grasshopper

algorithmic modeling for Rhino

This may be more of a logical question than GH, but I'm looking for means to translate the method into GH:

I have a list as follows: [11,12,13,14,15]

I have selected a random item from that list, in this case "13."

I am trying to find the logical way to output that item value as a percentage of the overall list's domain. For example, I need to convert 13 to a value of .5 representing it being the median value of the list. 11 would be 0.0, 12 would be .25, etc...

Any help would be greatly appreciated

Views: 1849

Replies to This Discussion

If you know the item number it is 

item/(list_length-1) 

item goes from 0 to (lenghth-1) so result go from 0 to 1. 

Hello Zak, Laurent,

If by "median value" you mean its in the middle of the list, then its what Laurent said.

If you are talking about its numerical value then you can try something like this (remap all the numbers from domain(11 to 15) to domain (0 to 1):

Nikos, 

Thank you, that is exactly what I was looking for

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