Python random 模块,paretovariate() 实例源码

我们从Python开源项目中,提取了以下4个代码示例,用于说明如何使用random.paretovariate()

项目:zippy    作者:securesystemslab    | 项目源码 | 文件源码
def sample(self):
        return random.paretovariate(self.alpha)
项目:Python-iBeacon-Scan    作者:NikNitro    | 项目源码 | 文件源码
def sample(self):
        return random.paretovariate(self.alpha)
项目:HyperStream    作者:IRC-SPHERE    | 项目源码 | 文件源码
def _execute(self, sources, alignment_stream, interval):
        if alignment_stream is None:
            raise ToolExecutionError("Alignment stream expected")

        for ti, _ in alignment_stream.window(interval, force_calculation=True):
            yield StreamInstance(ti, random.paretovariate(alpha=self.alpha))
项目:shellcraft    作者:maebert    | 项目源码 | 文件源码
def _resource_pr(self, resource, x, y, distance, deposit):
        seed("{}.{}".format(x, y))
        if resource == 'clay':
            v = paretovariate(2) / (distance + 1)
            return v if v > .2 else 0
        if resource == 'elevation':
            return paretovariate(4) / (distance + 1)
        if resource == 'ore':
            dx, dy, dr = deposit
            angle = math.atan2(dy - y, dx - x) % math.pi
            diff = .5 / (angle - dr + .5)
            v = paretovariate(2) / (distance + 1) * diff
            return v if v > .4 else 0