Created
May 25, 2020 02:30
-
-
Save nuintun/eac3bf75c5496f8acfe4e651842eca20 to your computer and use it in GitHub Desktop.
线性同余随机数
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * @function LCGRandom | |
| * @description 线性同余随机数 | |
| * @param {number} seed | |
| * @returns {number} | |
| * @see https://gist.github.com/Protonk/5389384 | |
| */ | |
| function LCGRandom1(seed = 0) { | |
| return ((seed * 11 + 17) % 25) / 25; | |
| } | |
| /** | |
| * @function LCGRandom | |
| * @description 线性同余随机数 | |
| * @param {number} seed | |
| * @returns {number} | |
| * @see https://www.zhihu.com/question/22818104 | |
| */ | |
| function LCGRandom2(seed = 0) { | |
| return ((seed * 9301 + 49297) % 233280) / 233280; | |
| } |
Author
nuintun
commented
Oct 14, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment