对数组的每一个位置随机排序:
https://blog.csdn.net/cyningsun/article/details/7545679
https://www.cnblogs.com/nily/p/4815797.html
String[] array = newString[]{"a","b","c","d","e","f","g"};
for (inti = 0; i < array.length; i++) {
int s = (int)(Math.random()*array.length);
inttemp = array[i];
array[i] = array[s];
array[s] = temp;}
三角形概率题
https://blog.csdn.net/weixin_41245919/article/details/88913251
rand3rand5、蓄水池抽样
https://www.cnblogs.com/grandyang/p/9727206.html
https://blog.csdn.net/jinzhao1993/article/details/69056135
https://www.cnblogs.com/python27/p/Reservoir_Sampling_Algorithm.html
大小王概率题:
https://zhidao.baidu.com/question/1926185954972234187.html
雇佣问题
https://blog.csdn.net/dajiyi1998/article/details/79538054
https://blog.csdn.net/zhang_xiaomeng/article/details/71425008
https://blog.csdn.net/qq_37098526/article/details/88650496
其他概率题
https://www.cnblogs.com/fanling999/p/6777335.html
https://blog.csdn.net/youwuwei2012/article/details/38018121
https://blog.csdn.net/qq_28836475/article/details/80218558
https://blog.csdn.net/chdhust/article/details/8533300
给出一个没有排序的N个数字的数组有1也有其他数字,随机的等概率的抽出1
同理,只要先前访问过的位置(不论是不是1)后来不访问,则可以保证抽到1的概率相同~
嗯嗯,应该是。假设5个数,其中3个为1,则抽第一个的概率为3/5。先前抽过的不再访问(设置visited标志),则抽第二个的时候分两种情况讨论:①第一个抽到1了,这种情况概率为3/5,剩下4个数有2个1,则抽到1的概率为2/4=1/2;②第一个没抽到1,这种情况概率为2/5,剩下4个数有3个1,则抽到1的概率为3/4。这两种情况合起来就是3/5*1/2 + 2/5*3/4 = 3/5。确实抽彩票也是这样,与顺序无关的。
网友评论