Question: How to properly invert and add scale and location parameters to a probability distribution from a built-in distribution?

Hello community,

Could I please get help on how to invert a probability distribution (reciprocal of) and add the location and scale parameters? The distribution in question is from the built-in (Statistics package) of ChiSquare(n) transformed into a scaled inverse Chi Square with location (shift) parameters.

I have tried the following which results in verified (correct) empirical (sampled) data, but have not been equally successful in the theoretical moments and its quantiles.

 

restart;
st:=time():

with(Statistics):

 

InvChi2:=proc(a,b,n)
        description "inverse chisquare distribution with a=location, b=scale, n=degrees of freedom";


        local CHI := RandomVariable(ChiSquare(n)):
        
        Distribution(
                CDF = unapply(CDF(b*n/CHI+a,t),t),
                PDF = unapply(PDF(b*n/CHI+a,t),t),
                Mean = a+~Mean(b*n/CHI),
                Median = a+~Median(b*n/CHI),
                Variance = simplify(CentralMoment(a+b*n/CHI,2)),
                Skewness = simplify(CentralMoment(b*n/CHI, 3) / CentralMoment(b*n/CHI,2)^(3/2)),
                Kurtosis = simplify(CentralMoment(b*n/CHI, 4) / CentralMoment(b*n/CHI,2)^2),
                Conditions = [b > 0],
                RandomSample = proc(N::nonnegint)
                                a+~Sample(b*n/CHI,N)
                        end proc
                );
        end proc:

 

T:= RandomVariable(InvChi2(2,4.32,3))

 

 

_R0

(1)

evalf(Median(T))

FAIL

(2)

evalf(Mean(T))

14.96000000

(3)

Variance(T)

Float(infinity)

(4)

Skewness(T)

Float(undefined)

(5)

Kurtosis(T)

Float(undefined)

(6)

Quantile(T,.25)

FAIL

(7)

A:=Sample(T,10^5):

Median(A)

HFloat(7.509476657413067)

(8)

Mean(A)

HFloat(14.419072346310452)

(9)

Variance(A)

HFloat(2692.8025716746843)

(10)

Skewness(A)

HFloat(47.59107730088799)

(11)

Quantile(A,.25)

HFloat(5.177452862452726)

(12)

Quantile(A,.75)

HFloat(12.76851658170427)

(13)

printf("Time to execute worksheet = %a seconds", time() - st)

Time to execute worksheet = 2.813 seconds

 

 


Download invChi2.mw

Thank you

Please Wait...