Update: THIS IS A WRONG IMPLEMENTATION. PLease don't++ it!! Thanks, buk.

I'm getting different results from other people, so this is probably wrong, but then maybe not, so...

#! perl -slw use strict; use List::Util qw[ reduce ]; $a = $a; ## Disable the dumbest warning in perl! my @samples = ( ## r1 r2 r3 [ qw[ 0.11 0.07 0.19 ] ], [ qw[ 0.43 0.31 0.37 ] ], [ qw[ 0.93 0.78 0.82 ] ], [ qw[ 0.91 0.12 0.15 ] ], [ qw[ 0.52 0.18 0.32 ] ], ); sub P{ return 1 if @_ == 1; my @r = @_; return reduce { $a + ( $r[ $b ] - $r[ $b - 1 ] ) * P( @r[ 0 .. ( $#r - $b ) ] + ) } 0 .. $#r; } my @results = map P( @$_ ), @samples; print "@results"; __END__ P:\test>380259 0.1216 0.0744 0.0624999999999999 0.6541 0.2556

Examine what is said, not who speaks.
"Efficiency is intelligent laziness." -David Dunham
"Think for yourself!" - Abigail
"Memory, processor, disk in that order on the hardware side. Algorithm, algorithm, algorithm on the code side." - tachyon

In reply to Re: recursive formula. by BrowserUk
in thread 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":