# Copyright (c) 2011, Roger Lew [see LICENSE.txt]
# This software is funded in part by NIH Grant P20 RR016454.

"""
Implementation of Gleason's (1999) non-iterative upper quantile
studentized range approximation.

According to Gleason this method should be more accurate than the
AS190 FORTRAN algorithm of Lund and Lund (1983) and works from .5
<= p <= .999 (The AS190 only works from .9 <= p <= .99).

It is more efficient then the Copenhaver & Holland (1988) algorithm
(used by the _qtukey_ R function) although it requires storing the A
table in memory. (q distribution) approximations in Python.

see:
  Gleason, J. R. (1999). An accurate, non-iterative approximation
    for studentized range quantiles. Computational Statistics &
    Data Analysis, (31), 147-158.

  Gleason, J. R. (1998). A table of quantile points of the
    Studentized range distribution.
    http://www.stata.com/stb/stb46/dm64/sturng.pdf
"""
from statsmodels.compat.python import lrange

import math

import numpy as np
from scipy.optimize import fminbound
import scipy.stats

inf = np.inf

__version__ = "0.2.3"

# changelog
# 0.1   - initial release
# 0.1.1 - vectorized
# 0.2   - psturng added
# 0.2.1 - T, R generation script relegated to make_tbls.py
# 0.2.2
#       - select_points refactored for performance to select_ps and
#         select_vs
#       - pysturng tester added.
# 0.2.3 - uses np.inf and np.isinf

