scala - 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)
}
}
什么是n
和meanLog
?meanLog1
解决方案
这些是足够的统计数据。在指数族中,最大似然估计仅通过充分统计的经验平均值依赖于数据。对于 beta 系列,充分的统计量是log(x)
和log(1-x)
。 meanLog
是和的meanLog1
样本平均值。是样本量,不直接进入MLE估计。它在包中用于组合两组充分的统计信息。log(x)
log(1-x)
n
推荐阅读
- java - EditText 无法将文本设置为格式化字符串
- ruby-on-rails - 我无法执行 rake db:migrate - Unexpected ':'
- javafx - 如何绑定到 JavaFX 中的 ObservableMap 中的属性?
- sql - 在 DB2 中将 CHAR 插入 DATE
- c++ - shrink_to_fit() 函数会删除空指针吗?
- javascript - Tesseract 中的特定信息
- javascript - 变量为空时的 v-bind
- r - 如何从 R 中宽格式数据的多列中选择具有 NA 的多个答案中的最后一个响应
- c++ - 结构的大小 - 填充和对齐
- azure - 无法在免费试用帐户下在 Azure 中设置 VM 的大小