概述
我们来自江河梦小组(Scond Effect Group),工程用到gh,所以必须学习好GH插件,而大部分权威资料都来自国外,所以就组织组员翻译来自GH官方论坛的帖子,以便学习。下面是一篇David的帖子讲解随机数原理,由黄思颖同学翻译。
What are random seed values?什么是随机种子?
- Posted by David Rutten on October 20, 2012 at 9:52am in FAQ (Frequent Questions and Problems)
- Send Message View Discussions
Most components inGrasshopper that utilize randomness on some level have an input called 'Seed'.So what is a seed for, why would you want to change it and how do you know whatto change it to?
多数使用随机数的计算器都有一个输入端叫做种子。因此种子是用来干什么的?为什么你试图改变它?你如何知道将它改变成什么?
First, let's talkabout randomness. Randomness is a problem in computing because digitalcomputers are deterministic.If you give them the exact same instructions they always end up with the exactsame result. It turns out to be mathematically impossible to generate true random numbers usinga digital computer, but it is fairly easy to generate pseudo-random numbers.This is actually not bad news as pseudo-random numbers -unlike real randomnumbers- 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 reliabilityof these number sequences which in turn makes them easier to use.
首先说说随机。随机是计算的一个问题,如果你输入相同的命令将总是以相同的结果终止。使用数学计算器产生真实的随机数这在数学上被证明是不可能的,但是生成虚拟的随机数字相当容易。这对于伪随机数来说不是个坏消息,不像真实的随机数字,它们可以被多次重复生成,你每次都将得到相同的随机数。可以按要求生成相同的随机数增加了这些数字序列的可靠度,反过来也让这些数字更简单被使用。
Pseudo-random numbersare numbers that have certain characteristics. Note that when we talk aboutrandom numbers we are really talking about numbers. Plural. It's easy to generate only asingle one, as xkcd so eloquently put it:
伪随机数是带有明确特征的数字,明确一点就是当我们谈论随机数时我们确实是在谈论数字。单个复数很容易生成,用门罗漫画的形式表现出来:(xkcd由兰德尔.门罗所绘制的网络漫画)
So what are thesecharacteristics that define pseudo-randomness? Without being actually correct,I can sum them up as follows:
§ Thesequence of generated numbers should never repeat itself*
§ Thenumbers in the sequence ought to be spread evenly across the numeric domain**
因此定义伪随机数的这些特征是什么呢?可能并非十分正确,我总结了如下两点:
生成数字的序列本身并不可复制。
序列中的数字应该被平均分配到数字域中。
There are a lot ofdifferent algorithms out there, some better than others, some faster thanothers, some solving very specific problems while others are more generic. Thegenerator used in Grasshopper is the standard Microsoft .NET Random, based on Donald Knuth's subtractive algorithm.
大量不同的算法有些比其他好,有些比其他快,有些可以解决特殊问题然而其他的却只能解决一般问题。GH中的运算法是基于DonaldKnuth的减法法则的标准微软.NET随机。
So let's imagine wewant random integers between 0 and 10. What would a bad randomsequence look like?
因此想象一下我们想要得到从1到10的随机整数。不好的序列会是怎样的呢?
§ 3 3 3 3 33 3 3 3 3 3 3 3 3 3 3 3 3 3 3 (about as bad as it gets)
§ 0 1 2 3 45 6 7 8 9 0 1 2 3 4 5 6 7 8 9 (not random at all)非随机
§ 1 3 2 5 39 1 2 4 2 5 1 1 2 8 1 5 2 3 4 (too many low numbers)
§ 2 8 4 6 09 8 2 4 8 6 4 2 2 5 1 4 8 6 2 (too many even numbers)
So what about goodsequences? Well, here's a few:好的序列是:
§ 6 9 1 2 04 2 8 5 7 2 9 1 9 2 5 3 1 9 2 (sure, why not)
§ 6 2 5 3 41 9 7 8 0 2 1 6 4 5 8 9 5 0 9 (looks about right)
§ 1 8 5 2 34 5 7 9 5 2 1 0 2 1 0 9 7 6 4 (I suppose)
§ 9 0 6 4 83 1 5 2 7 6 1 4 6 0 1 9 7 5 6 (whatever)
There are a lot of validpseudo-random sequences. (Seriously, loads). So even if we have a goodpseudo-random generator we may be given a random sequence that isn't entirelyto our liking. The shorter the sequence we need, the more likely it is that statisticalaberrationsinvalidate that particular sequence for us. What we need is some control overthe generator so we don't just get a repeatable sequence, but a repeatablesequence we actually like.
这里有许多有效的伪随机序列。因此即使我们有很好的伪随机数生产器,我们仍然可能得到并非完全照我们所想的随机序列。我们需要的序列越短,越有可能出现统计学的越轨使特殊的序列产生。
Enter seed values. Therandom generator requires a seed value before it can generate a randomsequence. These seed values are always integers, and they can be any valid32-bit integer. Every unique seed value results in the same sequence. Everytime.
输入种子值。随机运算器在运行随机序列之前需要一个种子值。这些种子值总是整数,他们可以是任意32字节整数。每次每个单一的种子值导致的是相同的序列。
Unfortunately there isno clear relationship between seeds and sequences. Changing the seed value from5 to 6 will result in a completely difference random sequence, and twosequences that are very similar may well have to wildly different seeds. Thereis 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 likeGalapagos to optimize a seed value.、
不幸的是种子和结果之间没有清晰地关系。将种子值从5变为6将导致完全不同的随机序列,两个非常近似的结果也许是相当不同的种子。因此没有方法去猜想一个好的种子值,完全是不断的尝试。同样因为这个完全不连续的性质,你不能使用像Galapagos这样的工具来优化种子值。
If you are looking fora pseudo-random sequence which has custom characteristics, you may well end uphaving to write your own generator algorithm. Ask questions about this on theGrasshopper main forum or the VB/C# forum.
如果你寻求有规范特征的伪随机序列,最终可能必须自己编写序列运算法则。关于这个的问题请于GH或VB/C#论坛寻求答案。
Conclusion:Seed values are integers that define the exact sequenceof pseudo-random numbers, but there's no way of knowing ahead of time whatsequence it will be and there's no way of tweaking a sequence by slightly changing the seed. Even the tiniest change inseed value will result in a radically different random sequence.
结论:种子值是定义伪随机数字精确序列的整数,但是没有方法提前预知序列是多少,也没有办法调整序列仅仅靠改变种子。甚至种子值最小的变化也将导致彻底不同的随机序列。
--
David Rutten
david@mcneel.com
Poprad, Slovakia
* This is not actuallypossible. A finite amount of numbers always repeats itself eventually.
事实上这并不可能,A限定的所有数字最终经常进行自我复制。
** This should only betrue for long enough sequences, short sequences are allowed to cluster theirvalues somewhat.
这仅仅对于足够长的序列才正确,短的序列多少允许值的聚集。
Interesting links forfurther reading:
Coding Horror: Computers are Louse Random NumberGenerators
StackOverflow: When do random numbers start repeating?
Tags: Random, numbers, pseudo-random, seed
原文链接:http://www.grasshopper3d.com/forum/topics/what-are-random-seed-values
最后
以上就是无辜龙猫为你收集整理的什么是随机种子What are random seed values?什么是随机种子?的全部内容,希望文章能够帮你解决什么是随机种子What are random seed values?什么是随机种子?所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复