Models - type 1: each team t=1..T has a potential a[t]; when two teams are playing each other, the probability that team t1 gets the next point is exp(a[t1])/(exp(a[t1])+exp(a[t2])) ss->logprior = 0.0 ; for ( i = 1 ; i <= ss->k ; i++ ) ss->logprior -= x[i]*x[i]* ss->priorfactor ; /* run through games */ for ( g = 1 ; g <= ss->G ; g ++ ) { t1 = s[g][1] ; a1=a[t1] ; s1 = (double) s[g][2] ; t2 = s[g][3] ; a2=a[t2] ; s2 = (double) s[g][4] ; if ( ss->weighted ) { w = ss->w[g] ; s1 *= w ; s2 *= w ; } lz[g] = logz ( a1 , a2 ) ; /* lz = log ( exp(a1) + exp(a2) ) */ f += s1 * a1 + s2 * a2 - ( s1 + s2 ) * lz[g] ; } ss->loglike = f ; f += ss->logprior ;