This file contains 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
#!/usr/bin/env ruby | |
#生成 10_000 个呈正态分布的范围在0-4之间的随机数 | |
#计算他们的平均值 | |
#从中随机抽取100个数 | |
#通过有放回重抽法尝试 10_000 次 | |
#每次抽 100 个数 | |
#计算这100个数的平均值 | |
#计算这 10_000 次的平均值 |
This file contains 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
#!/usr/bin/env ruby | |
class BSST | |
def initialize(capacity = 2) | |
@keys = Array.new(capacity) | |
@vals = Array.new(capacity) | |
@n = 0 | |
end | |
def is_empty? | |
@n == 0 |
NewerOlder