In [43]:
import numpy as np
from scipy.stats import norm
from scipy.optimize import curve_fit
import matplotlib.pyplot as plt

# Beginning in one dimension:
# mean = 0; Var = 1; N = 100
# scatter = np.random.normal(mean,np.sqrt(Var),N)
# scatter = np.sort(scatter)
t = [189.6071000099182, 191.2862000465393, 191.9226999282837, 192.32009983062744, 194.59099984169006, 194.69189977645874, 194.81200003623962, 195.4136998653412, 195.8914999961853, 196.71169996261597, 196.78150010108948, 197.03410005569458, 197.1198000907898, 197.76399993896484, 197.80709981918335, 197.87769985198975, 197.9296998977661, 198.16470003128052, 198.34800004959106, 198.38380002975464, 198.55809998512268, 198.59619998931885, 198.60689997673035, 198.7994999885559, 198.8127999305725, 198.87769985198975, 198.8961000442505, 199.03090000152588, 199.06170010566711, 199.11590003967285, 199.11650013923645, 199.23480010032654, 199.26859998703003, 199.28539991378784, 199.28569984436035, 199.2901999950409, 199.30789995193481, 199.38619995117188, 199.4277000427246, 199.54820013046265, 199.60840010643005, 199.68470001220703, 199.79959988594055, 199.80520009994507, 199.87220001220703, 199.92110013961792, 199.93280005455017, 199.96449995040894, 200.02769994735718, 200.15759992599487, 200.176500082016, 200.29069995880127, 200.33640003204346, 200.42440009117126, 200.74760007858276, 200.76629996299744, 201.10800004005432, 201.36319994926453, 201.56420016288757, 201.64739990234375, 203.52499985694885, 203.7118000984192, 206.8543999195099, 208.2497000694275, 210.16980004310608, 211.22909998893738, 212.25820016860962, 213.3011999130249, 216.19820022583008, 218.5029001235962, 219.21879982948303, 219.2882001399994, 223.16790008544922, 226.58719992637634, 227.41970014572144, 228.24290013313293, 231.29270005226135, 231.67810010910034, 232.58859992027283, 233.24539995193481, 233.4776999950409, 235.769700050354, 237.4837999343872, 237.61409997940063, 240.57780003547668, 241.18440008163452, 241.85349988937378, 243.439199924469, 243.5006000995636, 243.57949995994568, 245.11009979248047, 246.33259987831116, 246.59170007705688, 247.40899991989136, 250.1579999923706, 250.61940002441406, 250.6965000629425, 251.95709991455078, 252.30920004844666, 252.87159991264343, 252.99370002746582, 253.6926999092102, 255.32419991493225, 258.3877999782562, 259.0522999763489, 259.2037000656128, 259.2242000102997, 259.83120012283325, 259.84759998321533, 259.9684000015259, 261.8134000301361, 263.59940004348755, 264.8375999927521, 267.7960000038147, 267.8507001399994, 268.83990001678467, 269.04620003700256, 269.05509996414185, 269.33240008354187, 269.5037000179291, 269.7397999763489, 270.90319991111755, 272.0377998352051, 272.0747001171112, 272.1542999744415, 272.35350012779236, 272.3550000190735, 272.668399810791, 272.90750002861023, 273.2815001010895, 274.6137001514435, 274.6651999950409, 275.06919980049133, 275.2734000682831, 275.6498999595642, 275.88120007514954, 276.1007001399994, 276.73189997673035, 277.02559995651245, 277.47670006752014, 277.8952000141144, 277.91939997673035, 278.1614000797272, 278.59540009498596, 279.251699924469, 279.6147999763489, 281.0438001155853, 281.07920002937317, 281.2242000102997, 282.16820001602173, 282.9784998893738, 282.9980001449585, 283.688099861145, 283.9584000110626, 284.77300000190735, 285.3097999095917, 285.9256000518799, 287.29639983177185, 287.6809000968933, 287.81550002098083, 288.0566999912262, 291.2125999927521, 291.46810007095337, 293.32620000839233, 293.80739998817444, 294.0341999530792, 295.0464999675751, 295.27039980888367, 297.28690004348755, 297.48359990119934, 297.68649983406067, 297.73920011520386, 298.1391999721527, 298.54929995536804, 299.3740999698639, 299.5074999332428, 299.67120003700256, 299.81270003318787, 299.9292998313904, 300.22179985046387, 300.3617000579834, 300.69840002059937, 300.88229990005493, 301.0942997932434, 301.24150013923645, 301.30570006370544, 301.33369994163513, 301.3472001552582, 301.38059997558594, 302.1319999694824, 302.18330001831055, 302.23539996147156, 302.3315999507904, 302.3568000793457, 302.36070013046265, 302.487900018692, 303.50329995155334, 304.3765001296997, 305.20849990844727, 305.25220012664795, 305.34370017051697, 305.4293999671936, 305.47379994392395, 306.4015998840332, 306.4570999145508, 306.7078001499176, 307.00709986686707, 307.1610999107361, 307.4059998989105, 307.5889000892639, 308.44840002059937, 308.5464999675751, 316.46250009536743, 316.74259996414185, 317.188099861145, 318.49349999427795, 318.5443000793457, 318.6096999645233, 318.9563000202179, 319.61789989471436, 320.3954999446869, 320.58780002593994, 321.634299993515, 322.1167998313904, 322.1172001361847, 322.1802999973297, 322.9318001270294, 324.82249999046326, 324.86469984054565, 325.91390013694763, 325.9948000907898, 326.1133999824524, 326.446799993515, 326.906800031662, 327.6143000125885, 328.6284999847412, 329.0639998912811, 329.90120005607605, 331.6512999534607, 332.80840015411377, 333.9262001514435, 334.44810009002686, 335.5722999572754, 335.6867001056671, 336.7762999534607, 337.8452000617981, 338.3204998970032, 338.96050000190735, 339.78570008277893, 340.2051000595093, 340.3507001399994, 341.5891001224518, 341.63809990882874, 343.3168001174927, 344.00020003318787, 344.0559000968933, 345.519700050354, 345.6105999946594, 345.7255001068115, 346.04819989204407, 346.0757999420166, 346.4703998565674, 346.9500000476837, 347.48970007896423, 347.68649983406067, 348.1500999927521, 348.50789999961853, 348.8159999847412, 348.81700015068054, 348.8840000629425, 348.93190002441406, 349.0747001171112, 349.1642999649048, 349.81089997291565, 349.93710017204285, 350.6523001194, 350.7711000442505, 351.79439997673035, 352.09860014915466, 352.18729996681213, 352.57480001449585, 352.7698998451233, 352.9992001056671, 353.12720012664795, 353.5209000110626, 354.969899892807, 355.66739988327026, 356.28539991378784, 357.6537001132965, 357.928200006485, 358.0456998348236, 358.2394998073578, 358.5462999343872, 359.0153999328613, 359.1082000732422, 359.7950999736786, 359.82130002975464, 360.8533000946045, 361.08629989624023, 361.47239995002747, 361.7726001739502, 362.0262999534607, 362.0757999420166, 362.17980003356934, 362.2457001209259, 362.2590000629425, 363.95120000839233, 364.4533998966217, 365.431599855423, 366.62080001831055, 367.0819001197815, 369.2527000904083, 370.7765998840332, 370.8450999259949, 371.5557999610901, 372.8712999820709, 374.1957998275757, 374.8885998725891, 379.8382000923157, 379.86250019073486, 381.678200006485, 381.7116000652313, 382.7015998363495, 383.42400002479553, 384.49149990081787, 385.81610012054443, 387.0953001976013, 389.61190009117126, 392.09999990463257, 393.84220004081726, 396.26430010795593, 396.2650001049042, 397.0871000289917, 397.08929991722107, 397.7426998615265, 398.1346001625061, 399.49410009384155, 399.5038001537323, 399.99399995803833, 400.6917998790741, 400.98969984054565, 403.94350004196167, 404.0395998954773, 404.59699988365173, 404.6835000514984, 405.4930000305176, 406.2351999282837, 406.46550011634827, 407.2270998954773, 408.00160002708435, 409.4976999759674, 412.1075999736786, 414.2595000267029, 414.36210012435913, 414.9379999637604, 416.5566999912262, 416.5749001502991, 416.5896999835968, 418.04209995269775, 418.6231999397278, 418.7039999961853, 419.20789980888367, 420.0859999656677, 420.2603998184204, 420.67400002479553, 421.7853000164032, 422.0877001285553, 425.32510018348694, 427.38650012016296, 427.88639998435974, 428.1428999900818, 428.926500082016, 429.20300006866455, 429.23849987983704, 430.73619985580444, 431.32559990882874, 432.56199979782104, 433.4599997997284, 434.61559987068176, 434.97499990463257, 435.97259998321533, 436.6355001926422, 437.95120000839233, 437.96429991722107, 439.66680002212524, 440.2565999031067, 441.78629994392395, 441.91820001602173, 442.3288998603821, 446.6708998680115, 448.87810015678406, 452.75, 453.41050004959106, 455.1205999851227, 456.0848000049591, 456.19320011138916, 456.9457998275757, 461.78250002861023, 464.80830001831055, 468.03509998321533, 468.634299993515, 468.94090008735657, 471.0374000072479, 473.3707001209259, 475.1545000076294, 475.7686998844147, 476.3066999912262, 476.5549998283386, 476.71939992904663, 476.84540009498596, 476.88560009002686, 477.498300075531, 477.7546000480652, 478.4089000225067, 478.62720012664795, 478.76550006866455, 478.78539991378784, 479.44370007514954, 480.10689997673035, 480.1270000934601, 480.9742999076843, 481.1449999809265, 481.41799998283386, 481.74210000038147, 482.376699924469, 483.3386001586914, 483.3827998638153, 484.023099899292, 484.02680015563965, 484.2613000869751, 484.28769993782043, 484.4710998535156, 484.57329988479614, 484.58179998397827, 485.16129994392395, 485.72640013694763, 486.674800157547, 487.82829999923706, 490.12739992141724, 490.1569998264313, 490.4675998687744, 491.092600107193, 491.3041000366211, 494.5938000679016, 495.1322000026703, 496.2479000091553, 496.26749992370605, 498.7243001461029, 501.0044000148773, 502.729199886322, 513.9409999847412, 514.3407998085022, 516.0920000076294, 520.3984999656677, 521.0588998794556, 542.6861999034882, 589.6159000396729, 601.6647000312805, 602.648600101471, 603.5119998455048, 615.537700176239, 625.2442998886108, 636.2081999778748, 673.241800069809]
scatter = np.array(t)
mu = np.mean(scatter)
Var = np.std(scatter, ddof=1)
N = len(scatter)
mu1,sigma1 = norm.fit(scatter) # classical fit

