Skip to content

Instantly share code, notes, and snippets.

Created October 8, 2012 20:11
Show Gist options
  • Save anonymous/3854656 to your computer and use it in GitHub Desktop.
Save anonymous/3854656 to your computer and use it in GitHub Desktop.
Simple Bayesian estimate of Falcon 9 total failure probability
#! /usr/bin/env perl
use strict;
use warnings;
my %observed;
my %failure;
my $total_observed = 0;
my $n = 10000;
for my $i (0..$n) {
my $x = $i/$n;
$failure{$x} = probability_of_failure($x);
my $o = probability_of_observation($x);
$observed{$x} = $o;
$total_observed += $o;
}
my $total_failure = 0;
for my $x (keys %observed) {
$total_failure += $failure{$x} * $observed{$x} / $total_observed;
}
print "Estimated failure rate: $total_failure\n";
sub probability_of_observation {
my $x = shift;
return $x**35 * (1-$x) * 36;
}
sub probability_of_failure {
my $x = shift;
return 1 - $x**9 - $x**8 * (1-$x) * 9 - $x**7 * (1-$x)**2 * 36;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment