【问题标题】:Python Equivelent of R BetaExpert functionR BetaExpert 函数的 Python 等效项
【发布时间】:2018-11-10 18:26:39
【问题描述】:

是否有任何 Python 库提供 R 中的 BetaExpert 函数的等效项? (https://rdrr.io/cran/prevalence/man/betaExpert.html)

这样做的目的是让您给出专家意见(即 90% 确定它大于 0.7,很可能是 0.9)并输出涵盖此问题的 Beta 分布的 alpha/beta 参数。

scipy.stats.beta 和 numpy.random.beta 有各种各样的功能,但我找不到上面的 R 功能。

谢谢, 广东

【问题讨论】:

    标签: python numpy scipy


    【解决方案1】:

    https://www.codeproject.com/Articles/56371/Finding-Probability-Distribution-Parameters-from-P 给出了解决方案

    from scipy import stats, optimize
    def beta_parameters(x1, p1, x2, p2):
        "Find parameters for a beta random variable X so that P(X > x1) = p1 and P(X > x2) = p2."
    
        def square(x): 
            return x*x
    
        def objective(v):
            (a, b) = v
            temp  = square( stats.beta.cdf(x1, a, b) - p1 )
            temp += square( stats.beta.cdf(x2, a, b) - p2 )
            return temp
    
        # arbitrary initial guess of (3, 3) for parameters
        xopt = optimize.fmin(objective, (3, 3))
        return (xopt[0], xopt[1])   
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-04-13
      • 1970-01-01
      • 1970-01-01
      • 2020-03-18
      • 2019-02-09
      • 1970-01-01
      • 2019-10-04
      相关资源
      最近更新 更多