Grasshopper

algorithmic modeling for Rhino

Hi everybody!

I am trying to understand how the RANDOM BLOCK works. The problem is the follow:

I have a list of points which go to a LIST ITEM and the point/points that I want to be selected (i) is connected to the RANDOM BLOCK (the random number is a SLIDER).

The problem is when I want to select the maxim number os RANDOM VALUES, it does not select as much points as I put in the SLIDER and I have to modificate the SEED OF RANDOM ENGINE until get a number where exist the maxim point as I put in the SLIDER, because some points are repeated.

Is there any way to do not get repeated results???

 

Maybe if you look the .JPG you can understand it better.

 

Views: 11433

Replies to This Discussion

Hi Chichi,

 

I don't exactly see what's going on, but here is some background information on random numbers:

 

Computers are deterministic machines. I know sometimes they seem unpredictable and fickle, but at the lowest level computers only manipulate ones-and-zeros according to exact and unambiguous rules. As a result of this it is actually impossible to generate true random numbers using a computer. Computers use algorithms that create sequences of pseudo random numbers, numbers that appear to be random, but in fact are created by the application of a deterministic algorithm.

 

One of the major benefits of pseudo random numbers over actual random numbers is that it's easy to reproduce a sequence of numbers. If you generate the first 50 numbers in the pseudo-random sequence with seed=5 they will be exactly the same as when you did it last week. If you want different random numbers, you have to use a different seed. In Grasshopper I thought it important that the same random numbers are always generated, as that minimizes the 'surprise'. However, since the default numbers might not be to your liking, you can always play around with the seed value until you find a pseudo random sequence that suits you.

 

If you generate 8 random numbers between 1 and 10, you might get a sequence like this:

 

  {5, 8, 2, 4, 2, 7, 3, 10}

 

The pseudo random number generator guarantees that the spread of the numbers in the sequence is equal everywhere, but only when you generate an infinite amount of numbers. Since every sequence you care to generate in one human lifetime will not be infinite, there will always be some 'clumping' of values. A small stretch along the number line that is somewhat more densely populated by random numbers than the adjacent stretch.

 

There is also absolutely no guarantee that you won't get the same number more than once. Obviously this is impossible if you were to generate 50 values between 1 and 10 (there are only 10 possible unique numbers), but even if you generate only 2 values between 1 and 10 you might still get the same number twice.

 

Indeed in my example above the value 2 occurs twice, whereas the value 1 doesn't occur at all. If you want a range of numbers without overlaps, it's better to not use the Random component, but instead generate all the numbers using a Range or Series component and then Jitter the list, thus randomizing the order of the values, but not the values themselves.

 

--

David Rutten

david@mcneel.com

Poprad, Slovakia

ok, David!!! I thought it was more or less how it works, but now I know exactly why I could not do what I wanted with my GH-file (thanks for the information). My random hipothesis gets numbers between 1 and 10 and mostly, the results were, i.e:

2,4,3,6,8,5,9,1,4,7 >>> always there was a value which is repeated (in this case: 4)>> that is what I do not want, and that is why I had to change the seed until have a results where no value be repeated....i.e:

1,5,3,8,6,9,10,2,4,7 >>> all the numbers are diferents!!!! but I do not know how do it!!!

 

Thanks a lot!!!

Hi Chichi, as David wrote: "(...)If you want a range of numbers without overlaps, it's better to not use the Random component, but instead generate all the numbers using a Range or Series component and then Jitter the list, thus randomizing the order of the values, but not the values themselves."

just shuffle the series of numbers from 1 to 10. Random component actually can only generate series of random numbers but there is very small chance that u will get unique numbers if You need integres.

Thanks!

Actually I was trying what David said! (just wrong written by me, sorry!! I wanted to say I did not know how to do it).

 

Anyway thanks!!

Great tip David, this issue of the random numbers repeating had me stumped.

 

Also worth adding that if you are selecting a number of random elements (lets say 200) from a finite set (in my case this was 654) the workflow requires an additional step to limit the selection to the first 200 or jittered values.

 

So the first step is to create a series covering the total list of indexes that could be required (so starting at 0 with 654 values in the series), then jittering those results, then, splitting the jittered list so that you only get the first 200. this worked perfectly... happy days

 

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