Beefy Boxes and Bandwidth Generously Provided by pair Networks Bob
Welcome to the Monastery
 
PerlMonks  

Re: recursive formula.

by BrowserUk (Patriarch)
on Aug 06, 2004 at 02:02 UTC ( [id://380456]=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.

What should the result be for P( 1, 1, 1 )?

My interpretation is that each term will be: P( 1 - 1 )P( ... )

Which as 1 - 1 will always be zero, the results of the multiplication is zero, so the overall results will be zero?

If this is the case, then herveus' solution is incorrect as given input of ( 1, 1, 1 ), he returns 1.

If I'm correct, of which there is no guarentee, then I think that the problem lies with his simple expedient of prefixing the list with a 0 to get around the "indices starting from 1" problem, which is causing the function to iterate and recurse once too often.


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

Replies are listed 'Best First'.
Re^2: recursive formula.
by rsteinke (Scribe) on Aug 06, 2004 at 21:00 UTC
    You forget that r_0 is always zero, so
    P(1, 1, 1) = (1 - 1) P(1, 1) + (1 - 1) P(1, 1) + (1 - 0) P(1, 1) = P(1, 1) = P(1) = 1
    Ron Steinke rsteinke@w-link.net

      Thanks. That's the source of my misunderstanding. I saw the r0 = 0 reference, but I also saw r running 1 .. n and i running 1 to n.

      I missed that n-i = 0 whenever n=i. Stupid.


      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://380456]
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.