scat_sum = np.cumsum(np.ones(scatter.shape))/N # cumulative samples
[mu2,sigma2],Cx = curve_fit(norm.cdf, scatter, scat_sum, p0=[0,1]) # curve fit
print(u"norm.fit():  µ1= {:+.4f}, σ1={:.4f}".format(mu1, sigma1))
print(u"curve_fit(): µ2= {:+.4f}, σ2={:.4f}".format(mu2, sigma2))

t = np.linspace(min(scatter),max(scatter), len(scatter))
print t
print norm.cdf(t, mu1, sigma1)

fg = plt.figure(1); fg.clf()
ax = fg.add_subplot(1, 1, 1)
ax.plot(t, norm.cdf(t, mu1, sigma1), alpha=.5, label="norm.fit()")
ax.step(scatter, scat_sum, '-', where='post', alpha=.5, label="Samples")
ax.legend(loc="best")
ax.grid(True)
ax.set_xlabel("$x$")
ax.set_ylabel("Cumulative Probability Density")
ax.set_title("Fit to Normal Distribution")

fg.canvas.draw()
plt.show()


norm.fit():  µ1= +337.0038, σ1=98.0970
curve_fit(): µ2= +0.0000, σ2=1.0000
[ 189.60710001  190.6516674   191.69623478  192.74080217  193.78536956
  194.82993694  195.87450433  196.91907172  197.9636391   199.00820649
  200.05277388  201.09734126  202.14190865  203.18647604  204.23104342
  205.27561081  206.3201782   207.36474558  208.40931297  209.45388036
  210.49844774  211.54301513  212.58758252  213.6321499   214.67671729
  215.72128468  216.76585207  217.81041945  218.85498684  219.89955423
  220.94412161  221.988689    223.03325639  224.07782377  225.12239116
  226.16695855  227.21152593  228.25609332  229.30066071  230.34522809
  231.38979548  232.43436287  233.47893025  234.52349764  235.56806503
  236.61263241  237.6571998   238.70176719  239.74633457  240.79090196
  241.83546935  242.88003673  243.92460412  244.96917151  246.01373889
  247.05830628  248.10287367  249.14744105  250.19200844  251.23657583
  252.28114321  253.3257106   254.37027799  255.41484537  256.45941276
  257.50398015  258.54854753  259.59311492  260.63768231  261.68224969
  262.72681708  263.77138447  264.81595186  265.86051924  266.90508663
  267.94965402  268.9942214   270.03878879  271.08335618  272.12792356
  273.17249095  274.21705834  275.26162572  276.30619311  277.3507605
  278.39532788  279.43989527  280.48446266  281.52903004  282.57359743
  283.61816482  284.6627322   285.70729959  286.75186698  287.79643436
  288.84100175  289.88556914  290.93013652  291.97470391  293.0192713
  294.06383868  295.10840607  296.15297346  297.19754084  298.24210823
  299.28667562  300.331243    301.37581039  302.42037778  303.46494516
  304.50951255  305.55407994  306.59864732  307.64321471  308.6877821
  309.73234948  310.77691687  311.82148426  312.86605165  313.91061903
  314.95518642  315.99975381  317.04432119  318.08888858  319.13345597
  320.17802335  321.22259074  322.26715813  323.31172551  324.3562929
  325.40086029  326.44542767  327.48999506  328.53456245  329.57912983
  330.62369722  331.66826461  332.71283199  333.75739938  334.80196677
  335.84653415  336.89110154  337.93566893  338.98023631  340.0248037
  341.06937109  342.11393847  343.15850586  344.20307325  345.24764063
  346.29220802  347.33677541  348.38134279  349.42591018  350.47047757
  351.51504495  352.55961234  353.60417973  354.64874711  355.6933145
  356.73788189  357.78244927  358.82701666  359.87158405  360.91615144
  361.96071882  363.00528621  364.0498536   365.09442098  366.13898837
  367.18355576  368.22812314  369.27269053  370.31725792  371.3618253
  372.40639269  373.45096008  374.49552746  375.54009485  376.58466224
  377.62922962  378.67379701  379.7183644   380.76293178  381.80749917
  382.85206656  383.89663394  384.94120133  385.98576872  387.0303361
  388.07490349  389.11947088  390.16403826  391.20860565  392.25317304
  393.29774042  394.34230781  395.3868752   396.43144258  397.47600997
  398.52057736  399.56514474  400.60971213  401.65427952  402.6988469
  403.74341429  404.78798168  405.83254906  406.87711645  407.92168384
  408.96625122  410.01081861  411.055386    412.09995339  413.14452077
  414.18908816  415.23365555  416.27822293  417.32279032  418.36735771
  419.41192509  420.45649248  421.50105987  422.54562725  423.59019464
  424.63476203  425.67932941  426.7238968   427.76846419  428.81303157
  429.85759896  430.90216635  431.94673373  432.99130112  434.03586851
  435.08043589  436.12500328  437.16957067  438.21413805  439.25870544
  440.30327283  441.34784021  442.3924076   443.43697499  444.48154237
  445.52610976  446.57067715  447.61524453  448.65981192  449.70437931
  450.74894669  451.79351408  452.83808147  453.88264885  454.92721624
  455.97178363  457.01635101  458.0609184   459.10548579  460.15005318
  461.19462056  462.23918795  463.28375534  464.32832272  465.37289011
  466.4174575   467.46202488  468.50659227  469.55115966  470.59572704
  471.64029443  472.68486182  473.7294292   474.77399659  475.81856398
  476.86313136  477.90769875  478.95226614  479.99683352  481.04140091
  482.0859683   483.13053568  484.17510307  485.21967046  486.26423784
  487.30880523  488.35337262  489.39794     490.44250739  491.48707478
  492.53164216  493.57620955  494.62077694  495.66534432  496.70991171
  497.7544791   498.79904648  499.84361387  500.88818126  501.93274864
  502.97731603  504.02188342  505.0664508   506.11101819  507.15558558
  508.20015297  509.24472035  510.28928774  511.33385513  512.37842251
  513.4229899   514.46755729  515.51212467  516.55669206  517.60125945
  518.64582683  519.69039422  520.73496161  521.77952899  522.82409638
  523.86866377  524.91323115  525.95779854  527.00236593  528.04693331
  529.0915007   530.13606809  531.18063547  532.22520286  533.26977025
  534.31433763  535.35890502  536.40347241  537.44803979  538.49260718
  539.53717457  540.58174195  541.62630934  542.67087673  543.71544411
  544.7600115   545.80457889  546.84914627  547.89371366  548.93828105
  549.98284843  551.02741582  552.07198321  553.11655059  554.16111798
  555.20568537  556.25025276  557.29482014  558.33938753  559.38395492
  560.4285223   561.47308969  562.51765708  563.56222446  564.60679185
  565.65135924  566.69592662  567.74049401  568.7850614   569.82962878
  570.87419617  571.91876356  572.96333094  574.00789833  575.05246572
  576.0970331   577.14160049  578.18616788  579.23073526  580.27530265
  581.31987004  582.36443742  583.40900481  584.4535722   585.49813958
  586.54270697  587.58727436  588.63184174  589.67640913  590.72097652
  591.7655439   592.81011129  593.85467868  594.89924606  595.94381345
  596.98838084  598.03294822  599.07751561  600.122083    601.16665038
  602.21121777  603.25578516  604.30035255  605.34491993  606.38948732
  607.43405471  608.47862209  609.52318948  610.56775687  611.61232425
  612.65689164  613.70145903  614.74602641  615.7905938   616.83516119
  617.87972857  618.92429596  619.96886335  621.01343073  622.05799812
  623.10256551  624.14713289  625.19170028  626.23626767  627.28083505
  628.32540244  629.36996983  630.41453721  631.4591046   632.50367199
  633.54823937  634.59280676  635.63737415  636.68194153  637.72650892
  638.77107631  639.81564369  640.86021108  641.90477847  642.94934585
  643.99391324  645.03848063  646.08304801  647.1276154   648.17218279
  649.21675017  650.26131756  651.30588495  652.35045234  653.39501972
  654.43958711  655.4841545   656.52872188  657.57328927  658.61785666
  659.66242404  660.70699143  661.75155882  662.7961262   663.84069359
  664.88526098  665.92982836  666.97439575  668.01896314  669.06353052
  670.10809791  671.1526653   672.19723268  673.24180007]
[ 0.06647614  0.06786101  0.06926806  0.07069748  0.07214946  0.07362419
  0.07512186  0.07664264  0.07818673  0.07975429  0.08134552  0.08296058
  0.08459963  0.08626286  0.08795043  0.08966249  0.09139921  0.09316074
  0.09494723  0.09675884  0.0985957   0.10045796  0.10234576  0.10425922
  0.10619848  0.10816366  0.11015488  0.11217227  0.11421592  0.11628595
  0.11838247  0.12050556  0.12265532  0.12483185  0.12703521  0.1292655
  0.13152279  0.13380714  0.13611861  0.13845726  0.14082315  0.14321632
  0.1456368   0.14808464  0.15055987  0.15306249  0.15559254  0.15815001
  0.16073493  0.16334727  0.16598705  0.16865423  0.1713488   0.17407074
  0.17682001  0.17959656  0.18240035  0.18523134  0.18808945  0.19097462
  0.19388677  0.19682583  0.19979171  0.20278431  0.20580353  0.20884927
  0.2119214   0.2150198   0.21814435  0.22129491  0.22447133  0.22767347
  0.23090116  0.23415425  0.23743255  0.24073589  0.24406409  0.24741695
  0.25079427  0.25419584  0.25762145  0.26107087  0.26454389  0.26804026
  0.27155974  0.27510209  0.27866705  0.28225434  0.28586372  0.28949489
  0.29314759  0.29682151  0.30051636  0.30423185  0.30796765  0.31172347
  0.31549897  0.31929383  0.32310772  0.32694029  0.33079121  0.33466012
  0.33854666  0.34245047  0.34637119  0.35030844  0.35426184  0.35823102
  0.36221557  0.3662151   0.37022923  0.37425754  0.37829962  0.38235507
  0.38642346  0.39050437  0.39459739  0.39870207  0.40281799  0.4069447
  0.41108178  0.41522876  0.41938521  0.42355068  0.42772471  0.43190684
  0.43609662  0.44029358  0.44449726  0.4487072   0.45292291  0.45714394
  0.46136981  0.46560005  0.46983418  0.47407172  0.47831219  0.48255513
  0.48680004  0.49104644  0.49529386  0.49954182  0.50378982  0.5080374
  0.51228407  0.51652934  0.52077274  0.52501379  0.529252    0.53348691
  0.53771802  0.54194487  0.54616699  0.55038389  0.55459511  0.55880018
  0.56299863  0.56719     0.57137382  0.57554963  0.57971699  0.58387542
  0.58802449  0.59216374  0.59629273  0.60041101  0.60451815  0.60861372
  0.61269728  0.61676841  0.62082668  0.62487168  0.628903    0.63292022
  0.63692293  0.64091075  0.64488327  0.64884011  0.65278088  0.65670519
  0.66061268  0.66450298  0.66837573  0.67223055  0.67606711  0.67988506
  0.68368405  0.68746376  0.69122385  0.694964    0.69868389  0.70238322
  0.70606168  0.70971898  0.71335482  0.71696892  0.72056101  0.7241308
  0.72767805  0.73120249  0.73470386  0.73818194  0.74163647  0.74506724
  0.74847401  0.75185658  0.75521473  0.75854827  0.76185699  0.76514071
  0.76839924  0.77163243  0.77484009  0.77802207  0.78117822  0.7843084
  0.78741245  0.79049026  0.7935417   0.79656665  0.799565    0.80253665
  0.80548151  0.80839947  0.81129047  0.81415442  0.81699126  0.81980093
  0.82258336  0.82533852  0.82806635  0.83076683  0.83343992  0.83608561
  0.83870387  0.84129471  0.8438581   0.84639406  0.8489026   0.85138373
  0.85383748  0.85626386  0.85866292  0.86103469  0.86337921  0.86569654
  0.86798674  0.87024986  0.87248596  0.87469513  0.87687744  0.87903297
  0.88116181  0.88326405  0.88533978  0.88738912  0.88941216  0.89140901
  0.8933798   0.89532464  0.89724366  0.89913698  0.90100474  0.90284707
  0.90466411  0.90645601  0.90822291  0.90996497  0.91168234  0.91337517
  0.91504364  0.91668789  0.91830811  0.91990446  0.92147712  0.92302626
  0.92455205  0.92605469  0.92753435  0.92899122  0.93042549  0.93183735
  0.93322699  0.93459461  0.93594041  0.93726457  0.9385673   0.93984881
  0.94110929  0.94234896  0.943568    0.94476665  0.94594509  0.94710354
  0.94824221  0.94936131  0.95046105  0.95154165  0.95260331  0.95364626
  0.9546707   0.95567685  0.95666492  0.95763513  0.95858769  0.95952282
  0.96044074  0.96134165  0.96222577  0.96309333  0.96394452  0.96477957
  0.96559868  0.96640208  0.96718997  0.96796256  0.96872007  0.96946271
  0.97019068  0.9709042   0.97160347  0.9722887   0.97296009  0.97361786
  0.97426219  0.9748933   0.97551139  0.97611666  0.9767093   0.97728952
  0.9778575   0.97841345  0.97895756  0.97949002  0.98001102  0.98052074
  0.98101939  0.98150713  0.98198416  0.98245066  0.98290681  0.98335278
  0.98378877  0.98421493  0.98463145  0.98503849  0.98543624  0.98582485
  0.98620449  0.98657533  0.98693753  0.98729126  0.98763666  0.9879739
  0.98830314  0.98862453  0.98893821  0.98924434  0.98954307  0.98983455
  0.99011891  0.9903963   0.99066686  0.99093073  0.99118804  0.99143893
  0.99168353  0.99192197  0.99215438  0.99238089  0.99260163  0.9928167
  0.99302625  0.99323038  0.99342921  0.99362286  0.99381144  0.99399506
  0.99417384  0.99434788  0.99451729  0.99468217  0.99484263  0.99499877
  0.99515068  0.99529846  0.99544221  0.99558203  0.995718    0.99585022
  0.99597877  0.99610375  0.99622523  0.99634331  0.99645806  0.99656957
  0.99667792  0.99678318  0.99688542  0.99698474  0.99708119  0.99717485
  0.99726579  0.99735408  0.99743979  0.99752298  0.99760372  0.99768207
  0.99775809  0.99783184  0.99790339  0.99797279  0.9980401   0.99810538
  0.99816867  0.99823003  0.99828952  0.99834718  0.99840306  0.99845722
  0.9985097   0.99856054  0.9986098   0.99865751  0.99870373  0.99874848
  0.99879181  0.99883377  0.99887439  0.99891371  0.99895177  0.9989886
  0.99902424  0.99905872  0.99909208  0.99912435  0.99915556  0.99918575
  0.99921494  0.99924316  0.99927045  0.99929683  0.99932233  0.99934697
  0.99937078  0.99939378  0.99941601  0.99943749  0.99945823  0.99947826
  0.9994976   0.99951628  0.99953432  0.99955172  0.99956853  0.99958475
  0.9996004   0.9996155   0.99963007  0.99964413  0.99965769  0.99967077
  0.99968338  0.99969554]

