The Chi-Squared-Distribution - Compute and visualize in Java

in #programming6 years ago

ChiQuadratVerteilung.png

Today I add the chi-square distribution to my collection.

Since the same parameters are used here as for the student's t-distribution, the GUI does not need to be extended.

Calculation of the distribution

    double dchisq(double x, int df) {
        if (x<=0) {
            return 0.0;
        }
        
        return
            (Math.pow(x, df/2.0 - 1.0) * Math.exp(-(x/2.0))) / 
            (Math.pow(2, df/2.0) * XMath.gamma(df/2.0));
    }
    
    public double qchisq(double alpha, int df) {
        double sum = 0;
        double pos = 0;
        double stepSize = 0.01;
        while (sum<alpha) {
            sum += dchisq(pos, df)*stepSize;
            pos += stepSize;
        }
        return pos;
    }

Other distributions:

Sort:  

Cool demonstration 👍

Coin Marketplace

STEEM 0.36
TRX 0.12
JST 0.039
BTC 69735.97
ETH 3533.64
USDT 1.00
SBD 4.72