首页 > 解决方案 > Scala Breeze Beta分布参数估计

问题描述

我正在尝试将我的数据(CTR(双)值列表)拟合到 beta 分布并估计 alpha 和 beta 形状参数。我发现我可以使用 breeza 库的 mle 方法这样做,但我不明白调用 mle 方法所需的参数:-

object Beta extends ExponentialFamily[Beta,Double] with ContinuousDistributionUFuncProvider[Double,Beta] {
  type Parameter = (Double,Double)
  case class SufficientStatistic(n: Double, meanLog: Double, meanLog1M: Double) extends distributions.SufficientStatistic[SufficientStatistic]  {
    def *(weight: Double) = SufficientStatistic(n*weight,meanLog, meanLog1M)
    def +(t: SufficientStatistic) = {
      val delta = t.meanLog - meanLog
      val newMeanLog = meanLog + delta * (t.n /(t.n + n))
      val logDelta = t.meanLog1M - meanLog1M
      val newMeanLog1M = meanLog1M + logDelta * (t.n /(t.n + n))
      SufficientStatistic(n+t.n, newMeanLog, newMeanLog1M)
    }
  }

什么是nmeanLogmeanLog1

标签: scala

解决方案


这些是足够的统计数据。在指数族中,最大似然估计仅通过充分统计的经验平均值依赖于数据。对于 beta 系列,充分的统计量是log(x)log(1-x)meanLog是和的meanLog1样本平均值。是样本量,不直接进入MLE估计。它在包中用于组合两组充分的统计信息。log(x)log(1-x)n


推荐阅读