I'm trying to implement the following recursive formula in Perl:
''''''''''''''''''''''''''''''''''''n
P(r1,r2,...,rn) = Σ(rn-i+1 - rn-i)P(r1,r2,...,rn-i,rn-i+2,...,rn)
'''''''''''''''''''''''''''''''''''i=1

(if this doesn't render well, it is the second formula on this page),
where r0=0 and the recursive call to P supplies all of the original arguments except the (n‑i+1)th argument.
I've looked at Math::Sequence and Math::Series, but the examples given there are only for simple cases like
x(n+1) = 1 / (xn + 1)
and I'm a bit lost on how to implement this formula.

As sample data you can use:
r1 0,11 0,43 0,93 0,91 0,52
r2 0,07 0,31 0,78 0,12 0,18
r3 0,19 0,37 0,82 0,15 0,32

(which should give 5 P(r1,r2,...,rn)-values)


Update: I've tried to work out a litlle example of the algorithm myself (but correct me If I'm doing something wrong).
P(r1,r2,r3)= (r3 - r2)P(r1,r2) + (r2 - r1)P(r1,r3) + (r1 - r0)P(r2,r3)

Now the iteration comes into play, because to calculate the P-values in the rigth hand side of the formula, we use our original formula again.
P(r1,r2) = (r2 - r1)P(r1) + (r1 - r0)P(r2)
P(r1,r3) = (r3 - r1)P(r1) + (r1 - r0)P(r3)
P(r2,r3) = (r3 - r2)P(r2) + (r2 - r0)P(r3)

Update: the r-values are scores, and P is a probability:
so P(r1) is the chance of having score r1,
P(r1,r2) is the chance of both having score r1 and score r2,
and so on.

In reply to recursive formula. by BioGeek

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.