Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

_@_______

Name: Anonymous 2007-09-14 9:38 ID:26iR3rAD

we have a drunk person, who is standing one step away from falling from the cliff


       _@_______
      |

@ is person


probability of him making a step left (towards cliff) is p; right - q=1-p. He's one step away, so one step left and he dies.

for any p find the probability of him dying after n steps

This is not homework, I already did this with perl
#!/usr/bin/perl
use strict;
my $steps=eval shift or die;

sub step($$){
    my($loc,$left)=@_;
    return
        step(($loc or return 1)-1,($left or return 0)-1)*$_+
        step($loc+1,$left-1)*(1-$_);
}

printf "%.2f\t%s\n",$_,step 1,$steps foreach map{$_/100}0..100;

Name: Anonymous 2007-09-14 12:12 ID:Q0LE9lIe

OP here! Personally, I'd never use Binom(p,n), cause I'm stupid.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List