Question: Statistics fails to reject invalid parameter values

Maple doesn't completely check the condition on the number of trials "n" for Binomial and NegativeBinomial distributions (package Statistics).
The attribute "Conditions" explicitely says that n must be a strictly positive integer but no strictly positive real valuereturna an error (ok, it would be stupid to set n to a non integer value !!!).

I think it is a default that ought to be corrected in future releases (this default still exists in Maple 2018)

 

restart

kernelopts(version)

`Maple 2015.2, APPLE UNIVERSAL OSX, Dec 20 2015, Build ID 1097895`

(1)

with(Statistics):


BINOMIAL DISTRIBUTION

X := RandomVariable(Binomial(n, p)):
L := [attributes(X)][3]:
A := exports(L)

Conditions, ParentName, Parameters, CDF, CharacteristicFunction, Kurtosis, Mean, Median, Mode, MGF, ProbabilityFunction, Skewness, Support, Variance, VariationCoefficient, CDFNumeric, QuantileNumeric, RandomSample, RandomSampleSetup, RandomVariate

(2)

L:-Conditions

[0 <= p, p <= 1, n::posint]

(3)

# Maple should return an error for N is not of type posint
#
# It seems that Sample uses floor(N)

N := 10.49; type(N::posint);
P := 1/2:
X := RandomVariable(Binomial(N, P)):
Mean(X), N*P;
ProbabilityFunction(X, k);
S := Sample(X, 10^6):
Mean(S);


# A non consistent result (only non negative values of k should be accepted)

eval(ProbabilityFunction(X, k), k=evalf(Pi));

N := 10.49

 

false

 

5.245000000, 5.245000000

 

piecewise(k < 0, 0, binomial(10.49, k)*(1/2)^k*(1/2)^(10.49-k))

 

HFloat(4.998903)

 

.1096019539

(4)


NEGATIVE BINOMIAL DISTRIBUTION

X := RandomVariable(NegativeBinomial(n, p)):
L := [attributes(X)][3]:
A := exports(L):
L:-Conditions

[0 < n, 0 < p, p <= 1]

(5)

N := 10.49:
P := 1/2:
X := RandomVariable(NegativeBinomial(N, P)):

Mean(X)


 

Download BinomialLaw.mw

 

Please Wait...