Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
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