Skip to content

Instantly share code, notes, and snippets.

@bollwyvl
Created April 21, 2010 14:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bollwyvl/373907 to your computer and use it in GitHub Desktop.
Save bollwyvl/373907 to your computer and use it in GitHub Desktop.
from pylab import *
'''
COST_MONTE_CARLO performs a Monte Carlo simulation of total mission cost
Costs are given in $M
pmse = Project Management/System Engineering
fs = Flight System
inst = Instruments
mos = Mission Operations System
nt = New Technology
epo = Education & Public Outreach
lv = Launch Vehicle
For Gaussian distributions, provide mean and 1-sigma values
For Uniform distributions, provide the min and max range
For Fixed values, provide the fixed value
pmse - Gaussian
fs - Gaussian
inst - Gaussian
mos - Gaussian
nt - Uniform
epo - Fixed
lv - Fixed
'''
pmse_mean = 34
pmse_sig = 2
fs_mean = 120
fs_sig = 10
inst_mean = 62
inst_sig = 5
mos_mean = 27
mos_sig = 2
nt_min = 10
nt_max = 20
epo = 3
lv = 156
fid = open('cost_mc_out', 'a')
fid.write(' PMSE FS INST MOS NT EPO LV TOTAL\n')
for i in range(2000):
pmse = pmse_mean + pmse_sig*randn()
fs = fs_mean + fs_sig*randn()
inst = inst_mean + inst_sig*randn()
mos = mos_mean + mos_sig*randn()
nt = nt_min + (nt_max - nt_min)*rand()
total_cost = pmse+fs+inst+mos+nt+epo+lv
fid.write('%8.5f %8.5f %8.5f %8.5f %8.5f %8.5f %8.5f %8.5f\n' % (pmse,fs,inst,mos,nt,epo,lv,total_cost));
fid.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment