0

したがって、アルファのベクトルが 1 つ、ベータのベクトルが 1 つあり、すべての推定値 (アルファの i から n およびベータの i から n) の合計が 60 になるときのシータを見つけようとしています。

math.exp(alpha[i] * (theta - beta[i])) / (1 + math.exp(alpha[i] * (theta - beta[i])

ここに画像の説明を入力

基本的に私がしたことは、theta = 0.0001 から開始し、これらすべての合計を計算して反復し、60 未満の場合は毎回 0.0001 を追加して続行し、60 を超えることを意味します。

この方法でシータの値を見つけました。問題は、Python を使用して 0.456 のシータを見つけるのに約 60 秒かかったということです。

このシータを見つけるためのより迅速なアプローチは何ですか (これを他のデータに適用したいため)?

def CalcTheta(score, alpha, beta):
    theta = 0.0001
    estimate = [score-1]

    while(sum(estimate) < score):

        theta += 0.00001

        for x in range(len(beta)):
            if x == 0:
                estimate = []

            estimate.append(math.exp(alpha[x] * (theta - beta[x]))  / (1 +  math.exp(alpha[x] * (theta - beta[x]))))

    return(theta)
4

1 に答える 1

1

zipと を使用しsumて、ターゲット関数を計算できます。

  def f(theta):
    return sum(1/(1 + exp(a*(b-theta)))) for a,b in zip(alpha, beta))
于 2013-03-18T15:58:29.973 に答える