我想要创建一个泛型随机变量,它的分布取决于某个条件,然后根据保留的分布生成一个随机变量序列。例如,
if (condition):
RV = np.random.normal
""" The above command will assign the standard normal distribution to RV.
I do not know how to assign the normal distribution with mean $m$ and variance sigma^2.
"""
else:
RV =
我试图用scipy.stats.rv_continuous对受给定概率密度函数约束的随机变量进行抽样:
class Distribution(stats.rv_continuous):
def _pdf(self,x, _a, _c):
return first_hitting_time(x, _a, _c)
函数first_hitting_time所在的位置
#pdf of first hitting time of W_t + c*t on a.
def first_hitting_time(_t, _a, _c=0.0):
return _a/_t*np
我最近开始用python.Everything做一个很漂亮的骰子游戏,直到now.My的问题是,当我尝试玩的时候,我赢了或者输了,或者下一次是相等的,它只会继续下去。
示例:
Enter name >> Sorin
Money = 2
Bet >> 2
You won!
Money 4
Bet >> 2
You won!
它像这样循环:/
Here is the code:
import time
import os
import random
os = os.system
os("clear")
print "What is y