Scala-Breeze-Beta分布参数估计
我正在尝试将我的数据(CTR(双)值列表)拟合到beta分布,并估计alpha和beta形状参数。我发现我可以使用breeza库的mle方法来实现这一点,但我不理解调用mle方法所需的参数:-Scala-Breeze-Beta分布参数估计,scala,Scala,我正在尝试将我的数据(CTR(双)值列表)拟合到beta分布,并估计alpha和beta形状参数。我发现我可以使用breeza库的mle方法来实现这一点,但我不理解调用mle方法所需的参数:- object Beta extends ExponentialFamily[Beta,Double] with ContinuousDistributionUFuncProvider[Double,Beta] { type Parameter = (Double,Double) case clas
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
是log(x)
和log(1-x)
的样本平均值n
是样本量,它不直接输入MLE估计。包中使用它来组合两组足够的统计数据。是否有其他方法使用beta-MLE方法。是否有其他方法使用beta-MLE方法。比如说private Tuple2 getBetaPriorParameters(List ctrs){Beta.SufficientStatistic SufficientStatistic=Beta.emptySufficientStatistic();for(Double-ctr:ctrs){SufficientStatistic=SufficientStatistic.$plus(Beta.sufficientStatisticFor(ctr));}返回Beta.mle(SufficientStatistic);}
似乎您正在将聚合添加到mle方法中。这应该很好,但可以通过先聚合,然后传递Beta.mle(Beta.sulficientstatistic(1,meanLog,meanLog1m))来实现。您能帮我提供准确的代码吗?我对scala没有足够的经验