Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

建议更改随机数生成方式 #34

Open
JOHNYXUU opened this issue Dec 30, 2019 · 2 comments · May be fixed by #35
Open

建议更改随机数生成方式 #34

JOHNYXUU opened this issue Dec 30, 2019 · 2 comments · May be fixed by #35

Comments

@JOHNYXUU
Copy link

由于您代码中的随机数生成是固定的,导致每次第一次出现的cxk图片都是固定的,非常影响观感,建议修改
随机数生成代码如下
`function rnd( seed ){
seed = ( seed * 9301 + 49297 ) % 233280; //为何使用这三个数?
return seed / ( 233280.0 );
};

function rand(number){
today = new Date();
seed = today.getTime();
return Math.ceil( rnd( seed ) * number );
};

myNum=(rand(5));`

@liyishuai
Copy link
Contributor

Does your function guarantee uniform distribution? If not, we should stick to Math.random.
To introduce nondeterminism, we can discard k results from PRNG, where k depends on system time.

@JOHNYXUU
Copy link
Author

Does your function guarantee uniform distribution? If not, we should stick to Math.random.
To introduce nondeterminism, we can discard k results from PRNG, where k depends on system time.

tbh,i get those functions from others, if u doubt the uniform distribution of function,u can go there
https://www.zhihu.com/question/22818104
hope it can solve your questions

@liyishuai liyishuai linked a pull request Dec 30, 2019 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants