AutoHotKey(오토핫키) 설명서 Random
Random
의사 난수를 생성
Random, OutputVar [, Min, Max] Random,,NewSeed
Parameters
인수명 | 설명 |
---|---|
OutputVar |
결과의 출력처의 변수명. 부동 소수점수(실수)의 표현 형식은SetFormat커멘드로 설정할 수 있다. |
Min |
결과의 최소치. 생략시는 「0」 부의 값도 가능. 정수의 경우, 「-2147483648」까지 가능. 소수의 경우, 하한은 없다. |
Max |
결과의 최대치. 생략시는 「2147483648」 정수의 경우, 「2147483648」까지 가능. 소수의 경우, 하한은 없다. |
NewSeed |
제1인수를 생략 해 제2인수에 수치를 지정했을 경우, 난수 생성에 사용되는 배정을 설정할 수 있다. 같은 배정을 설정해 똑같이Random커멘드를 실행했을 경우, 얻을 수 있는 값은 반드시 같게 된다. 예를 들면, 이하의 스크립트는, 몇 번 실행해도 반드시 같은 표시가 된다. Random,,1000 Loop,10{ Random,r,0,10000 s=%s%%r%`n } MsgBox,%s%스크립트 개시시는,100나노초단위의 현재 시각을 나타내는 수치가 배정에 사용된다. |
Remarks
Min(와)과Max그리고 설정한 수의 사이에 있는 랜덤인 수치를OutputVar변수에 격납한다.
Max인가Min에 소수점을 포함한 수치가 지정되었을 경우, 결과는SetFormat커멘드로 설정한 포맷의 소수가 된다.
그 이외의 경우는, 정수가 된다.
Related
Example(s)
Random, rand, 1, 10
Random, rand, 0.0, 1.0
Comments based on the original source
This function uses the Mersenne Twister random number generator, MT19937, written by Takuji Nishimura and Makoto Matsumoto, Shawn Cokus, Matthe Bellew and Isaku Wada.
The Mersenne Twister is an algorithm for generating random numbers. It was designed with consideration of the flaws in various other generators. The period, 219937-1, and the order of equidistribution, 623 dimensions, are far greater. The generator is also fast; it avoids multiplication and division, and it benefits from caches and pipelines. For more information see the inventors' web page at http://www.math.keio.ac.jp/~matumoto/emt.html
Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura, All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
- Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
- The names of its contributors may not be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Do NOT use for CRYPTOGRAPHY without securely hashing several returned values together, otherwise the generator state can be learned after reading 624 consecutive values.
When you use this, send an email to: matumoto@math.keio.ac.jp with an appropriate reference to your work. It would be nice to CC: rjwagner@writeme.com and Cokus@math.washington.edu when you write.
This above has been already been done for AutoHotkey, but if you use the Random command in a publicly distributed application, consider sending an e-mail to the above people to thank them for their efforts and generosity.
'AutoHotKey > Commands' 카테고리의 다른 글
AutoHotKey(오토핫키) 설명서 RegExMatch() (0) | 2014.08.14 |
---|---|
AutoHotKey(오토핫키) 설명서 RegDelete (0) | 2014.08.14 |
AutoHotKey(오토핫키) 설명서 Progress / SplashImage (0) | 2014.08.14 |
AutoHotKey(오토핫키) 설명서 Process (0) | 2014.08.14 |
AutoHotKey(오토핫키) 설명서 PostMessage / SendMessage (0) | 2014.08.14 |