In [1]:
%pylab inline
import matplotlib
import seaborn as sns
PAPER_PRESET = {"style": "ticks", "font": "Helvetica", "context": "paper", 
                "rc": {"font.size":20,"axes.titlesize":22,
                       "axes.labelsize":22, 'axes.linewidth': 2,
                       "legend.fontsize":20, "xtick.labelsize": 20,
                       "ytick.labelsize":20, "xtick.major.size": 8.0,
                       "ytick.major.size": 8.0, "axes.edgecolor": "black",
                       "xtick.major.pad": 3.0, "ytick.major.pad": 3.0}}
PAPER_FONTSIZE = 20
sns.set(**PAPER_PRESET)
fontsize = PAPER_FONTSIZE
matplotlib.rcParams['pdf.fonttype'] = 42
matplotlib.rcParams['ps.fonttype'] = 42


Bad key "text.kerning_factor" on line 4 in
/home/cmb-06/as/skchoudh/software_frozen/anaconda37/lib/python3.7/site-packages/matplotlib/mpl-data/stylelib/_classic_test_patch.mplstyle.
You probably need to get an updated matplotlibrc file from
http://github.com/matplotlib/matplotlib/blob/master/matplotlibrc.template
or from the matplotlib source distribution
Populating the interactive namespace from numpy and matplotlib

In [7]:
alpha = 0.05

def probability_of_error(alpha, n):
    return 1-(1-alpha)**n

number_of_tests = np.arange(1, 1000)
p_errors = list(map(lambda n: probability_of_error(alpha, n), number_of_tests))
n_errors = list(map(lambda n,error: n*error, number_of_tests, p_errors))

In [8]:
n_errors


Out[8]:
[0.050000000000000044,
 0.19500000000000006,
 0.42787500000000034,
 0.7419750000000005,
 1.1310953125000012,
 1.5894486562500012,
 2.111638927343752,
 2.692636549687502,
 3.3277553124785184,
 4.012630607616213,
 4.743198984958943,
 5.51567894804836,
 6.326552917366437,
 7.172550292382587,
 8.050631547603704,
 8.957973301571755,
 9.891954301273989,
 10.850142267752073,
 11.830281551829163,
 12.830281551829161,
 13.84820584794959,
 14.882262010578401,
 15.930792042324457,
 16.992263415869463,
 18.065260671954157,
 19.148477543890706,
 20.240709576953716,
 21.3408472128507,
 22.4478693112156,
 23.56083708171188,
 24.6788884018805,
 25.801232497327973,
 26.927144962226,
 28.0559630993909,
 29.18708156043375,
 30.319948267623836,
 31.45406060019383,
 32.58896182883776,
 33.72423778311682,
 34.85951373739588,
 35.994451501789236,
 37.12874670539976,
 38.26212625989477,
 39.39434599217678,
 40.52518843558085,
 41.65446076966407,
 42.781992899250014,
 43.9076356639532,
 45.031259169937954,
 46.15275123616434,
 47.27201594784325,
 48.38897231026385,
 49.503552996572786,
 50.61570318347517,
 51.725379469195886,
 52.832548868385835,
 53.937187878983806,
 55.039281616351005,
 56.138823010284035,
 57.235812060782884,
 58.33025514870614,
 59.42216439768511,
 60.51155708389441,
 61.59845509048858,
 62.68288440371359,
 63.764874647889876,
 64.84445865663925,
 65.92167207789396,
 66.9965530103816,
 68.06914166942575,
 69.13948008003953,
 70.20761179541836,
 71.27358163905922,
 72.33743546884743,
 73.39921996155918,
 74.45898241632764,
 75.51677057571536,
 76.57263246312348,
 77.6266162353515,
 78.67877004919892,
 79.72914194107321,
 80.77777971863706,
 81.82473086359187,
 82.87004244475459,
 83.91376104064206,
 84.9559326708289,
 85.99660273539544,
 87.03581596182828,
 88.07361635877932,
 89.11004717613069,
 90.14515087084999,
 91.17896907815702,
 92.21154258755622,
 93.24291132332012,
 94.27311432903873,
 95.30218975587718,
 96.33017485420919,
 97.3571059683183,
 98.38301853388099,
 99.4079470779666,
 100.43192522130896,
 101.45498568262215,
 102.47716028475077,
 103.49847996245995,
 104.51897477168635,
 105.53867390008395,
 106.55760567871259,
 107.57579759472814,
 108.59327630494536,
 109.61006765015404,
 110.6261966700795,
 111.641687618887,
 112.65656398113858,
 113.67084848811777,
 114.6845631344462,
 115.69772919492148,
 116.71036724151313,
 117.7224971604583,
 118.73413816940518,
 119.74530883455621,
 120.75602708776864,
 121.76631024357343,
 122.77617501607833,
 123.7856375357238,
 124.79471336586452,
 125.80341751915188,
 126.81176447369582,
 127.8197681889875,
 128.82744212156575,
 129.83479924041373,
 130.841852042073,
 131.8486125654653,
 132.85509240641318,
 133.86130273185262,
 134.86725429373206,
 135.87295744259396,
 136.8784221408353,
 137.88365797564606,
 138.88867417162365,
 139.89347960306435,
 140.89808280593192,
 141.90249198950508,
 142.9067150477061,
 143.91075957011324,
 144.91463285266042,
 145.91834190802757,
 146.9218934757264,
 147.92529403188524,
 148.92854979873889,
 149.93166675382744,
 150.9346506389103,
 151.93750696860033,
 152.94024103872405,
 153.94285793441392,
 154.945362537938,
 155.94775953627362,
 156.95005342843083,
 157.95224853253166,
 158.9543489926513,
 159.95635878542765,
 160.95828172644477,
 161.96012147639658,
 162.96188154703708,
 163.96356530692256,
 164.9651759869519,
 165.966716685711,
 166.9681903746268,
 167.96959990293675,
 168.97094800247916,
 169.97223729230996,
 170.97347028315147,
 171.9746493816781,
 172.97577689464416,
 173.97685503285942,
 174.97788591501651,
 175.9788715713758,
 176.97981394731158,
 177.98071490672535,
 178.9815762353295,
 179.98239964380636,
 180.98318677084725,
 181.98393918607454,
 182.98465839285197,
 183.9853458309865,
 184.98600287932538,
 185.98663085825297,
 186.98723103208945,
 187.98780461139665,
 188.98835275519292,
 189.9888765730811,
 190.98937712729244,
 191.98985543464994,
 192.99031246845348,
 193.99074916029002,
 194.99116640177178,
 195.99156504620467,
 196.9919459101898,
 197.99230977516092,
 198.99265738885944,
 199.99298946675023,
 200.9933066933798,
 201.9936097236795,
 202.99389918421582,
 203.99417567438928,
 204.99443976758485,
 205.9946920122749,
 206.994932933077,
 207.9951630317682,
 208.99538278825756,
 209.99559266151857,
 210.99579309048286,
 211.9959844948969,
 212.99616727614335,
 213.9963418180279,
 214.99650848753365,
 215.99666763554373,
 216.996819597534,
 217.99696469423634,
 218.99710323227464,
 219.99723550477353,
 220.9973617919418,
 221.99748236163134,
 222.9975974698721,
 223.99770736138467,
 224.9978122700713,
 225.99791241948583,
 226.9980080232837,
 227.9980992856531,
 228.9981864017273,
 229.99826955798,
 230.99834893260308,
 231.99842469586892,
 232.99849701047665,
 233.99856603188394,
 234.99863190862433,
 235.99869478261095,
 236.99875478942738,
 237.99881205860558,
 238.99886671389245,
 239.99891887350407,
 240.99896865036982,
 241.99901615236524,
 242.9990614825352,
 243.99910473930723,
 244.99914601669573,
 245.9991854044971,
 246.99922298847662,
 247.99925885054694,
 248.999293068939,
 249.99932571836553,
 250.99935687017702,
 251.99938659251148,
 252.99941495043706,
 253.99944200608877,
 254.99946781879922,
 255.9994924452234,
 256.9995159394582,
 257.9995383531564,
 258.9995597356362,
 259.9995801339851,
 260.99959959316004,
 261.9996181560825,
 262.99963586372985,
 263.9996527552222,
 264.999668867906,
 265.99968423743337,
 266.99969889783824,
 267.99971288160907,
 268.9997262197582,
 269.99973894188844,
 270.9997510762562,
 271.99976264983246,
 272.99977368836045,
 273.9997842164111,
 274.9997942574358,
 275.99980383381694,
 276.9998129669164,
 277.99982167712136,
 278.99982998388856,
 279.99983790578625,
 280.9998454605344,
 281.9998526650433,
 282.99985953544996,
 283.99986608715335,
 284.9998723348478,
 285.9998782925549,
 286.99988397365416,
 287.99988939091213,
 288.9998945565102,
 289.9998994820711,
 290.9999041786847,
 291.9999086569317,
 292.99991292690737,
 293.99991699824307,
 294.99992088012795,
 295.99992458132874,
 296.99992811020917,
 297.9999314747482,
 298.9999346825578,
 299.99993774089955,
 300.99994065670074,
 301.9999434365696,
 302.9999460868098,
 303.9999486134346,
 304.9999510221798,
 305.99995331851693,
 306.99995550766494,
 307.9999575946018,
 308.99995958407584,
 309.999961480616,
 310.9999632885419,
 311.99996501197376,
 312.999966654841,
 313.99996822089156,
 314.9999697137,
 315.9999711366754,
 316.9999724930689,
 317.99997378598147,
 318.9999750183701,
 319.99997619305486,
 320.99997731272526,
 321.99997837994596,
 322.9999793971628,
 323.9999803667081,
 324.999981290806,
 325.9999821715772,
 326.9999830110444,
 327.99998381113585,
 328.9999845736906,
 329.999985300462,
 330.99998599312204,
 331.99998665326495,
 332.99998728241076,
 333.9999878820088,
 334.999988453441,
 335.99998899802495,
 336.99998951701696,
 337.99999001161467,
 338.9999904829601,
 339.9999909321419,
 340.9999913601981,
 341.9999917681184,
 342.9999921568462,
 343.9999925272808,
 344.99999288027993,
 345.99999321666087,
 346.99999353720307,
 347.99999384264936,
 348.99999413370807,
 349.9999944110542,
 350.9999946753315,
 351.99999492715347,
 352.9999951671049,
 353.99999539574327,
 354.9999956136,
 355.99999582118176,
 356.99999601897133,
 357.999996207429,
 358.9999963869935,
 359.99999655808296,
 360.9999967210959,
 361.9999968764124,
 362.99999702439453,
 363.9999971653874,
 364.99999729972,
 365.9999974277059,
 366.9999975496439,
 367.9999976658188,
 368.99999777650214,
 369.9999978819526,
 370.99999798241674,
 371.9999980781296,
 372.99999816931506,
 373.99999825618676,
 374.99999833894793,
 375.99999841779254,
 376.9999984929053,
 377.9999985644623,
 378.9999986326314,
 379.9999986975723,
 380.9999987594377,
 381.99999881837255,
 382.9999988745153,
 383.99999892799786,
 384.9999989789459,
 385.99999902747913,
 386.9999990737116,
 387.9999991177522,
 388.9999991597045,
 389.99999919966706,
 390.9999992377342,
 391.99999927399546,
 392.99999930853625,
 393.99999934143796,
 394.9999993727781,
 395.9999994026307,
 396.9999994310661,
 397.99999945815136,
 398.99999948395043,
 399.99999950852424,
 400.99999953193077,
 401.9999995542253,
 402.99999957546066,
 403.9999995956868,
 404.9999996149517,
 405.99999963330094,
 406.99999965077785,
 407.9999996674238,
 408.99999968327825,
 409.9999996983787,
 410.9999997127609,
 411.9999997264589,
 412.9999997395052,
 413.9999997519307,
 414.999999763765,
 415.9999997750359,
 416.9999997857704,
 417.9999997959938,
 418.9999998057305,
 419.9999998150035,
 420.99999982383486,
 421.99999983224563,
 422.99999984025567,
 423.99999984788417,
 424.9999998551491,
 425.99999986206785,
 426.99999986865686,
 427.9999998749318,
 428.99999988090764,
 429.9999998865985,
 430.9999998920181,
 431.9999998971791,
 432.9999999020941,
 433.9999999067746,
 434.9999999112318,
 435.9999999154763,
 436.99999991951836,
 437.99999992336745,
 438.9999999270329,
 439.9999999305233,
 440.99999993384716,
 441.9999999370123,
 442.99999994002627,
 443.99999994289635,
 444.9999999456294,
 445.99999994823185,
 446.99999995070993,
 447.99999995306973,
 448.9999999553167,
 449.99999995745634,
 450.9999999594937,
 451.99999996143373,
 452.99999996328097,
 453.9999999650399,
 454.99999996671477,
 455.9999999683095,
 456.999999969828,
 457.9999999712739,
 458.99999997265064,
 459.99999997396145,
 460.9999999752096,
 461.99999997639804,
 462.9999999775296,
 463.99999997860704,
 464.9999999796329,
 465.99999998060963,
 466.99999998153964,
 467.9999999824251,
 468.99999998326814,
 469.9999999840709,
 470.9999999848351,
 471.9999999855628,
 472.9999999862556,
 473.9999999869152,
 474.9999999875432,
 475.9999999881411,
 476.99999998871044,
 477.99999998925244,
 478.99999998976847,
 479.99999999025977,
 480.9999999907274,
 481.99999999117273,
 482.9999999915967,
 483.9999999920003,
 484.99999999238463,
 485.9999999927505,
 486.99999999309875,
 487.9999999934304,
 488.9999999937461,
 489.9999999940466,
 490.99999999433277,
 491.99999999460516,
 492.9999999948645,
 493.99999999511135,
 494.9999999953464,
 495.99999999557014,
 496.9999999957831,
 497.99999999598595,
 498.999999996179,
 499.99999999636276,
 500.99999999653767,
 501.9999999967043,
 502.9999999968628,
 503.99999999701373,
 504.99999999715743,
 505.9999999972942,
 506.9999999974244,
 507.9999999975484,
 508.99999999766635,
 509.9999999977787,
 510.99999999788565,
 511.9999999979874,
 512.9999999980843,
 513.9999999981766,
 514.9999999982643,
 515.9999999983479,
 516.9999999984275,
 517.9999999985032,
 518.9999999985753,
 519.999999998644,
 520.9999999987092,
 521.9999999987714,
 522.9999999988306,
 523.999999998887,
 524.9999999989407,
 525.9999999989916,
 526.9999999990403,
 527.9999999990865,
 528.9999999991305,
 529.9999999991725,
 530.9999999992124,
 531.9999999992503,
 532.9999999992865,
 533.9999999993208,
 534.9999999993537,
 535.9999999993848,
 536.9999999994145,
 537.9999999994427,
 538.9999999994695,
 539.9999999994952,
 540.9999999995196,
 541.9999999995428,
 542.9999999995647,
 543.9999999995857,
 544.9999999996057,
 545.9999999996247,
 546.9999999996429,
 547.9999999996602,
 548.9999999996766,
 549.9999999996921,
 550.999999999707,
 551.9999999997211,
 552.9999999997345,
 553.9999999997475,
 554.9999999997597,
 555.9999999997713,
 556.9999999997823,
 557.9999999997927,
 558.9999999998029,
 559.9999999998123,
 560.9999999998214,
 561.99999999983,
 562.9999999998382,
 563.9999999998461,
 564.9999999998535,
 565.9999999998605,
 566.9999999998673,
 567.9999999998737,
 568.9999999998798,
 569.9999999998856,
 570.9999999998912,
 571.9999999998964,
 572.9999999999014,
 573.9999999999062,
 574.9999999999106,
 575.999999999915,
 576.9999999999192,
 577.999999999923,
 578.9999999999268,
 579.9999999999303,
 580.9999999999337,
 581.9999999999369,
 582.99999999994,
 583.9999999999429,
 584.9999999999457,
 585.9999999999483,
 586.9999999999508,
 587.9999999999532,
 588.9999999999554,
 589.9999999999576,
 590.9999999999595,
 591.9999999999616,
 592.9999999999634,
 593.9999999999652,
 594.9999999999669,
 595.9999999999685,
 596.99999999997,
 597.9999999999715,
 598.9999999999728,
 599.9999999999742,
 600.9999999999753,
 601.9999999999766,
 602.9999999999777,
 603.9999999999789,
 604.9999999999799,
 605.9999999999808,
 606.9999999999817,
 607.9999999999826,
 608.9999999999835,
 609.9999999999843,
 610.999999999985,
 611.9999999999857,
 612.9999999999865,
 613.9999999999872,
 614.9999999999877,
 615.9999999999883,
 616.9999999999889,
 617.9999999999894,
 618.99999999999,
 619.9999999999905,
 620.9999999999909,
 621.9999999999912,
 622.9999999999918,
 623.9999999999922,
 624.9999999999925,
 625.999999999993,
 626.9999999999933,
 627.9999999999936,
 628.9999999999939,
 629.9999999999942,
 630.9999999999944,
 631.9999999999948,
 632.999999999995,
 633.9999999999952,
 634.9999999999955,
 635.9999999999957,
 636.9999999999959,
 637.9999999999961,
 638.9999999999964,
 639.9999999999965,
 640.9999999999967,
 641.9999999999968,
 642.9999999999969,
 643.999999999997,
 644.9999999999972,
 645.9999999999974,
 646.9999999999975,
 647.9999999999976,
 648.9999999999977,
 649.9999999999978,
 650.999999999998,
 651.9999999999981,
 652.9999999999981,
 653.9999999999983,
 654.9999999999983,
 655.9999999999984,
 656.9999999999985,
 657.9999999999985,
 658.9999999999986,
 659.9999999999986,
 660.9999999999987,
 661.9999999999989,
 662.9999999999989,
 663.9999999999989,
 664.999999999999,
 665.9999999999991,
 666.9999999999991,
 667.9999999999991,
 668.9999999999992,
 669.9999999999992,
 670.9999999999992,
 671.9999999999992,
 672.9999999999993,
 673.9999999999993,
 674.9999999999994,
 675.9999999999994,
 676.9999999999994,
 677.9999999999994,
 678.9999999999994,
 679.9999999999995,
 680.9999999999995,
 681.9999999999995,
 682.9999999999997,
 683.9999999999997,
 684.9999999999997,
 685.9999999999997,
 686.9999999999997,
 687.9999999999997,
 688.9999999999997,
 689.9999999999997,
 690.9999999999997,
 691.9999999999998,
 692.9999999999998,
 693.9999999999998,
 694.9999999999998,
 695.9999999999998,
 696.9999999999998,
 697.9999999999998,
 698.9999999999999,
 699.9999999999999,
 700.9999999999999,
 701.9999999999999,
 702.9999999999999,
 703.9999999999999,
 704.9999999999999,
 705.9999999999999,
 706.9999999999999,
 707.9999999999999,
 708.9999999999999,
 709.9999999999999,
 710.9999999999999,
 711.9999999999999,
 712.9999999999999,
 713.9999999999999,
 714.9999999999999,
 715.9999999999999,
 716.9999999999999,
 717.9999999999999,
 718.9999999999999,
 719.9999999999999,
 720.9999999999999,
 721.9999999999999,
 722.9999999999999,
 723.9999999999999,
 724.9999999999999,
 725.9999999999999,
 726.9999999999999,
 727.9999999999999,
 728.9999999999999,
 730.0,
 731.0,
 732.0,
 733.0,
 734.0,
 735.0,
 736.0,
 737.0,
 738.0,
 739.0,
 740.0,
 741.0,
 742.0,
 743.0,
 744.0,
 745.0,
 746.0,
 747.0,
 748.0,
 749.0,
 750.0,
 751.0,
 752.0,
 753.0,
 754.0,
 755.0,
 756.0,
 757.0,
 758.0,
 759.0,
 760.0,
 761.0,
 762.0,
 763.0,
 764.0,
 765.0,
 766.0,
 767.0,
 768.0,
 769.0,
 770.0,
 771.0,
 772.0,
 773.0,
 774.0,
 775.0,
 776.0,
 777.0,
 778.0,
 779.0,
 780.0,
 781.0,
 782.0,
 783.0,
 784.0,
 785.0,
 786.0,
 787.0,
 788.0,
 789.0,
 790.0,
 791.0,
 792.0,
 793.0,
 794.0,
 795.0,
 796.0,
 797.0,
 798.0,
 799.0,
 800.0,
 801.0,
 802.0,
 803.0,
 804.0,
 805.0,
 806.0,
 807.0,
 808.0,
 809.0,
 810.0,
 811.0,
 812.0,
 813.0,
 814.0,
 815.0,
 816.0,
 817.0,
 818.0,
 819.0,
 820.0,
 821.0,
 822.0,
 823.0,
 824.0,
 825.0,
 826.0,
 827.0,
 828.0,
 829.0,
 830.0,
 831.0,
 832.0,
 833.0,
 834.0,
 835.0,
 836.0,
 837.0,
 838.0,
 839.0,
 840.0,
 841.0,
 842.0,
 843.0,
 844.0,
 845.0,
 846.0,
 847.0,
 848.0,
 849.0,
 850.0,
 851.0,
 852.0,
 853.0,
 854.0,
 855.0,
 856.0,
 857.0,
 858.0,
 859.0,
 860.0,
 861.0,
 862.0,
 863.0,
 864.0,
 865.0,
 866.0,
 867.0,
 868.0,
 869.0,
 870.0,
 871.0,
 872.0,
 873.0,
 874.0,
 875.0,
 876.0,
 877.0,
 878.0,
 879.0,
 880.0,
 881.0,
 882.0,
 883.0,
 884.0,
 885.0,
 886.0,
 887.0,
 888.0,
 889.0,
 890.0,
 891.0,
 892.0,
 893.0,
 894.0,
 895.0,
 896.0,
 897.0,
 898.0,
 899.0,
 900.0,
 901.0,
 902.0,
 903.0,
 904.0,
 905.0,
 906.0,
 907.0,
 908.0,
 909.0,
 910.0,
 911.0,
 912.0,
 913.0,
 914.0,
 915.0,
 916.0,
 917.0,
 918.0,
 919.0,
 920.0,
 921.0,
 922.0,
 923.0,
 924.0,
 925.0,
 926.0,
 927.0,
 928.0,
 929.0,
 930.0,
 931.0,
 932.0,
 933.0,
 934.0,
 935.0,
 936.0,
 937.0,
 938.0,
 939.0,
 940.0,
 941.0,
 942.0,
 943.0,
 944.0,
 945.0,
 946.0,
 947.0,
 948.0,
 949.0,
 950.0,
 951.0,
 952.0,
 953.0,
 954.0,
 955.0,
 956.0,
 957.0,
 958.0,
 959.0,
 960.0,
 961.0,
 962.0,
 963.0,
 964.0,
 965.0,
 966.0,
 967.0,
 968.0,
 969.0,
 970.0,
 971.0,
 972.0,
 973.0,
 974.0,
 975.0,
 976.0,
 977.0,
 978.0,
 979.0,
 980.0,
 981.0,
 982.0,
 983.0,
 984.0,
 985.0,
 986.0,
 987.0,
 988.0,
 989.0,
 990.0,
 991.0,
 992.0,
 993.0,
 994.0,
 995.0,
 996.0,
 997.0,
 998.0,
 999.0]

In [9]:
fig, ax = plt.subplots(figsize=(8,8))
sns.scatterplot(number_of_tests, p_errors, alpha=0.5, ax=ax)
ax.set_xlabel('Number of hypotheses')
ax.set_ylabel('Probability of at least one error')
ax.grid()
fig.tight_layout()
fig.savefig('p_errors_FDR.pdf')



In [22]:
fig, ax = plt.subplots(figsize=(8,8))
sns.scatterplot(number_of_tests, n_errors, alpha=0.5, ax=ax)
ax.set_xlabel('Number of hypotheses')
ax.set_ylabel('Number of errors')
fig.tight_layout()