[R] Sth better than cycle?

Ott Toomet otoomet at econ.dk
Mon Dec 9 11:51:03 CET 2002


Hi,

I want to calculate expected likelihood over a 2D discrete
distribution, something like

\sum_k \sum_l p_{kl} L(v_k, v_l)

It is trivial to write a cycle like

for(k in 1:K)
   for(l in 1:L)
      sum <- sum + p[k,l]*L(v[k], v[l])

But is there a more clever way for R?

Best wishes,

Ott




More information about the R-help mailing list