t, let's talk about randomness. Randomness is a problem in computing because digital computers are deterministic. If you give them the exact same instructions they always end up with the exact same result. It turns out to be mathematically impossible to generate true random numbers using a digital computer, but it is fairly easy to generate pseudo-random numbers. This is actually not bad news as pseudo-random numbers -unlike real random numbers- can be generated again and again and you'll end up with the same random numbers every time. Being able to get the same random numbers on demand increases the reliability of these number sequences which in turn makes them easier to use.
Pseudo-random numbers are numbers that have certain characteristics. Note that when we talk about random numbers we are really talking about numbers. Plural. It's easy to generate only a single one, as xkcd so eloquently put it:
So what are these characteristics that define pseudo-randomness? Without being actually correct, I can sum them up as follows:
The sequence of generated numbers should never repeat itself*
The numbers in the sequence ought to be spread evenly across the numeric domain**
There are a lot of different algorithms out there, some better than others, some faster than others, some solving very specific problems while others are more generic. The generator used in Grasshopper is the standard Microsoft .NET Random, based on Donald Knuth's subtractive algorithm.
So let's imagine we want random integers between 0 and 10. What would a bad random sequence look like?
3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 (about as bad as it gets)
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 (not random at all)
1 3 2 5 3 9 1 2 4 2 5 1 1 2 8 1 5 2 3 4 (too many low numbers)
2 8 4 6 0 9 8 2 4 8 6 4 2 2 5 1 4 8 6 2 (too many even numbers)
So what about good sequences? Well, here's a few:
6 9 1 2 0 4 2 8 5 7 2 9 1 9 2 5 3 1 9 2 (sure, why not)
6 2 5 3 4 1 9 7 8 0 2 1 6 4 5 8 9 5 0 9 (looks about right)
1 8 5 2 3 4 5 7 9 5 2 1 0 2 1 0 9 7 6 4 (I suppose)
9 0 6 4 8 3 1 5 2 7 6 1 4 6 0 1 9 7 5 6 (whatever)
There are a lot of valid pseudo-random sequences. (Seriously, loads). So even if we have a good pseudo-random generator we may be given a random sequence that isn't entirely to our liking. The shorter the sequence we need, the more likely it is that statistical aberrations invalidate that particular sequence for us. What we need is some control over the generator so we don't just get a repeatable sequence, but a repeatable sequence we actually like.
Enter seed values. The random generator requires a seed value before it can generate a random sequence. These seed values are always integers, and they can be any valid 32-bit integer. Every unique seed value results in the same sequence. Every time.
Unfortunately there is no clear relationship between seeds and sequences. Changing the seed value from 5 to 6 will result in a completely difference random sequence, and two sequences that are very similar may well have to wildly different seeds. There is therefore no way to guess a good seed value, it is completely trial-and-error. Also because of this extremely discontinuous nature, you cannot use tools like Galapagos to optimize a seed value.
If you are looking for a pseudo-random sequence which has custom characteristics, you may well end up having to write your own generator algorithm. Ask questions about this on the Grasshopper main forum or the VB/C# forum.
Conclusion: Seed values are integers that define the exact sequence of pseudo-random numbers, but there's no way of knowing ahead of time what sequence it will be and there's no way of tweaking a sequence by slightly changing the seed. Even the tiniest change in seed value will result in a radically different random sequence.
--
David Rutten
david@mcneel.com
Poprad, Slovakia
* This is not actually possible. A finite amount of numbers always repeats itself eventually.
** This should only be true for long enough sequences, short sequences are allowed to cluster their values somewhat.
Interesting links for further reading:
Coding Horror: Computers are Louse Random Number Generators
StackOverflow: When do random numbers start repeating?…
Added by David Rutten at 9:52am on October 20, 2012
e curve and then repeats it. The random numbers don't iterate themselves after each loop.
My script:
Dim points As New list(Of Point3d) For i As int32 = 0 To N 'defining the points for cruve Dim pt1 As New point3d Dim pt2 As New point3d Dim pt3 As New point3d Dim pt4 As New point3d pt2 = New Point3d(pt1) pt3 = New Point3d(pt2) pt4 = New Point3d(pt3) 'equations for generating random points Dim RandomClass As New Random Dim RandomNumber As New Integer Dim RandomNumber2 As New Integer Dim RandomNumber3 As New Integer Dim RandomNumber4 As New Integer Dim RandomNumber5 As New Integer Dim RandomNumber6 As New Integer Dim RandomNumber7 As New Integer Dim RandomNumber8 As New Integer RandomNumber = RandomClass.Next(1, 10) RandomNumber2 = RandomClass.Next(-5, 5) RandomNumber3 = RandomClass.Next(1, 10) RandomNumber4 = RandomClass.Next(-5, 5) RandomNumber5 = RandomClass.Next(1, 10) RandomNumber6 = RandomClass.Next(-5, 5) RandomNumber7 = RandomClass.Next(1, 10) RandomNumber8 = RandomClass.Next(-5, 5) pt1.X = RandomNumber7 pt1.Y = RandomNumber8 pt1.Z = i pt2.X = pt1.X + RandomNumber pt2.Y = RandomNumber2 pt2.Z = i pt3.X = pt2.X + RandomNumber3 pt3.Y = RandomNumber4 pt3.Z = i pt4.X = pt3.X + RandomNumber5 pt4.Y = RandomNumber6 pt4.Z = i 'generating points for a curve. points.add(pt1) points.add(pt2) points.add(pt3) points.add(pt4) Next a = points
Can anyone help me with this problem?
Thanks…
to 10 = color 2
10 to 15 = color 3
15 to 30 = color 4
....
I divide the surface by number of segments. How can I divide the surface by distance between
any help...…
e! I do not have good ideas today!
The end result of the list would be:
5, 10, 15, 20, 21, (21 + 5), (21 + 10), (21 + 15), (21 + 20), (21 + 21), (42 + 5), (42 + 10), (42 + 15), (42 + 20), (42 + 21), etc …
Sorry, it was caught in my spam filter, thanks for chasing. To anyone else reading this, get in touch if you don't get a reply within 24 hours (normally within 10).
Thanks,
Jon
axim value according to the addition do not be greater or higher of this value?
i.e.
All the sliders from 0 to 5, and I do not want the maxim value was higher than 10, then:
Slider 1 >>> value 3
Slider 2 >>> value 2
Slider 3 >>> value 1
Slider 4 >>> this value must be less than 4
Then i.e. if these 4 Sliders are random, is it possible the addition of random numbers not be higher of that value I am talking?
I do not know if I was able to explain myself!
thank you very much!!…
I assume that branch 0;0 has N = 10 points, 0;1 N = 7 points.
In the photo the way you describe the points it is like branch 0;0 has N = 45 points, where subbranch 0;0;1 has null points, subbrach 0;0;1 has N=1 point... subbranch 0;0;9 has N= 9 points.
Most likely you need to just graft you initial data tree that has the following structure
0;0 with N = 10
0;1 with N = 7
0;2 with N = 9
0;3 with N = 5
0;4 with N = 8
without a file, or a solid description of your starting data structure all these remain assumptions.
…
oning behind using the equality component to test for even numbers is flawed because of the data matching used by gh. It is testing like this:
0==0 True
2==1 False
4==2 False
6==3 False
etc
.............
Where as a Modulo 2 would work like this
0%2 = 0
1%2 = 1
2%2 = 0
3%2 = 1
4%2 = 0
5%2 = 1
6%2 = 0
7%2 = 1
8%2 = 0
9%2 = 1
......
Also I notice you have some errors in your expressions producing Nulls.
If you want it to be twice the value then you should have 2*D in the Expression and 10*D in the other
....
I attach a working version.…