Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit b85d2f6

Browse files
zhangzz2015gitbook-bot
authored andcommitted
GitBook: [greyireland#115] No subject
1 parent 62b569a commit b85d2f6

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

‎suan-fa-si-wei/sampling-fang-fa.md‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
包括Reject sampling 和 **Fisher-Yates Shuffle 以及蓄水池算法**
44

5+
蓄水池算法
6+
7+
计算复杂度高,空间复杂度低,核心逻辑,选择第i个数的概率 1/i \* (1 - 1/(i+1)) \* (1 - 1/(i+2)) \* (1 - 1/N) = 1/N,比较适合流数据处理,也可生成k/N 个随机数
8+
9+
10+
511
### **470.Implement Rand10() Using Rand7()**
612

713
使用7个数字表达出更多个数字,构造两位7进制,(rand7() - 1) \* 7 + rand7() - 1,可以取得0-48之间的数字。如得到0-39之间的数字,使用(num % 10 + 1)等概率映射出1-10. 如得到40-48之间的数字,重新选择...直到选择到0-39之间的数字

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /