这是我的代码:
import scipy.stats as st
import numpy as np
from scipy import stats
xk = (30, 20, 50)
pk = (0.30, 0.2, 0.5)
custm = stats.rv_discrete(name='custm', values=(xk, pk))
X = np.random.random((100,3))
## Map back into the specified distribution by inverting the CDF
X[:, 0] = st.norm.ppf(X[:, 0], 5,2)
X[:, 1] = st.lognorm.ppf(X[:, 1], 6,1)
##This following line does not work
X[:, 2] = st.rv_discrete.ppf(X[:, 2], values=(xk, pk))
当我运行上面的代码时,出现此错误:
TypeError: ppf() missing 1 required positional argument: 'q'
你想在实例上调用.ppf,即 在您的示例中custm.ppf
。