Beefy Boxes and Bandwidth Generously Provided by pair Networks Bob
Think about Loose Coupling
 
PerlMonks  

Re: recursive formula.

by BrowserUk (Patriarch)
on Aug 05, 2004 at 11:41 UTC ( [id://380298]=note: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.


in reply to recursive formula.

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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://380298]
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.