Skip to content
Advertisement

Tag: random

Recommendations for Low Discrepancy (e.g. Sobol) quasi-random sequences in Python/SciPy?

I would like to use a quasi-random sequence, specifically Sobol, within a SciPy based simulation. Any recommendations on existing, efficient packages? Answer I would use OpenTURNS, which provides several low discrepancy sequences: Faure sequence, Halton sequence, Reverse Halton sequence, Haselgrove sequence, Sobol sequence. Moreover, the sequence can be generated so that the marginals have arbitrary distribution. This is done with

Shuffling a list of objects

How do I shuffle a list of objects? I tried random.shuffle: But it outputs: Answer random.shuffle should work. Here’s an example, where the objects are lists: Note that shuffle works in place, and returns None. More generally in Python, mutable objects can be passed into functions, and when a function mutates those objects, the standard is to return None (rather

How do I simulate flip of biased coin?

In unbiased coin flip H or T occurs 50% of times. But I want to simulate coin which gives H with probability ‘p’ and T with probability ‘(1-p)’. something like this: Answer random.random() returns a uniformly distributed pseudo-random floating point number in the range [0, 1). This number is less than a given number p in the range [0,1) with

Advertisement