>>> exec(open('5YourName.py').read()) >>> y = Drv([25, 33, 40, 50], [1/4]*4 ) >>> y.xk [25, 33, 40, 50] >>> y.pk [0.25, 0.25, 0.25, 0.25] >>> y Discrete random variable: (25,0.25) (33,0.25) (40,0.25) (50,0.25) >>> y.e() 37.0 >>> x = y.reweight() >>> x Discrete random variable: (25,0.16891891891891891) (33,0.22297297297297297) (40,0.2702702702702703) (50,0.33783783783783783) >>> x.cdf(42) 0.6621621621621622 >>> x.cdf(52) 1.0 >>> b = Binomial(11, .5) >>> b.cdf(6) 0.5 >>> b Binomial random variable: (0,0.00048828125) (1,0.00537109375) (2,0.02685546875) (3,0.08056640625) (4,0.1611328125) (5,0.2255859375) (6,0.2255859375) (7,0.1611328125) (8,0.08056640625) (9,0.02685546875) ... >>> b.cdf(0) 0 >>> b.cdf(1) 0.00048828125 >>> b.pdf(0) 0.00048828125 >>> br = b.reweight() >>> br Discrete random variable: (0,0.0) (1,0.0009765625) (2,0.009765625) (3,0.0439453125) (4,0.1171875) (5,0.205078125) (6,0.24609375) (7,0.205078125) (8,0.1171875) (9,0.0439453125) ... >>> z = Uniform(3) >>> z Uniform random variable: (1,0.3333333333333333) (2,0.3333333333333333) (3,0.3333333333333333) >>> z.e() 2.0 >>> z.pdf(2) 0.3333333333333333 >>> z.cdf(3) 0.6666666666666666 >>> z.cdf(4) 1.0
discrete.py
.
Use the
skeleton
file. You
may load your code into an interactive section with the next
commands.
exec(open("discrete.py").read())
After this, you may test your code as it is shown above.