# Gleason's table was derived using least square estimation on the tabled
# r values for combinations of p and v. In total there are 206
# estimates over p-values of .5, .75, .9, .95, .975, .99, .995,
# and .999, and over v (degrees of freedom) of (1) - 20, 24, 30, 40,
# 60, 120, and inf. combinations with p < .95 do not have coefficients
# for v = 1. Hence the parentheses. These coefficients allow us to
# form f-hat. f-hat with the inverse t transform of tinv(p,v) yields
# a fairly accurate estimate of the studentized range distribution
# across a wide range of values. According to Gleason this method
# should be more accurate than algorithm AS190 of Lund and Lund (1983)
# and work across a wider range of values (The AS190 only works
# from .9 <= p <= .99). R's qtukey algorithm was used to add tables
# at .675, .8, and .85. These aid approximations when p < .9.
#
# The code that generated this table is called make_tbls.py and is
# located in version control.
A = {
    (0.1, 2.0): [
        -2.2485085243379075,
        -1.5641014278923464,
        0.55942294426816752,
        -0.060006608853883377,
    ],
    (0.1, 3.0): [
        -2.2061105943901564,
        -1.8415406600571855,
        0.61880788039834955,
        -0.062217093661209831,
    ],
    (0.1, 4.0): [
        -2.1686691786678178,
        -2.008196172372553,
        0.65010084431947401,
        -0.06289005500114471,
    ],
    (0.1, 5.0): [
        -2.145077200277393,
        -2.112454843879346,
        0.66701240582821342,
        -0.062993502233654797,
    ],
    (0.1, 6.0): [
        -2.0896098049743155,
        -2.2400004934286497,
        0.70088523391700142,
        -0.065907568563272748,
    ],
    (0.1, 7.0): [
        -2.0689296655661584,
        -2.3078445479584873,
        0.71577374609418909,
        -0.067081034249350552,
    ],
    (0.1, 8.0): [
        -2.0064956480711262,
        -2.437400413087452,
        0.76297532367415266,
        -0.072805518121505458,
    ],
    (0.1, 9.0): [
        -2.3269477513436061,
        -2.0469494712773089,
        0.60662518717720593,
        -0.054887108437009016,
    ],
    (0.1, 10.0): [
        -2.514024350177229,
        -1.8261187841127482,
        0.51674358077906746,
        -0.044590425150963633,
    ],
    (0.1, 11.0): [
        -2.5130181309130828,
        -1.8371718595995694,
        0.51336701694862252,
        -0.043761825829092445,
    ],
    (0.1, 12.0): [
        -2.5203508109278823,
        -1.8355687130611862,
        0.5063486549107169,
        -0.042646205063108261,
    ],
    (0.1, 13.0): [
        -2.5142536438310477,
        -1.8496969402776282,
        0.50616991367764153,
        -0.042378379905665363,
    ],
    (0.1, 14.0): [
        -2.3924634153781352,
        -2.013859173066078,
        0.56421893251638688,
        -0.048716888109540266,
    ],
    (0.1, 15.0): [
        -2.3573552940582574,
        -2.0576676976224362,
        0.57424068771143233,
        -0.049367487649225841,
    ],
    (0.1, 16.0): [
        -2.3046427483044871,
        -2.1295959138627993,
        0.59778272657680553,
        -0.051864829216301617,
    ],
    (0.1, 17.0): [
        -2.2230551072316125,
        -2.2472837435427127,
        0.64255758243215211,
        -0.057186665209197643,
    ],
    (0.1, 18.0): [
        -2.3912859179716897,
        -2.0350604070641269,
        0.55924788749333332,
        -0.047729331835226464,
    ],
    (0.1, 19.0): [
        -2.4169773092220623,
        -2.0048217969339146,
        0.54493039319748915,
        -0.045991241346224065,
    ],
    (0.1, 20.0): [
        -2.4264087194660751,
        -1.9916614057049267,
        0.53583555139648154,
        -0.04463049934517662,
    ],
    (0.1, 24.0): [
        -2.3969903132061869,
        -2.0252941869225345,
        0.53428382141200137,
        -0.043116495567779786,
    ],
    (0.1, 30.0): [
        -2.2509922780354623,
        -2.2309248956124894,
        0.60748041324937263,
        -0.051427415888817322,
    ],
    (0.1, 40.0): [
        -2.1310090183854946,
        -2.3908466074610564,
        0.65844375382323217,
        -0.05676653804036895,
    ],
    (0.1, 60.0): [
        -1.9240060179027036,
        -2.6685751031012233,
        0.75678826647453024,
        -0.067938584352398995,
    ],
    (0.1, 120.0): [
        -1.9814895487030182,
        -2.5962051736978373,
        0.71793969041292693,
        -0.063126863201511618,
    ],
    (0.1, inf): [
        -1.913410267066703,
        -2.6947367328724732,
        0.74742335122750592,
        -0.06660897234304515,
    ],
    (0.5, 2.0): [
        -0.88295935738770648,
        -0.1083576698911433,
        0.035214966839394388,
        -0.0028576288978276461,
    ],
    (0.5, 3.0): [
        -0.89085829205846834,
        -0.10255696422201063,
        0.033613638666631696,
        -0.0027101699918520737,
    ],
    (0.5, 4.0): [
        -0.89627345339338116,
        -0.099072524607668286,
        0.032657774808907684,
        -0.0026219007698204916,
    ],
    (0.5, 5.0): [
        -0.89959145511941052,
        -0.097272836582026817,
        0.032236187675182958,
        -0.0025911555217019663,
    ],
    (0.5, 6.0): [
        -0.89959428735702474,
        -0.098176292411106647,
        0.032590766960226995,
        -0.0026319890073613164,
    ],
    (0.5, 7.0): [
        -0.90131491102863937,
        -0.097135907620296544,
        0.032304124993269533,
        -0.0026057965808244125,
    ],
    (0.5, 8.0): [
        -0.90292500599432901,
        -0.096047500971337962,
        0.032030946615574568,
        -0.0025848748659053891,
    ],
    (0.5, 9.0): [
        -0.90385598607803697,
        -0.095390771554571888,
        0.031832651111105899,
        -0.0025656060219315991,
    ],
    (0.5, 10.0): [
        -0.90562524936125388,
        -0.093954488089771915,
        0.031414451048323286,
        -0.0025257834705432031,
    ],
    (0.5, 11.0): [
        -0.90420347371173826,
        -0.095851656370277288,
        0.0321150356209743,
        -0.0026055056400093451,
    ],
    (0.5, 12.0): [
        -0.90585973471757664,
        -0.094449306296728028,
        0.031705945923210958,
        -0.0025673330195780191,
    ],
    (0.5, 13.0): [
        -0.90555437067293054,
        -0.094792991050780248,
        0.031826594964571089,
        -0.0025807109129488545,
    ],
    (0.5, 14.0): [
        -0.90652756604388762,
        -0.093792156994564738,
        0.031468966328889042,
        -0.0025395175361083741,
    ],
    (0.5, 15.0): [
        -0.90642323700400085,
        -0.094173017520487984,
        0.031657517378893905,
        -0.0025659271829033877,
    ],
    (0.5, 16.0): [
        -0.90716338636685234,
        -0.093785178083820434,
        0.031630091949657997,
        -0.0025701459247416637,
    ],
    (0.5, 17.0): [
        -0.90790133816769714,
        -0.093001147638638884,
        0.031376863944487084,
        -0.002545143621663892,
    ],
    (0.5, 18.0): [
        -0.9077432927051563,
        -0.093343516378180599,
        0.031518139662395313,
        -0.0025613906133277178,
    ],
    (0.5, 19.0): [
        -0.90789499456490286,
        -0.09316964789456067,
        0.031440782366342901,
        -0.0025498353345867453,
    ],
    (0.5, 20.0): [
        -0.90842707861030725,
        -0.092696016476608592,
        0.031296040311388329,
        -0.0025346963982742186,
    ],
    (0.5, 24.0): [
        -0.9083281347135469,
        -0.092959308144970776,
        0.031464063190077093,
        -0.0025611384271086285,
    ],
    (0.5, 30.0): [
        -0.90857624050016828,
        -0.093043139391980514,
        0.031578791729341332,
        -0.0025766595412777147,
    ],
    (0.5, 40.0): [
        -0.91034085045438684,
        -0.091978035738914568,
        0.031451631000052639,
        -0.0025791418103733297,
    ],
    (0.5, 60.0): [
        -0.91084356681030032,
        -0.091452675572423425,
        0.031333147984820044,
        -0.0025669786958144843,
    ],
    (0.5, 120.0): [
        -0.90963649561463833,
        -0.093414563261352349,
        0.032215602703677425,
        -0.0026704024780441257,
    ],
    (0.5, inf): [
        -0.91077157500981665,
        -0.092899220350334571,
        0.032230422399363315,
        -0.0026696941964372916,
    ],
    (0.675, 2.0): [
        -0.67231521026565144,
        -0.097083624030663451,
        0.027991378901661649,
        -0.0021425184069845558,
    ],
    (0.675, 3.0): [
        -0.65661724764645824,
        -0.08147195494632696,
        0.02345732427073333,
        -0.0017448570400999351,
    ],
    (0.675, 4.0): [
        -0.65045677697461124,
        -0.071419073399450431,
        0.020741962576852499,
        -0.0015171262565892491,
    ],
    (0.675, 5.0): [
        -0.64718875357808325,
        -0.064720611425218344,
        0.019053450246546449,
        -0.0013836232986228711,
    ],
    (0.675, 6.0): [
        -0.64523003702018655,
        -0.059926313672731824,
        0.017918997181483924,
        -0.0012992250285556828,
    ],
    (0.675, 7.0): [
        -0.64403313148478836,
        -0.056248191513784476,
        0.017091446791293721,
        -0.0012406558789511822,
    ],
    (0.675, 8.0): [
        -0.64325095865764359,
        -0.053352543126426684,
        0.016471879286491072,
        -0.0011991839050964099,
    ],
    (0.675, 9.0): [
        -0.64271152754911653,
        -0.051023769620449078,
        0.01599799600547195,
        -0.0011693637984597086,
    ],
    (0.675, 10.0): [
        -0.64232244408502626,
        -0.049118327462884373,
        0.015629704966568955,
        -0.0011477775513952285,
    ],
    (0.675, 11.0): [
        -0.64203897854353564,
        -0.047524627960277892,
        0.015334801262767227,
        -0.0011315057284007177,
    ],
    (0.675, 12.0): [
        -0.64180344973512771,
        -0.046205907576003291,
        0.015108290595438166,
        -0.0011207364514518488,
    ],
    (0.675, 13.0): [
        -0.64162086456823342,
        -0.045076099336874231,
        0.0149226565346125,
        -0.0011126140690497352,
    ],
    (0.675, 14.0): [
        -0.64146906480198984,
        -0.044108523550512715,
        0.014772954218646743,
        -0.0011069708562369386,
    ],
    (0.675, 15.0): [
        -0.64133915151966603,
        -0.043273370927039825,
        0.014651691599222836,
        -0.0011032216539514398,
    ],
    (0.675, 16.0): [
        -0.64123237842752079,
        -0.042538925012463868,
        0.014549992487506169,
        -0.0011005633864334021,
    ],
    (0.675, 17.0): [
        -0.64113034037536609,
        -0.041905699463005854,
        0.014470805560767184,
        -0.0010995286436738471,
    ],
    (0.675, 18.0): [
        -0.64104137391561256,
        -0.041343885546229336,
        0.014404563657113593,
        -0.0010991304223377683,
    ],
    (0.675, 19.0): [
        -0.64096064882827297,
        -0.04084569291139839,
        0.014350159655133801,
        -0.0010993656711121901,
    ],
    (0.675, 20.0): [
        -0.64088647405089572,
        -0.040402175957178085,
        0.014305769823654429,
        -0.0011001304776712105,
    ],
    (0.675, 24.0): [
        -0.64063763965937837,
        -0.039034716348048545,
        0.014196703837251648,
        -0.0011061961945598175,
    ],
    (0.675, 30.0): [
        -0.64034987716294889,
        -0.037749651156941719,
        0.014147040999127263,
        -0.0011188251352919833,
    ],
    (0.675, 40.0): [
        -0.6399990514713938,
        -0.036583307574857803,
        0.014172070700846548,
        -0.0011391004138624943,
    ],
    (0.675, 60.0): [
        -0.63955586202430248,
        -0.035576938958184395,
        0.014287299153378865,
        -0.0011675811805794236,
    ],
    (0.675, 120.0): [
        -0.63899242674778622,
        -0.034763757512388853,
        0.014500726912982405,
        -0.0012028491454427466,
    ],
    (0.675, inf): [
        -0.63832682579247613,
        -0.034101476695520404,
        0.014780921043580184,
        -0.0012366204114216408,
    ],
    (0.75, 2.0): [
        -0.60684073638504454,
        -0.096375192078057031,
        0.026567529471304554,
        -0.0019963228971914488,
    ],
    (0.75, 3.0): [
        -0.57986144519102656,
        -0.078570292718034881,
        0.021280637925009449,
        -0.0015329306898533772,
    ],
    (0.75, 4.0): [
        -0.56820771686193594,
        -0.0668113563896649,
        0.018065284051059189,
        -0.0012641485481533648,
    ],
    (0.75, 5.0): [
        -0.56175292435740221,
        -0.058864526929603825,
        0.016046735025708799,
        -0.0011052560286524044,
    ],
    (0.75, 6.0): [
        -0.55773449282066356,
        -0.053136923269827351,
        0.014684258167069347,
        -0.0010042826823561605,
    ],
    (0.75, 7.0): [
        -0.55509524598867332,
        -0.048752649191139405,
        0.013696566605823626,
        -0.00093482210003133898,
    ],
    (0.75, 8.0): [
        -0.55324993686191515,
        -0.045305558708724644,
        0.012959681992062138,
        -0.00088583541601696021,
    ],
    (0.75, 9.0): [
        -0.55189259054026196,
        -0.042539819902381634,
        0.012398791106424769,
        -0.00085083962241435827,
    ],
    (0.75, 10.0): [
        -0.55085384656956893,
        -0.040281425755686585,
        0.01196442242722482,
        -0.00082560322161492677,
    ],
    (0.75, 11.0): [
        -0.55003198103541273,
        -0.038410176100193948,
        0.011623294239447784,
        -0.00080732975034320073,
    ],
    (0.75, 12.0): [
        -0.54936541596319177,
        -0.036838543267887103,
        0.011351822637895701,
        -0.0007940703654926442,
    ],
    (0.75, 13.0): [
        -0.54881015972753833,
        -0.035506710625568455,
        0.011134691307865171,
        -0.0007846360016355809,
    ],
    (0.75, 14.0): [
        -0.54834094346071949,
        -0.034364790609906569,
        0.010958873929274728,
        -0.00077796645357008291,
    ],
    (0.75, 15.0): [
        -0.54793602418304255,
        -0.033379237455748029,
        0.010816140998057593,
        -0.00077344175064785099,
    ],
    (0.75, 16.0): [
        -0.54758347689728037,
        -0.032520569145898917,
        0.010699240399358219,
        -0.00077050847328596678,
    ],
    (0.75, 17.0): [
        -0.54727115963795303,
        -0.031769277192927527,
        0.010603749751170481,
        -0.0007688642392748113,
    ],
    (0.75, 18.0): [
        -0.54699351808826535,
        -0.031105476267880995,
        0.010524669113016114,
        -0.00076810656837464093,
    ],
    (0.75, 19.0): [
        -0.54674357626419079,
        -0.030516967201954001,
        0.010459478822937069,
        -0.00076808652582440037,
    ],
    (0.75, 20.0): [
        -0.54651728378950126,
        -0.029992319199769232,
        0.010405694998386575,
        -0.0007686417223966138,
    ],
    (0.75, 24.0): [
        -0.54578309546828363,
        -0.028372628574010936,
        0.010269939602271542,
        -0.00077427370647261838,
    ],
    (0.75, 30.0): [
        -0.54501246434397554,
        -0.026834887880579802,
        0.010195603314317611,
        -0.00078648615954105515,
    ],
    (0.75, 40.0): [
        -0.54418127442022624,
        -0.025413224488871379,
        0.010196455193836855,
        -0.00080610785749523739,
    ],
    (0.75, 60.0): [
        -0.543265189207915,
        -0.024141961069146383,
        0.010285001019536088,
        -0.00083332193364294587,
    ],
    (0.75, 120.0): [
        -0.54224757817994806,
        -0.023039071833948214,
        0.010463365295636302,
        -0.00086612828539477918,
    ],
    (0.75, inf): [
        -0.54114579815367159,
        -0.02206592527426093,
        0.01070374099737127,
        -0.00089726564005122183,
    ],
    (0.8, 2.0): [
        -0.56895274046831146,
        -0.096326255190541957,
        0.025815915364208686,
        -0.0019136561019354845,
    ],
    (0.8, 3.0): [
        -0.5336038380862278,
        -0.077585191014876181,
        0.020184759265389905,
        -0.0014242746007323785,
    ],
    (0.8, 4.0): [
        -0.51780274285934258,
        -0.064987738443608709,
        0.016713309796866204,
        -0.001135379856633562,
    ],
    (0.8, 5.0): [
        -0.50894361222268403,
        -0.056379186603362705,
        0.014511270339773345,
        -0.00096225604117493205,
    ],
    (0.8, 6.0): [
        -0.50335153028630408,
        -0.050168860294790812,
        0.01302807093593626,
        -0.00085269812692536306,
    ],
    (0.8, 7.0): [
        -0.49960934380896432,
        -0.045417333787806033,
        0.011955593330247398,
        -0.00077759605604250882,
    ],
    (0.8, 8.0): [
        -0.49694518248979763,
        -0.041689151516021969,
        0.011158986677273709,
        -0.00072497430103953366,
    ],
    (0.8, 9.0): [
        -0.4949559974898507,
        -0.038702217132906024,
        0.010554360004521268,
        -0.0006875213117164109,
    ],
    (0.8, 10.0): [
        -0.49341407910162483,
        -0.036266788741325398,
        0.010087354421936092,
        -0.00066060835062865602,
    ],
    (0.8, 11.0): [
        -0.49218129312493897,
        -0.034252403643273498,
        0.0097218584838579536,
        -0.00064123459335201907,
    ],
    (0.8, 12.0): [
        -0.49117223957112183,
        -0.032563269730499021,
        0.0094318583096021404,
        -0.00062725253852419032,
    ],
    (0.8, 13.0): [
        -0.49032781145131277,
        -0.031132495018324432,
        0.0091999762562792898,
        -0.0006172944366003854,
    ],
    (0.8, 14.0): [
        -0.48961049628464259,
        -0.029906921170494854,
        0.009012451847823854,
        -0.00061026211968669543,
    ],
    (0.8, 15.0): [
        -0.48899069793054922,
        -0.028849609914548158,
        0.0088602820002619594,
        -0.00060548991575179055,
    ],
    (0.8, 16.0): [
        -0.48844921216636505,
        -0.027929790075266154,
        0.00873599263877896,
        -0.00060242119796859379,
    ],
    (0.8, 17.0): [
        -0.48797119683309537,
        -0.027123634910159868,
        0.0086338139869481887,
        -0.00060061821593399998,
    ],
    (0.8, 18.0): [
        -0.48754596864745836,
        -0.026411968723496961,
        0.0085493196604705755,
        -0.00059977083160833624,
    ],
    (0.8, 19.0): [
        -0.48716341805691843,
        -0.025781422230819986,
        0.0084796655915025769,
        -0.00059970031758323466,
    ],
    (0.8, 20.0): [
        -0.48681739197185547,
        -0.025219629852198749,
        0.0084221844254287765,
        -0.00060023212822886711,
    ],
    (0.8, 24.0): [
        -0.48570639629281365,
        -0.023480608772518948,
        0.008274490561114187,
        -0.000605681105792215,
    ],
    (0.8, 30.0): [
        -0.48455867067770253,
        -0.021824655071720423,
        0.0081888502974720567,
        -0.00061762126933785633,
    ],
    (0.8, 40.0): [
        -0.48335478729267423,
        -0.020279958998363389,
        0.0081765095914194709,
        -0.00063657117129829635,
    ],
    (0.8, 60.0): [
        -0.48207351944996679,
        -0.018875344346672228,
        0.0082473997191472338,
        -0.00066242478479277243,
    ],
    (0.8, 120.0): [
        -0.48070356185330182,
        -0.017621686995755746,
        0.0084009638803223801,
        -0.00069300383808949318,
    ],
    (0.8, inf): [
        -0.47926687718713606,
        -0.016476575352367202,
        0.0086097059646591811,
        -0.00072160843492730911,
    ],
    (0.85, 2.0): [
        -0.53366806986381743,
        -0.098288178252723263,
        0.026002333446289064,
        -0.0019567144268844896,
    ],
    (0.85, 3.0): [
        -0.48995919239619989,
        -0.077312722648418056,
        0.019368984865418108,
        -0.0013449670192265796,
    ],
    (0.85, 4.0): [
        -0.46956079162382858,
        -0.063818518513946695,
        0.015581608910696544,
        -0.0010264315084377606,
    ],
    (0.85, 5.0): [
        -0.45790853796153624,
        -0.054680511194530226,
        0.013229852432203093,
        -0.00084248430847535898,
    ],
    (0.85, 6.0): [
        -0.4505070841695738,
        -0.048050936682873302,
        0.011636407582714191,
        -0.00072491480033529815,
    ],
    (0.85, 7.0): [
        -0.44548337477336181,
        -0.042996612516383016,
        0.010493052959891263,
        -0.00064528784792153239,
    ],
    (0.85, 8.0): [
        -0.44186624932664148,
        -0.039040005821657585,
        0.0096479530794160544,
        -0.00058990874360967567,
    ],
    (0.85, 9.0): [
        -0.43914118689812259,
        -0.035875693030752713,
        0.0090088804130628187,
        -0.00055071480339399694,
    ],
    (0.85, 10.0): [
        -0.43701255390953769,
        -0.033300997407157376,
        0.0085172159355344848,
        -0.00052272770799695464,
    ],
    (0.85, 11.0): [
        -0.43530109064899053,
        -0.031174742038490313,
        0.0081335619868386066,
        -0.00050268353809787927,
    ],
    (0.85, 12.0): [
        -0.43389220376610071,
        -0.02939618314990838,
        0.007830626267772851,
        -0.00048836431712678222,
    ],
    (0.85, 13.0): [
        -0.43271026958463166,
        -0.027890759135246888,
        0.0075886916668632936,
        -0.00047819339710596971,
    ],
    (0.85, 14.0): [
        -0.43170230265007209,
        -0.026604156062396189,
        0.0073939099688705547,
        -0.00047109996854335419,
    ],
    (0.85, 15.0): [
        -0.43083160459377423,
        -0.025494228911600785,
        0.0072358738657550868,
        -0.00046630677052262481,
    ],
    (0.85, 16.0): [
        -0.4300699280587239,
        -0.024529612608808794,
        0.0071069227026219683,
        -0.00046323869860941791,
    ],
    (0.85, 17.0): [
        -0.42939734931902857,
        -0.023685025616054269,
        0.0070011541609695891,
        -0.00046147954942994158,
    ],
    (0.85, 18.0): [
        -0.42879829041505324,
        -0.022940655682782165,
        0.006914006369119409,
        -0.00046070877994711774,
    ],
    (0.85, 19.0): [
        -0.42826119448419875,
        -0.022280181781634649,
        0.0068417746905826433,
        -0.00046066841214091982,
    ],
    (0.85, 20.0): [
        -0.42777654887094479,
        -0.021690909076747832,
        0.0067817408643717969,
        -0.00046118620289068032,
    ],
    (0.85, 24.0): [
        -0.42622450033640852,
        -0.019869646711890065,
        0.0066276799593494029,
        -0.00046668820637553747,
    ],
    (0.85, 30.0): [
        -0.42463810443233418,
        -0.018130114737381745,
        0.0065344613060499164,
        -0.00047835583417510423,
    ],
    (0.85, 40.0): [
        -0.42299917804589382,
        -0.016498222901308417,
        0.0065120558343578407,
        -0.00049656043685325469,
    ],
    (0.85, 60.0): [
        -0.42129387265810464,
        -0.014992121475265813,
        0.0065657795990087635,
        -0.00052069705640687698,
    ],
    (0.85, 120.0): [
        -0.41951580476366368,
        -0.013615722489371183,
        0.0066923911275726814,
        -0.00054846911649167492,
    ],
    (0.85, inf): [
        -0.41768751825428968,
        -0.012327525092266726,
        0.0068664920569562592,
        -0.00057403720261753539,
    ],
    (0.9, 1.0): [
        -0.65851063279096722,
        -0.126716242078905,
        0.036318801917603061,
        -0.002901283222928193,
    ],
    (0.9, 2.0): [
        -0.50391945369829139,
        -0.096996108021146235,
        0.024726437623473398,
        -0.0017901399938303017,
    ],
    (0.9, 3.0): [
        -0.44799791843058734,
        -0.077180370333307199,
        0.018584042055594469,
        -0.0012647038118363408,
    ],
    (0.9, 4.0): [
        -0.42164091756145167,
        -0.063427071006287514,
        0.014732203755741392,
        -0.00094904174117957688,
    ],
    (0.9, 5.0): [
        -0.40686856251221754,
        -0.053361940054842398,
        0.012041802076025801,
        -0.00072960198292410612,
    ],
    (0.9, 6.0): [
        -0.39669926026535285,
        -0.046951517438004242,
        0.010546647213094956,
        -0.00062621198002366064,
    ],
    (0.9, 7.0): [
        -0.39006553675807426,
        -0.04169480606532109,
        0.0093687546601737195,
        -0.00054648695713273862,
    ],
    (0.9, 8.0): [
        -0.38570205067061908,
        -0.037083910859179794,
        0.0083233218526375836,
        -0.00047177586974035451,
    ],
    (0.9, 9.0): [
        -0.38190737267892938,
        -0.034004585655388865,
        0.0077531991574119183,
        -0.00044306547308527872,
    ],
    (0.9, 10.0): [
        -0.37893272918125737,
        -0.031394677600916979,
        0.0072596802503533536,
        -0.0004160518834299966,
    ],
    (0.9, 11.0): [
        -0.37692512492705132,
        -0.028780793403136471,
        0.0066937909049060379,
        -0.00037420010136784526,
    ],
    (0.9, 12.0): [
        -0.37506345200129187,
        -0.026956483290567372,
        0.0064147730707776523,
        -0.00036595383207062906,
    ],
    (0.9, 13.0): [
        -0.37339516122383209,
        -0.02543949524844704,
        0.0061760656530197187,
        -0.00035678737379179527,
    ],
    (0.9, 14.0): [
        -0.37216979891087842,
        -0.02396347606956644,
        0.0059263234465969641,
        -0.0003439784452550796,
    ],
    (0.9, 15.0): [
        -0.371209456600122,
        -0.022696132732654414,
        0.0057521677184623147,
        -0.00033961108561770848,
    ],
    (0.9, 16.0): [
        -0.36958924377983338,
        -0.022227885445863002,
        0.0057691706799383926,
        -0.00035042762538099682,
    ],
    (0.9, 17.0): [
        -0.36884224719083203,
        -0.021146977888668726,
        0.0055957928269732716,
        -0.00034283810412697531,
    ],
    (0.9, 18.0): [
        -0.36803087186793326,
        -0.020337731477576542,
        0.0054655378095212759,
        -0.00033452966946535248,
    ],
    (0.9, 19.0): [
        -0.3676700404163355,
        -0.019370115848857467,
        0.0053249296207149655,
        -0.00032975528909580403,
    ],
    (0.9, 20.0): [
        -0.36642276267188811,
        -0.019344251412284838,
        0.0054454968582897528,
        -0.00034868111677540948,
    ],
    (0.9, 24.0): [
        -0.36450650753755193,
        -0.017284255499990679,
        0.0052337500059176749,
        -0.00034898202845747288,
    ],
    (0.9, 30.0): [
        -0.36251868940168608,
        -0.015358560437631397,
        0.0050914299956134786,
        -0.00035574528891633978,
    ],
    (0.9, 40.0): [
        -0.36008886676510943,
        -0.014016835682905486,
        0.0051930835959111514,
        -0.00038798316011984165,
    ],
    (0.9, 60.0): [
        -0.35825590690268061,
        -0.011991568926537646,
        0.0050632208542414191,
        -0.00039090198974493085,
    ],
    (0.9, 120.0): [
        -0.35543612237284411,
        -0.011074403997811812,
        0.0053504570752765162,
        -0.00043647137428074178,
    ],
    (0.9, inf): [
        -0.35311806343057167,
        -0.0096254020092145353,
        0.0054548591208177181,
        -0.00045343916634968493,
    ],
    (0.95, 1.0): [
        -0.65330318136020071,
        -0.12638310760474375,
        0.035987535130769424,
        -0.0028562665467665315,
    ],
    (0.95, 2.0): [
        -0.47225160417826934,
        -0.10182570362271424,
        0.025846563499059158,
        -0.0019096769058043243,
    ],
    (0.95, 3.0): [
        -0.4056635555586528,
        -0.077067172693350297,
        0.017789909647225533,
        -0.001182961668735774,
    ],
    (0.95, 4.0): [
        -0.37041675177340955,
        -0.063815687118939465,
        0.014115210247737845,
        -0.00089996098435117598,
    ],
    (0.95, 5.0): [
        -0.35152398291152309,
        -0.052156502640669317,
        0.010753738086401853,
        -0.0005986841939451575,
    ],
    (0.95, 6.0): [
        -0.33806730015201264,
        -0.045668399809578597,
        0.0093168898952878162,
        -0.00051369719615782102,
    ],
    (0.95, 7.0): [
        -0.32924041072104465,
        -0.040019601775490091,
        0.0080051199552865163,
        -0.00042054536135868043,
    ],
    (0.95, 8.0): [
        -0.32289030266989077,
        -0.035575345931670443,
        0.0070509089344694669,
        -0.00035980773304803576,
    ],
    (0.95, 9.0): [
        -0.31767304201477375,
        -0.032464945930165703,
        0.0064755950437272143,
        -0.0003316676253661824,
    ],
    (0.95, 10.0): [
        -0.31424318064708656,
        -0.029133461621153,
        0.0057437449431074795,
        -0.00027894252261209191,
    ],
    (0.95, 11.0): [
        -0.31113589620384974,
        -0.02685115250591049,
        0.0053517905282942889,
        -0.00026155954116874666,
    ],
    (0.95, 12.0): [
        -0.30848983612414582,
        -0.025043238019239168,
        0.0050661675913488829,
        -0.00025017202909614005,
    ],
    (0.95, 13.0): [
        -0.3059212907410393,
        -0.023863874699213077,
        0.0049618051135807322,
        -0.00025665425781125703,
    ],
    (0.95, 14.0): [
        -0.30449676902720035,
        -0.021983976741572344,
        0.0045740513735751968,
        -0.00022881166323945914,
    ],
    (0.95, 15.0): [
        -0.30264908294481396,
        -0.02104880307520084,
        0.0044866571614804382,
        -0.00023187587597844057,
    ],
    (0.95, 16.0): [
        -0.30118294463097917,
        -0.020160231061926728,
        0.0044170780759056859,
        -0.00023733502359045826,
    ],
    (0.95, 17.0): [
        -0.30020013353427744,
        -0.018959271614471574,
        0.0041925333038202285,
        -0.00022274025630789767,
    ],
    (0.95, 18.0): [
        -0.29857886556874402,
        -0.018664437456802001,
        0.0042557787632833697,
        -0.00023758868868853716,
    ],
    (0.95, 19.0): [
        -0.29796289236978263,
        -0.017632218552317589,
        0.0040792779937959866,
        -0.00022753271474613109,
    ],
    (0.95, 20.0): [
        -0.29681506554838077,
        -0.017302563243037392,
        0.0041188426221428964,
        -0.00023913038468772782,
    ],
    (0.95, 24.0): [
        -0.29403146911167666,
        -0.015332330986025032,
        0.0039292170319163728,
        -0.00024003445648641732,
    ],
    (0.95, 30.0): [
        -0.29080775563775879,
        -0.013844059210779323,
        0.0039279165616059892,
        -0.00026085104496801666,
    ],
    (0.95, 40.0): [
        -0.28821583032805109,
        -0.011894686715666892,
        0.0038202623278839982,
        -0.00026933325102031252,
    ],
    (0.95, 60.0): [
        -0.28525636737751447,
        -0.010235910558409797,
        0.0038147029777580001,
        -0.00028598362144178959,
    ],
    (0.95, 120.0): [
        -0.28241065885026539,
        -0.0086103836327305026,
        0.0038450612886908714,
        -0.00030206053671559411,
    ],
    (0.95, inf): [
        -0.27885570064169296,
        -0.0078122455524849222,
        0.0041798538053623453,
        -0.0003469494881774609,
    ],
    (0.975, 1.0): [
        -0.65203598304297983,
        -0.12608944279227957,
        0.035710038757117347,
        -0.0028116024425349053,
    ],
    (0.975, 2.0): [
        -0.46371891130382281,
        -0.096954458319996509,
