defmodule Bmark.Distribution do
  @moduledoc """
  This module implements an Inverse Student's t-distribution.
  """
  
  @p_value_table [
     0.05,       0.025,     0.01,      0.005,       0.0025,     0.001,      0.0005
  ]
  
  # Generated using TINV() in Apple Numbers
  @critical_value_table [
    [6.313752,	12.706205, 31.820516,	63.656741,	127.321336,	318.308839,	636.619249],
    [2.919986,	 4.302653,	6.964557,	 9.924843,	 14.089047,	 22.327125,  31.599055],
    [2.353363,	 3.182446,	4.540703,	 5.840909,	  7.453319,	 10.214532,  12.923979],
    [2.131847,	 2.776445,	3.746947,	 4.604095,	  5.597568,	  7.173182,	  8.610302],
    [2.015048,	 2.570582,	3.364930,	 4.032143,	  4.773341,	  5.893430,	  6.868827],
    [1.943180,	 2.446912,	3.142668,	 3.707428,	  4.316827,	  5.207626,	  5.958816],
    [1.894579,	 2.364624,	2.997952,	 3.499483,	  4.029337,	  4.785290,	  5.407883],
    [1.859548,	 2.306004,	2.896459,	 3.355387,	  3.832519,	  4.500791,	  5.041305],
    [1.833113,	 2.262157,	2.821438,	 3.249836,	  3.689662,	  4.296806,	  4.780913],
    [1.812461,	 2.228139,	2.763769,	 3.169273,	  3.581406,	  4.143700,	  4.586894],
    [1.795885,	 2.200985,	2.718079,	 3.105807,	  3.496614,	  4.024701,	  4.436979],
    [1.782288,	 2.178813,	2.680998,	 3.054540,	  3.428444,	  3.929633,	  4.317791],
    [1.770933,	 2.160369,	2.650309,	 3.012276,	  3.372468,	  3.851982,	  4.220832],
    [1.761310,	 2.144787,	2.624494,	 2.976843,	  3.325696,	  3.787390,	  4.140454],
    [1.753050,	 2.131450,	2.602480,	 2.946713,	  3.286039,	  3.732834,	  4.072765],
    [1.745884,	 2.119905,	2.583487,	 2.920782,	  3.251993,	  3.686155,	  4.014996],
    [1.739607,	 2.109816,	2.566934,	 2.898231,	  3.222450,	  3.645767,	  3.965126],
    [1.734064,	 2.100922,	2.552380,	 2.878440,	  3.196574,	  3.610485,	  3.921646],
    [1.729133,	 2.093024,	2.539483,	 2.860935,	  3.173725,	  3.579400,	  3.883406],
    [1.724718,	 2.085963,	2.527977,	 2.845340,	  3.153401,	  3.551808,	  3.849516],
    [1.720743,	 2.079614,	2.517648,	 2.831360,	  3.135206,	  3.527154,	  3.819277],
    [1.717144,	 2.073873,	2.508325,	 2.818756,	  3.118824,	  3.504992,	  3.792131],
    [1.713872,	 2.068658,	2.499867,	 2.807336,	  3.103997,	  3.484964,	  3.767627],
    [1.710882,	 2.063899,	2.492159,	 2.796940,	  3.090514,	  3.466777,	  3.745399],
    [1.708141,	 2.059539,	2.485107,	 2.787436,	  3.078199,	  3.450189,	  3.725144],
    [1.705618,	 2.055529,	2.478630,	 2.778715,	  3.066909,	  3.434997,	  3.706612],
    [1.703288,	 2.051831,	2.472660,	 2.770683,	  3.056520,	  3.421034,	  3.689592],
    [1.701131,	 2.048407,	2.467140,	 2.763262,	  3.046929,	  3.408155,	  3.673906],
    [1.699127,	 2.045230,	2.462021,	 2.756386,	  3.038047,	  3.396240,	  3.659405],
    [1.697261,	 2.042272,	2.457262,	 2.749996,	  3.029798,	  3.385185,	  3.645959],
    [1.695519,	 2.039513,	2.452824,	 2.744042,	  3.022118,	  3.374899,	  3.633456],
    [1.693889,	 2.036933,	2.448678,	 2.738481,	  3.014949,	  3.365306,	  3.621802],
    [1.692360,	 2.034515,	2.444794,	 2.733277,	  3.008242,	  3.356337,	  3.610913],
    [1.690924,	 2.032245,	2.441150,	 2.728394,	  3.001954,	  3.347934,	  3.600716],
    [1.689572,	 2.030108,	2.437723,	 2.723806,	  2.996047,	  3.340045,	  3.591147],
    [1.688298,	 2.028094,	2.434494,	 2.719485,	  2.990487,	  3.332624,	  3.582150],
    [1.687094,	 2.026192,	2.431447,	 2.715409,	  2.985244,	  3.325631,	  3.573675],
    [1.685954,	 2.024394,	2.428568,	 2.711558,	  2.980293,	  3.319030,	  3.565678],
    [1.684875,	 2.022691,	2.425841,	 2.707913,	  2.975609,	  3.312788,	  3.558120],
    [1.683851,	 2.021075,	2.423257,	 2.704459,	  2.971171,	  3.306878,	  3.550966],
    [1.682878,	 2.019541,	2.420803,	 2.701181,	  2.966961,	  3.301273,	  3.544184],
    [1.681952,	 2.018082,	2.418470,	 2.698066,	  2.962962,	  3.295951,	  3.537745],
    [1.681071,	 2.016692,	2.416250,	 2.695102,	  2.959157,	  3.290890,	  3.531626],
    [1.680230,	 2.015368,	2.414134,	 2.692278,	  2.955534,	  3.286072,	  3.525801],
    [1.679427,	 2.014103,	2.412116,	 2.689585,	  2.952079,	  3.281480,	  3.520251],
    [1.678660,	 2.012896,	2.410188,	 2.687013,	  2.948781,	  3.277098,	  3.514957],
    [1.677927,	 2.011741,	2.408345,	 2.684556,	  2.945630,	  3.272912,	  3.509901],
    [1.677224,	 2.010635,	2.406581,	 2.682204,	  2.942616,	  3.268910,	  3.505068],
    [1.676551,	 2.009575,	2.404892,	 2.679952,	  2.939730,	  3.265079,	  3.500443],
    [1.675905,	 2.008559,	2.403272,	 2.677793,	  2.936964,	  3.261409,	  3.496013],
    [1.675285,	 2.007584,	2.401718,	 2.675722,	  2.934311,	  3.257890,	  3.491766],
    [1.674689,	 2.006647,	2.400225,	 2.673734,	  2.931765,	  3.254512,	  3.487691],
    [1.674116,	 2.005746,	2.398790,	 2.671823,	  2.929318,	  3.251268,	  3.483777],
    [1.673565,	 2.004879,	2.397410,	 2.669985,	  2.926965,	  3.248149,	  3.480016],
    [1.673034,	 2.004045,	2.396081,	 2.668216,	  2.924701,	  3.245149,	  3.476398],
    [1.672522,	 2.003241,	2.394801,	 2.666512,	  2.922521,	  3.242261,	  3.472916],
    [1.672029,	 2.002465,	2.393568,	 2.664870,	  2.920420,	  3.239478,	  3.469562],
    [1.671553,	 2.001717,	2.392377,	 2.663287,	  2.918394,	  3.236795,	  3.466329],
    [1.671093,	 2.000995,	2.391229,	 2.661759,	  2.916440,	  3.234207,	  3.463210],
    [1.670649,	 2.000298,	2.390119,	 2.660283,	  2.914553,	  3.231709,	  3.460200],
    [1.670219,	 1.999624,	2.389047,	 2.658857,	  2.912729,	  3.229296,	  3.457294],
    [1.669804,	 1.998972,	2.388011,	 2.657479,	  2.910967,	  3.226964,	  3.454485],
    [1.669402,	 1.998341,	2.387008,	 2.656145,	  2.909262,	  3.224709,	  3.451769],
    [1.669013,	 1.997730,	2.386037,	 2.654854,	  2.907613,	  3.222527,	  3.449142],
    [1.668636,	 1.997138,	2.385097,	 2.653604,	  2.906015,	  3.220414,	  3.446598],
    [1.668271,	 1.996564,	2.384186,	 2.652394,	  2.904468,	  3.218368,	  3.444135],
    [1.667916,	 1.996008,	2.383302,	 2.651220,	  2.902968,	  3.216386,	  3.441749],
    [1.667572,	 1.995469,	2.382446,	 2.650081,	  2.901514,	  3.214463,	  3.439435],
    [1.667239,	 1.994945,	2.381615,	 2.648977,	  2.900103,	  3.212599,	  3.437192],
    [1.666914,	 1.994437,	2.380807,	 2.647905,	  2.898734,	  3.210789,	  3.435015],
    [1.666600,	 1.993943,	2.380024,	 2.646863,	  2.897404,	  3.209032,	  3.432901],
    [1.666294,	 1.993464,	2.379262,	 2.645852,	  2.896113,	  3.207326,	  3.430848],
    [1.665996,	 1.992997,	2.378522,	 2.644869,	  2.894857,	  3.205668,	  3.428854],
    [1.665707,	 1.992543,	2.377802,	 2.643913,	  2.893637,	  3.204056,	  3.426916],
    [1.665425,	 1.992102,	2.377102,	 2.642983,	  2.892450,	  3.202489,	  3.425031],
    [1.665151,	 1.991673,	2.376420,	 2.642078,	  2.891295,	  3.200964,	  3.423197],
    [1.664885,	 1.991254,	2.375757,	 2.641198,	  2.890171,	  3.199480,	  3.421413],
    [1.664625,	 1.990847,	2.375111,	 2.640340,	  2.889077,	  3.198035,	  3.419676],
    [1.664371,	 1.990450,	2.374482,	 2.639505,	  2.888011,	  3.196628,	  3.417985],
    [1.664125,	 1.990063,	2.373868,	 2.638691,	  2.886972,	  3.195258,	  3.416337],
    [1.663884,	 1.989686,	2.373270,	 2.637897,	  2.885960,	  3.193922,	  3.414732],
    [1.663649,	 1.989319,	2.372687,	 2.637123,	  2.884973,	  3.192619,	  3.413167],
    [1.663420,	 1.988960,	2.372119,	 2.636369,	  2.884010,	  3.191349,	  3.411641],
    [1.663197,	 1.988610,	2.371564,	 2.635632,	  2.883071,	  3.190111,	  3.410152],
    [1.662978,	 1.988268,	2.371022,	 2.634914,	  2.882154,	  3.188902,	  3.408699],
    [1.662765,	 1.987934,	2.370493,	 2.634212,	  2.881260,	  3.187722,	  3.407282],
    [1.662557,	 1.987608,	2.369977,	 2.633527,	  2.880386,	  3.186569,	  3.405897],
    [1.662354,	 1.987290,	2.369472,	 2.632858,	  2.879533,	  3.185444,	  3.404546],
    [1.662155,	 1.986979,	2.368979,	 2.632204,	  2.878699,	  3.184345,	  3.403225],
    [1.661961,	 1.986675,	2.368497,	 2.631565,	  2.877884,	  3.183271,	  3.401935],
    [1.661771,	 1.986377,	2.368026,	 2.630940,	  2.877088,	  3.182221,	  3.400674],
    [1.661585,	 1.986086,	2.367566,	 2.630330,	  2.876309,	  3.181194,	  3.399442],
    [1.661404,	 1.985802,	2.367115,	 2.629732,	  2.875547,	  3.180191,	  3.398236],
    [1.661226,	 1.985523,	2.366674,	 2.629148,	  2.874802,	  3.179209,	  3.397057],
    [1.661052,	 1.985251,	2.366243,	 2.628576,	  2.874073,	  3.178248,	  3.395904],
    [1.660881,	 1.984984,	2.365821,	 2.628016,	  2.873360,	  3.177308,	  3.394775],
    [1.660715,	 1.984723,	2.365407,	 2.627468,	  2.872661,	  3.176387,	  3.393670],
    [1.660551,	 1.984467,	2.365002,	 2.626931,	  2.871977,	  3.175486,	  3.392588],
    [1.660391,	 1.984217,	2.364606,	 2.626405,	  2.871308,	  3.174604,	  3.391529],
    [1.660234,	 1.983972,	2.364217,	 2.625891,	  2.870652,	  3.173739,	  3.390491],
    [1.660081,	 1.983731,	2.363837,	 2.625386,	  2.870009,	  3.172893,	  3.389475],
    [1.659930,	 1.983495,	2.363464,	 2.624891,	  2.869379,	  3.172063,	  3.388479],
    [1.659782,	 1.983264,	2.363098,	 2.624407,	  2.868761,	  3.171250,	  3.387503],
    [1.659637,	 1.983038,	2.362739,	 2.623932,	  2.868156,	  3.170452,	  3.386546],
    [1.659495,	 1.982815,	2.362388,	 2.623465,	  2.867562,	  3.169670,	  3.385608],
    [1.659356,	 1.982597,	2.362043,	 2.623008,	  2.866980,	  3.168904,	  3.384688],
    [1.659219,	 1.982383,	2.361704,	 2.622560,	  2.866409,	  3.168152,	  3.383785],
    [1.659085,	 1.982173,	2.361372,	 2.622120,	  2.865848,	  3.167414,	  3.382900],
    [1.658953,	 1.981967,	2.361046,	 2.621688,	  2.865298,	  3.166690,	  3.382032],
    [1.658824,	 1.981765,	2.360726,	 2.621265,	  2.864759,	  3.165979,	  3.381179],
    [1.658697,	 1.981567,	2.360412,	 2.620849,	  2.864229,	  3.165282,	  3.380342],
    [1.658573,	 1.981372,	2.360104,	 2.620440,	  2.863709,	  3.164597,	  3.379521],
    [1.658450,	 1.981180,	2.359801,	 2.620039,	  2.863198,	  3.163925,	  3.378714],
    [1.658330,	 1.980992,	2.359504,	 2.619645,	  2.862696,	  3.163265,	  3.377922],
    [1.658212,	 1.980808,	2.359212,	 2.619258,	  2.862203,	  3.162616,	  3.377145],
    [1.658096,	 1.980626,	2.358924,	 2.618878,	  2.861719,	  3.161979,	  3.376380],
    [1.657982,	 1.980448,	2.358642,	 2.618504,	  2.861244,	  3.161353,	  3.375629],
    [1.657870,	 1.980272,	2.358365,	 2.618137,	  2.860776,	  3.160738,	  3.374892],
    [1.657759,	 1.980100,	2.358093,	 2.617776,	  2.860317,	  3.160133,	  3.374167],
    [1.657651,	 1.979930,	2.357825,	 2.617421,	  2.859865,	  3.159539,	  3.373454],
    [1.657544,	 1.979764,	2.357561,	 2.617072,	  2.859421,	  3.158954,	  3.372753],
    [1.657439,	 1.979600,	2.357302,	 2.616729,	  2.858984,	  3.158380,	  3.372064],
    [1.657336,	 1.979439,	2.357047,	 2.616392,	  2.858554,	  3.157815,	  3.371387],
    [1.657235,	 1.979280,	2.356797,	 2.616060,	  2.858132,	  3.157259,	  3.370720],
    [1.657135,	 1.979124,	2.356550,	 2.615733,	  2.857716,	  3.156712,	  3.370065],
    [1.657037,	 1.978971,	2.356307,	 2.615412,	  2.857308,	  3.156175,	  3.369420],
    [1.656940,	 1.978820,	2.356069,	 2.615096,	  2.856905,	  3.155645,	  3.368785],
    [1.656845,	 1.978671,	2.355834,	 2.614785,	  2.856509,	  3.155125,	  3.368161],
    [1.656752,	 1.978524,	2.355602,	 2.614479,	  2.856120,	  3.154612,	  3.367546],
    [1.656659,	 1.978380,	2.355375,	 2.614177,	  2.855736,	  3.154107,	  3.366942],
    [1.656569,	 1.978239,	2.355150,	 2.613880,	  2.855358,	  3.153611,	  3.366346],
    [1.656479,	 1.978099,	2.354930,	 2.613588,	  2.854986,	  3.153122,	  3.365760],
    [1.656391,	 1.977961,	2.354712,	 2.613300,	  2.854620,	  3.152640,	  3.365183],
    [1.656305,	 1.977826,	2.354498,	 2.613017,	  2.854260,	  3.152166,	  3.364614],
    [1.656219,	 1.977692,	2.354287,	 2.612738,	  2.853904,	  3.151699,	  3.364055],
    [1.656135,	 1.977561,	2.354079,	 2.612463,	  2.853554,	  3.151239,	  3.363503],
    [1.656052,	 1.977431,	2.353875,	 2.612192,	  2.853210,	  3.150786,	  3.362960],
    [1.655970,	 1.977304,	2.353673,	 2.611925,	  2.852870,	  3.150339,	  3.362425],
    [1.655890,	 1.977178,	2.353474,	 2.611662,	  2.852535,	  3.149899,	  3.361897],
    [1.655811,	 1.977054,	2.353278,	 2.611403,	  2.852206,	  3.149466,	  3.361378],
    [1.655732,	 1.976931,	2.353085,	 2.611147,	  2.851880,	  3.149038,	  3.360866],
    [1.655655,	 1.976811,	2.352895,	 2.610895,	  2.851560,	  3.148617,	  3.360361],
    [1.655579,	 1.976692,	2.352707,	 2.610647,	  2.851244,	  3.148202,	  3.359863],
    [1.655504,	 1.976575,	2.352522,	 2.610402,	  2.850933,	  3.147792,	  3.359373],
    [1.655430,	 1.976460,	2.352340,	 2.610161,	  2.850626,	  3.147389,	  3.358889],
    [1.655357,	 1.976346,	2.352160,	 2.609923,	  2.850323,	  3.146991,	  3.358412],
    [1.655285,	 1.976233,	2.351983,	 2.609688,	  2.850024,	  3.146598,	  3.357942],
    [1.655215,	 1.976122,	2.351808,	 2.609456,	  2.849730,	  3.146211,	  3.357478],
    [1.655145,	 1.976013,	2.351635,	 2.609228,	  2.849439,	  3.145829,	  3.357020],
    [1.655076,	 1.975905,	2.351465,	 2.609003,	  2.849152,	  3.145453,	  3.356569],
    [1.655007,	 1.975799,	2.351297,	 2.608780,	  2.848870,	  3.145081,	  3.356124],
    [1.654940,	 1.975694,	2.351131,	 2.608561,	  2.848591,	  3.144714,	  3.355685],
    [1.654874,	 1.975590,	2.350967,	 2.608344,	  2.848315,	  3.144353,	  3.355251],
    [1.654808,	 1.975488,	2.350806,	 2.608131,	  2.848044,	  3.143996,	  3.354823],
    [1.654744,	 1.975387,	2.350646,	 2.607920,	  2.847776,	  3.143643,	  3.354401],
    [1.654680,	 1.975288,	2.350489,	 2.607712,	  2.847511,	  3.143296,	  3.353985],
    [1.654617,	 1.975189,	2.350334,	 2.607506,	  2.847250,	  3.142952,	  3.353574],
    [1.654555,	 1.975092,	2.350180,	 2.607304,	  2.846992,	  3.142613,	  3.353168],
    [1.654494,	 1.974996,	2.350029,	 2.607103,	  2.846737,	  3.142279,	  3.352767],
    [1.654433,	 1.974902,	2.349880,	 2.606906,	  2.846486,	  3.141949,	  3.352371],
    [1.654373,	 1.974808,	2.349732,	 2.606711,	  2.846238,	  3.141623,	  3.351981],
    [1.654314,	 1.974716,	2.349586,	 2.606518,	  2.845993,	  3.141301,	  3.351595],
    [1.654256,	 1.974625,	2.349442,	 2.606328,	  2.845751,	  3.140983,	  3.351214],
    [1.654198,	 1.974535,	2.349300,	 2.606140,	  2.845511,	  3.140669,	  3.350838],
    [1.654141,	 1.974446,	2.349160,	 2.605954,	  2.845275,	  3.140358,	  3.350467],
    [1.654085,	 1.974358,	2.349021,	 2.605770,	  2.845042,	  3.140052,	  3.350100],
    [1.654029,	 1.974271,	2.348884,	 2.605589,	  2.844812,	  3.139749,	  3.349737],
    [1.653974,	 1.974185,	2.348749,	 2.605410,	  2.844584,	  3.139450,	  3.349379],
    [1.653920,	 1.974100,	2.348615,	 2.605233,	  2.844359,	  3.139155,	  3.349025],
    [1.653866,	 1.974017,	2.348483,	 2.605058,	  2.844137,	  3.138863,	  3.348676],
    [1.653813,	 1.973934,	2.348352,	 2.604886,	  2.843917,	  3.138575,	  3.348330],
    [1.653761,	 1.973852,	2.348223,	 2.604715,	  2.843700,	  3.138290,	  3.347989],
    [1.653709,	 1.973771,	2.348096,	 2.604546,	  2.843486,	  3.138008,	  3.347651],
    [1.653658,	 1.973691,	2.347970,	 2.604379,	  2.843274,	  3.137729,	  3.347318],
    [1.653607,	 1.973612,	2.347845,	 2.604215,	  2.843064,	  3.137454,	  3.346989],
    [1.653557,	 1.973534,	2.347722,	 2.604052,	  2.842857,	  3.137182,	  3.346663],
    [1.653508,	 1.973457,	2.347600,	 2.603891,	  2.842652,	  3.136913,	  3.346341],
    [1.653459,	 1.973381,	2.347479,	 2.603731,	  2.842450,	  3.136648,	  3.346022],
    [1.653411,	 1.973305,	2.347360,	 2.603574,	  2.842250,	  3.136385,	  3.345708],
    [1.653363,	 1.973231,	2.347243,	 2.603418,	  2.842052,	  3.136125,	  3.345397],
    [1.653316,	 1.973157,	2.347126,	 2.603264,	  2.841856,	  3.135868,	  3.345089],
    [1.653269,	 1.973084,	2.347011,	 2.603112,	  2.841663,	  3.135614,	  3.344785],
    [1.653223,	 1.973012,	2.346897,	 2.602961,	  2.841471,	  3.135363,	  3.344484],
    [1.653177,	 1.972941,	2.346785,	 2.602813,	  2.841282,	  3.135114,	  3.344186],
    [1.653132,	 1.972870,	2.346673,	 2.602665,	  2.841095,	  3.134868,	  3.343892],
    [1.653087,	 1.972800,	2.346563,	 2.602520,	  2.840910,	  3.134625,	  3.343601],
    [1.653043,	 1.972731,	2.346454,	 2.602376,	  2.840726,	  3.134385,	  3.343313],
    [1.652999,	 1.972663,	2.346346,	 2.602233,	  2.840545,	  3.134147,	  3.343028],
    [1.652956,	 1.972595,	2.346240,	 2.602092,	  2.840366,	  3.133911,	  3.342746],
    [1.652913,	 1.972528,	2.346134,	 2.601952,	  2.840189,	  3.133679,	  3.342468],
    [1.652871,	 1.972462,	2.346030,	 2.601814,	  2.840013,	  3.133448,	  3.342192],
    [1.652829,	 1.972396,	2.345926,	 2.601678,	  2.839840,	  3.133220,	  3.341919],
    [1.652787,	 1.972332,	2.345824,	 2.601543,	  2.839668,	  3.132995,	  3.341649],
    [1.652746,	 1.972268,	2.345723,	 2.601409,	  2.839498,	  3.132772,	  3.341382],
    [1.652705,	 1.972204,	2.345623,	 2.601276,	  2.839329,	  3.132551,	  3.341117],
    [1.652665,	 1.972141,	2.345524,	 2.601145,	  2.839163,	  3.132332,	  3.340856],
    [1.652625,	 1.972079,	2.345425,	 2.601016,	  2.838998,	  3.132116,	  3.340597],
    [1.652586,	 1.972017,	2.345328,	 2.600887,	  2.838835,	  3.131902,	  3.340340],
    [1.652547,	 1.971957,	2.345232,	 2.600760,	  2.838674,	  3.131690,	  3.340087],
    [1.652508,	 1.971896,	2.345137,	 2.600634,	  2.838514,	  3.131480,	  3.339835],
    [1.652470,	 1.971837,	2.345043,	 2.600510,	  2.838355,	  3.131272,	  3.339587],
    [1.652432,	 1.971777,	2.344950,	 2.600387,	  2.838199,	  3.131067,	  3.339341],
    [1.652394,	 1.971719,	2.344857,	 2.600265,	  2.838044,	  3.130863,	  3.339097],
    [1.652357,	 1.971661,	2.344766,	 2.600144,	  2.837890,	  3.130661,	  3.338856],
    [1.652321,	 1.971603,	2.344675,	 2.600024,	  2.837738,	  3.130462,	  3.338617],
    [1.652284,	 1.971547,	2.344586,	 2.599906,	  2.837588,	  3.130264,	  3.338380],
    [1.652248,	 1.971490,	2.344497,	 2.599788,	  2.837438,	  3.130069,	  3.338146],
    [1.652212,	 1.971435,	2.344409,	 2.599672,	  2.837291,	  3.129875,	  3.337914],
    [1.652177,	 1.971379,	2.344322,	 2.599557,	  2.837145,	  3.129683,	  3.337685],
    [1.652142,	 1.971325,	2.344236,	 2.599443,	  2.837000,	  3.129493,	  3.337457],
    [1.652107,	 1.971271,	2.344150,	 2.599330,	  2.836856,	  3.129305,	  3.337232],
    [1.652073,	 1.971217,	2.344066,	 2.599218,	  2.836714,	  3.129118,	  3.337009],
    [1.652039,	 1.971164,	2.343982,	 2.599108,	  2.836574,	  3.128934,	  3.336788],
    [1.652005,	 1.971111,	2.343899,	 2.598998,	  2.836434,	  3.128751,	  3.336569],
    [1.651972,	 1.971059,	2.343817,	 2.598889,	  2.836296,	  3.128570,	  3.336352],
    [1.651939,	 1.971007,	2.343735,	 2.598782,	  2.836159,	  3.128390,	  3.336137],
    [1.651906,	 1.970956,	2.343655,	 2.598675,	  2.836024,	  3.128212,	  3.335924],
    [1.651873,	 1.970906,	2.343575,	 2.598569,	  2.835890,	  3.128036,	  3.335714],
    [1.651841,	 1.970855,	2.343496,	 2.598465,	  2.835757,	  3.127862,	  3.335505],
    [1.651809,	 1.970806,	2.343417,	 2.598361,	  2.835625,	  3.127689,	  3.335298],
    [1.651778,	 1.970756,	2.343339,	 2.598258,	  2.835494,	  3.127517,	  3.335093],
    [1.651746,	 1.970707,	2.343262,	 2.598156,	  2.835365,	  3.127347,	  3.334889],
    [1.651715,	 1.970659,	2.343186,	 2.598055,	  2.835237,	  3.127179,	  3.334688],
    [1.651685,	 1.970611,	2.343110,	 2.597955,	  2.835110,	  3.127013,	  3.334489],
    [1.651654,	 1.970563,	2.343035,	 2.597856,	  2.834984,	  3.126847,	  3.334291],
    [1.651624,	 1.970516,	2.342961,	 2.597758,	  2.834859,	  3.126684,	  3.334095],
    [1.651594,	 1.970470,	2.342887,	 2.597661,	  2.834735,	  3.126521,	  3.333901],
    [1.651564,	 1.970423,	2.342814,	 2.597564,	  2.834613,	  3.126360,	  3.333708],
    [1.651535,	 1.970377,	2.342742,	 2.597468,	  2.834491,	  3.126201,	  3.333517],
    [1.651506,	 1.970332,	2.342670,	 2.597374,	  2.834371,	  3.126043,	  3.333328],
    [1.651477,	 1.970287,	2.342599,	 2.597280,	  2.834251,	  3.125886,	  3.333141],
    [1.651448,	 1.970242,	2.342528,	 2.597186,	  2.834133,	  3.125731,	  3.332955],
    [1.651420,	 1.970198,	2.342458,	 2.597094,	  2.834016,	  3.125577,	  3.332771],
    [1.651391,	 1.970154,	2.342389,	 2.597002,	  2.833899,	  3.125424,	  3.332588],
    [1.651364,	 1.970110,	2.342320,	 2.596912,	  2.833784,	  3.125273,	  3.332407],
    [1.651336,	 1.970067,	2.342252,	 2.596822,	  2.833670,	  3.125123,	  3.332228],
    [1.651308,	 1.970024,	2.342185,	 2.596732,	  2.833556,	  3.124974,	  3.332050],
    [1.651281,	 1.969982,	2.342118,	 2.596644,	  2.833444,	  3.124827,	  3.331873],
    [1.651254,	 1.969939,	2.342051,	 2.596556,	  2.833332,	  3.124681,	  3.331698],
    [1.651227,	 1.969898,	2.341985,	 2.596469,	  2.833222,	  3.124536,	  3.331525],
    [1.651201,	 1.969856,	2.341920,	 2.596383,	  2.833112,	  3.124392,	  3.331353],
    [1.651175,	 1.969815,	2.341855,	 2.596297,	  2.833003,	  3.124249,	  3.331182],
    [1.651148,	 1.969774,	2.341791,	 2.596212,	  2.832896,	  3.124108,	  3.331013],
    [1.651123,	 1.969734,	2.341728,	 2.596128,	  2.832789,	  3.123968,	  3.330845],
    [1.651097,	 1.969694,	2.341664,	 2.596045,	  2.832683,	  3.123829,	  3.330679],
    [1.651071,	 1.969654,	2.341602,	 2.595962,	  2.832578,	  3.123691,	  3.330514],
    [1.651046,	 1.969615,	2.341540,	 2.595880,	  2.832473,	  3.123554,	  3.330350],
    [1.651021,	 1.969576,	2.341478,	 2.595799,	  2.832370,	  3.123418,	  3.330188],
    [1.650996,	 1.969537,	2.341417,	 2.595718,	  2.832267,	  3.123284,	  3.330027],
    [1.650971,	 1.969498,	2.341356,	 2.595638,	  2.832166,	  3.123150,	  3.329867],
    [1.650947,	 1.969460,	2.341296,	 2.595558,	  2.832065,	  3.123018,	  3.329709],
    [1.650923,	 1.969422,	2.341236,	 2.595479,	  2.831964,	  3.122886,	  3.329552],
    [1.650899,	 1.969385,	2.341177,	 2.595401,	  2.831865,	  3.122756,	  3.329396],
    [1.650875,	 1.969348,	2.341118,	 2.595323,	  2.831767,	  3.122627,	  3.329241],
    [1.650851,	 1.969311,	2.341060,	 2.595246,	  2.831669,	  3.122499,	  3.329088],
    [1.650828,	 1.969274,	2.341002,	 2.595170,	  2.831572,	  3.122371,	  3.328935],
    [1.650804,	 1.969237,	2.340945,	 2.595094,	  2.831476,	  3.122245,	  3.328784],
    [1.650781,	 1.969201,	2.340888,	 2.595019,	  2.831380,	  3.122120,	  3.328635],
    [1.650758,	 1.969166,	2.340831,	 2.594945,	  2.831285,	  3.121996,	  3.328486],
    [1.650735,	 1.969130,	2.340775,	 2.594870,	  2.831191,	  3.121872,	  3.328338],
    [1.650713,	 1.969095,	2.340720,	 2.594797,	  2.831098,	  3.121750,	  3.328192],
    [1.650690,	 1.969060,	2.340665,	 2.594724,	  2.831005,	  3.121629,	  3.328047],
    [1.650668,	 1.969025,	2.340610,	 2.594652,	  2.830914,	  3.121508,	  3.327903],
    [1.650646,	 1.968990,	2.340556,	 2.594580,	  2.830822,	  3.121389,	  3.327760],
    [1.650624,	 1.968956,	2.340502,	 2.594509,	  2.830732,	  3.121270,	  3.327618],
    [1.650602,	 1.968922,	2.340448,	 2.594438,	  2.830642,	  3.121152,	  3.327477],
    [1.650581,	 1.968889,	2.340395,	 2.594368,	  2.830553,	  3.121035,	  3.327337],
    [1.650559,	 1.968855,	2.340342,	 2.594298,	  2.830465,	  3.120919,	  3.327198],
    [1.650538,	 1.968822,	2.340290,	 2.594229,	  2.830377,	  3.120804,	  3.327061],
    [1.650517,	 1.968789,	2.340238,	 2.594161,	  2.830290,	  3.120690,	  3.326924],
    [1.650496,	 1.968756,	2.340187,	 2.594092,	  2.830203,	  3.120577,	  3.326788],
    [1.650475,	 1.968724,	2.340135,	 2.594025,	  2.830117,	  3.120464,	  3.326654],
    [1.650454,	 1.968692,	2.340085,	 2.593958,	  2.830032,	  3.120352,	  3.326520],
    [1.650434,	 1.968660,	2.340034,	 2.593891,	  2.829948,	  3.120241,	  3.326387],
    [1.650413,	 1.968628,	2.339984,	 2.593825,	  2.829864,	  3.120131,	  3.326256],
    [1.650393,	 1.968596,	2.339934,	 2.593759,	  2.829780,	  3.120022,	  3.326125],
    [1.650373,	 1.968565,	2.339885,	 2.593694,	  2.829698,	  3.119914,	  3.325995],
    [1.650353,	 1.968534,	2.339836,	 2.593630,	  2.829615,	  3.119806,	  3.325866],
    [1.650333,	 1.968503,	2.339788,	 2.593565,	  2.829534,	  3.119699,	  3.325739],
    [1.650314,	 1.968472,	2.339739,	 2.593502,	  2.829453,	  3.119593,	  3.325612],
    [1.650294,	 1.968442,	2.339691,	 2.593438,	  2.829373,	  3.119487,	  3.325485],
    [1.650275,	 1.968412,	2.339644,	 2.593376,	  2.829293,	  3.119383,	  3.325360],
    [1.650256,	 1.968382,	2.339597,	 2.593313,	  2.829214,	  3.119279,	  3.325236],
    [1.650237,	 1.968352,	2.339550,	 2.593251,	  2.829135,	  3.119176,	  3.325113],
    [1.650218,	 1.968323,	2.339503,	 2.593190,	  2.829057,	  3.119073,	  3.324990],
    [1.650199,	 1.968293,	2.339457,	 2.593129,	  2.828979,	  3.118972,	  3.324869],
    [1.650180,	 1.968264,	2.339411,	 2.593068,	  2.828902,	  3.118871,	  3.324748],
    [1.650162,	 1.968235,	2.339365,	 2.593008,	  2.828826,	  3.118770,	  3.324628],
    [1.650143,	 1.968206,	2.339320,	 2.592948,	  2.828750,	  3.118671,	  3.324509],
    [1.650125,	 1.968178,	2.339275,	 2.592888,	  2.828674,	  3.118572,	  3.324390],
    [1.650107,	 1.968150,	2.339230,	 2.592829,	  2.828599,	  3.118474,	  3.324273],
    [1.650089,	 1.968121,	2.339186,	 2.592771,	  2.828525,	  3.118376,	  3.324156],
    [1.650071,	 1.968093,	2.339142,	 2.592713,	  2.828451,	  3.118279,	  3.324041],
    [1.650053,	 1.968066,	2.339098,	 2.592655,	  2.828378,	  3.118183,	  3.323925],
    [1.650035,	 1.968038,	2.339055,	 2.592598,	  2.828305,	  3.118088,	  3.323811],
    [1.650018,	 1.968011,	2.339012,	 2.592541,	  2.828233,	  3.117993,	  3.323698],
    [1.650000,	 1.967984,	2.338969,	 2.592484,	  2.828161,	  3.117898,	  3.323585],
    [1.649983,	 1.967957,	2.338926,	 2.592428,	  2.828089,	  3.117805,	  3.323473],
    [1.649966,	 1.967930,	2.338884,	 2.592372,	  2.828018,	  3.117712,	  3.323362],
  ]
  
  @doc """
  Lookup the ciritcal values of the t distribution.
  
  `val` A value to lookup in the t-distribution.
  `df`  degrees of freedom for the distribution
  """
  def t(val, df) do
    index_of_lower_critical_t_value(val, df)
    |> lookup_p
  end
  
  defp index_of_lower_critical_t_value(val, df) do
    (lookup_row_by_df(df)
     |> Enum.take_while(fn(x) -> x < val end)
     |> Enum.count) - 1
  end
  
  defp lookup_row_by_df(df) do
    {:ok, row} = Enum.fetch(@critical_value_table, clamp(df) - 1)
    row
  end
  
  defp clamp(df) do
    min(df, Enum.count(@critical_value_table))
  end
  
  defp lookup_p(-1), do: 1
  defp lookup_p(index) do
    {:ok, p} = Enum.fetch(@p_value_table, index )
    p
  end
end