• Back to MAIN



  • Statistics -- light version

    operatorQsample
    comb[n,m]k) comb:{(*/1f*y#|!1+x)%*/1f+!y}comb[8;3] .. 56f (0f for y>x)
    std (deviation)std:{sqrt (sum l*l:x-avg x)%-1+count x}std 1+til 6 .. 1.87
    variancevarp:{i*i:std x}varp 1+til 6 .. 3.5
    GAUSS g:{abs (neg x>0f)+(1f%sqrt 2f*pi)*(exp -0.5*x*x)*t*0.31938153+t*-0.356563782+ ..
    .. t*1.781477937+t*-1.821255978+1.330274429*t:1f%1f+0.2316419*abs x}
    g 0 .. 0.5 (pi:acos -1)
    GAUSSinverse(9-digit precision) /static data
    a1:-39.69683028665376;a2:220.9460984245205;a3:-275.9285104469687
    a4:138.3577518672690;a5:-30.66479806614716;a6:2.506628277459239

    b1:-54.47609879822406;b2:161.5858368580409;b3:-155.6989798598866
    b4:66.80131188771972;b5:-13.28068155288572

    c1:-7.784894002430293e-03;c2:-3.223964580411365e-01;c3:-2.400758277161838
    c4:-2.549732539343734;c5:4.374664141464968;c6:2.938163982698783

    d1:7.784695709041462e-03;d2:3.224671290700398e-01;d3:2.445134137142996;d4:3.754408661907416

    pl:0.02425;ph:1f-pl

    /rational approximation lower region:(x>0f)&x < pl
    icnd1:{q:sqrt@-2f*log x;(c6+q*c5+q*c4+q*c3+q*c2+q*c1)%1f+q*d4+q*d3+q*d2+q*d1}

    /Rational approximation for central region:(p<=ph) and p >= pl
    icnd2:{r:q*q:x-0.5;(q*a6+r*a5+r*a4+r*a3+r*a2+r*a1)%1+r*b5+r*b4+r*b3+r*b2+r*b1}

    /Rational approximation for upper region:(x<1f) and x > ph
    icnd3:{q:sqrt -2f*log 1-x;neg (c6+q*c5+q*c4+q*c3+q*c2+q*c1)%1f+q*d4+q*d3+q*d2+q*d1}

    pf1:{where (x>0f) and x < pl}
    pf2:{where not (x>ph) or x < pl}
    pf3:{where (x<1f) and x > ph}

    k)igauss:{j:x;p1:pf1 x;p2:pf2 x;p3:pf3 x;if[0<#p1;j:@[j;p1;:;icnd1 j@p1]];if[0<#p2;j:@[j;p2;:;icnd2 j@p2]];if[0<#p3;j:@[j;p3;:;icnd3 j@p3]];:j}

    /example

    s:0.889 0.991 0.00045 0.4 0.99991 0.777 0.5 0.993
    igauss s .. 1.221227 2.365618 -3.320054 -0.2533471 3.745549 0.7621005 0 2.457263
    igauss enlist 0.75 .. ,0.6744898
    covp .. covariance covp:{(sum(x-avg x)*y-avg y)%-1+count x} covp . (x;y)
    corrp .. correlationcorrp:{(sum i*j)%sqrt(sum j*j:y-avg y)*sum i*i:x-avg x}corrp . (x;y)
    indep .. independency of random variables
    (T-distributed)
    indep:{c*sqrt (-2+count first x)%1-c*c:corrp . x} indep@(x;y) ..
    regr .. lin.regressionregr:{(avg y-i*avg x),i:((std y)%std x)*corrp . (x;y)} (or just use y!m)regr . (x;y) .. (y ord,slope)
    regrTest .. regression test (T distributed)regrTest:{((sqrt (-2f+count x)%(a*a:std y)-u*u:t*i))*(i:std x)*abs z-t:last regr . (x;y)}regrTest . (x;y;z)
    marg .. marginal distribution (KHI squared)marg:{sum (t*t:u-raze c)%u:(prd each i cross sum 1f*c:flip x)%sum i:sum x}marg M
    hypp .. testing of hypothetical probabilities(KHI squared)hypp:{sum (i*i:y-l)%l:(count y)#x*sum y}hypp . (P;x)
    dtt .. double T-test (T distributed)dtt:{((avg y)-avg x)*sqrt (1f%r*((varp x)*u-1f)+(varp y)*v-1f)*(-2f+r:u+v)*(v:count y)*(u:count x)}dtt . (x;y)
    bdt .. bonded test .. bdt: {std y-x}bdt . (x;y)
    dsg .. double sided gauss avg test (T distributed)dsg:{abs (x-avg y)*(sqrt count y)%std y}dsg . (M;x)
    regrp .. polynomial regression regrp:{u:x+1;r:sum each w:(enlist (count y)#1f),prds (2*x)#enlist 1f*y;b:u {1 rotate x}\r;s:u#u#'b;
    :raze (inv s)$flip enlist 1f*sum flip (u#enlist z)*u#w;}
    regrp . (n;x;y)

  • Back to MAIN