In [37]:
fg = plt.figure(1); fg.clf()
ax = fg.add_subplot(1, 1, 1)
t = np.linspace(min(scatter),max(scatter), len(scatter))
# ax.plot(t, norm.cdf(t, mu1, sigma1), alpha=.5, label="norm.fit()")
ax.plot(t, norm.cdf(t, mu2, sigma2), alpha=.5, label="curve_fit()")
ax.legend(loc="best")
ax.grid(True)
ax.set_xlabel("$x$")
ax.set_ylabel("Cumulative Probability Density")
ax.set_title("Fit to Normal Distribution")


fg.canvas.draw()
plt.show()



In [63]:
%matplotlib inline

import random
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import scipy.stats  as stats

def measures_of_center(durations):
    m = {}
    m['mu']     = np.mean(durations)
    m['sem']    = stats.sem(durations)
    m['median'] = np.median(durations)
    m['mode']   = stats.mstats.mode(durations)

    return m


rolls = []
for i in range(10000):
    roll = random.choice([1,2,3,4,5,6])
    rolls.append(roll)

# pd.DataFrame(rolls).plot(kind="density",  # Plot the distribution
#                                figsize=(9,9),
#                                xlim=(-1,7))

# stats.uniform.cdf(x=6,         # Cutoff value (quantile) to check
#                   loc=1,         # Distribution start
#                   scale=6)      # Distribution end

mrolls = measures_of_center(rolls)

print mrolls

plt.hist(rolls, bins='fd', normed=1)


{'mu': 3.4662999999999999, 'sem': 0.017081440470898702, 'median': 3.0, 'mode': ModeResult(mode=array([ 2.]), count=array([ 1747.]))}
Out[63]:
(array([ 0.60732,  0.     ,  0.     ,  0.62892,  0.     ,  0.     ,
         0.     ,  0.60876,  0.     ,  0.     ,  0.57312,  0.     ,
         0.     ,  0.     ,  0.59652,  0.     ,  0.     ,  0.58536]),
 array([ 1.        ,  1.27777778,  1.55555556,  1.83333333,  2.11111111,
         2.38888889,  2.66666667,  2.94444444,  3.22222222,  3.5       ,
         3.77777778,  4.05555556,  4.33333333,  4.61111111,  4.88888889,
         5.16666667,  5.44444444,  5.72222222,  6.        ]),
 <a list of 18 Patch objects>)

In [ ]: