NanaP

40 Reputation

3 Badges

1 years, 289 days

MaplePrimes Activity


These are questions asked by NanaP

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

Hi community!

In the mw file attached, I have worked a numerical solution to get the standard parameters of minimum and maximum of the distribution Triangular(a,b,c) given 2 quantiles (and its values) and c.  The code works and was simple.  Now, how do I solve this more elegantly to have the reparameterization directly inputed instead of indirectly by solving a & b first (like the attached file does)? Thanks people,altTriangular2.mw

Hello community, I am new in this forum and sorry if the following seems rudimentary:

I am replicating a distribution function using Statistics[Distribution] as defined here:

Vose Software's Beta Subjective

I have tested numerically and the function works for this initial values: Min := 3; Mlikely := 8; Avg := 9; Max := 18;

But failed to complete with these values (which I tested works in another software) Min := 1000; Mlikely := 1400; Avg := 1500; Max := 2100;

What puzzles me is the inconsistency of handling the functions (be aware that the server kernel could be slow at times). I hope I don't have to give up and continue my custom distribution project in another software.

Here is the document: 

NULL

The Beta Subjective Distribution

 

 

restart

 

with(Statistics)

NULL

Min := 3; Mlikely := 8; Avg := 9; Max := 18

18

(1)

NULL

Mid := (Min+Max)*(1/2)

21/2

(2)

alpha := 2*(Avg-Min)*(Mid-Mlikely)/((Avg-Mlikely)*(Max-Min))

2

(3)

beta := alpha*(Max-Avg)/(Avg-Min)

3

(4)

NULLNULLNULLNULL

NULL

f := simplify(piecewise(Min <= x and x <= Max, (x-Min)^(alpha-1)*(Max-x)^(beta-1)/(Beta(alpha, beta)*(Max-Min)^(alpha+beta-1)), 0))

piecewise(x < 3, 0, x <= 18, (4/16875)*(x-3)*(-18+x)^2, 18 < x, 0)

(5)

NULL

NULL

MD := Distribution(PDF = unapply(f, x), Conditions = [`and`(Min < Mlikely and Mlikely < Max and Min < Avg and Avg < Max and Mlikely <> Avg, piecewise(Avg < Mlikely, Mlikely > Mid, Mid > Mlikely))])

_m2352873740384

(6)

NULL

NULL

NULL

NULL

NULL

X := RandomVariable(MD)

_R

(7)

NULL

evalf(Mean(X))NULL

9.

(8)

NULL

NULL

evalf(Mode(X))

{8.}

(9)

evalf(Quantile(X, .25))

HFloat(6.645331256340534)

(10)

NULL

A := Sample(X, 10^5)

Mean(A)

HFloat(8.989513601786443)

(11)

Mode(A)

HFloat(8.399525182283146)

(12)

Variance(A)

HFloat(9.029923294780689)

(13)

Skewness(A)

HFloat(0.29817612117709397)

(14)

Kurtosis(A)

HFloat(2.3706624578773154)

(15)

Quantile(A, .25)

HFloat(6.63427086578336)

(16)

NULL

Download Distribution-Beta-Subjective.mw

Page 1 of 1