MaplePrimes Questions

I didn't understand what the page on implicit differentiation meant by 2nd derivatives are just like in using diff    Like this  implicitdiff(y^2 = x^3+a*x+b, y, x, [x$n]) ??  idk 

I have the following ODE which I would like to solve with Maple rather than solving by hand (having solved this type of equation by hand many times now):

diff(f(x,y,z),z$2) = A - B*e^(-A*z)

where A and B are constants and I have indicated the second derivative of a function of x,y and z with respect to z.  

Dear maple users,
Greetings.
I am solving an ode problem with an analytical solution.
programming running properly, but my plot not exact with the already existing article plot. 
how to get the exact plot.

Thanking you.

Code:JVB.mw
 

restart

N := 3;

3

 

1

(1)

dsolve(diff(f(x), `$`(x, 3)));

f(x) = (1/2)*_C1*x^2+_C2*x+_C3

(2)

Rf := 2*(diff(f[m-1](x), x, x, x))-(2*mh*mh)*(diff(f[m-1](x), x))+sum(f[m-1-n](x)*(diff(f[n](x), x)), n = 0 .. m-1)-bet*(sum(sum(2*f[m-1-n](x)*(diff(f[n-t](x), x))*(diff(f[t](x), x, x))+f[m-1-n](x)*f[n-t](x)*(diff(f[t](x), x, x, x))+x*(diff(f[m-1-n](x), x))*(diff(f[n-t](x), x))*(diff(f[t](x), x, x)), t = 0 .. n), n = 0 .. m-1));

2*(diff(diff(diff(f[m-1](x), x), x), x))-2*(diff(f[m-1](x), x))+sum(f[m-1-n](x)*(diff(f[n](x), x)), n = 0 .. m-1)-.2*(sum(sum(2*f[m-1-n](x)*(diff(f[n-t](x), x))*(diff(diff(f[t](x), x), x))+f[m-1-n](x)*f[n-t](x)*(diff(diff(diff(f[t](x), x), x), x))+x*(diff(f[m-1-n](x), x))*(diff(f[n-t](x), x))*(diff(diff(f[t](x), x), x)), t = 0 .. n), n = 0 .. m-1))

(3)

dsolve(diff(f[m](x), x, x, x)-CHI[m]*(diff(f[m-1](x), x, x, x)) = h*H*Rf, f[m](x));

f[m](x) = Int(Int(Int(CHI[m]*(diff(diff(diff(f[m-1](x), x), x), x))+2*h*(diff(diff(diff(f[m-1](x), x), x), x))-2*h*(diff(f[m-1](x), x))+h*(sum(f[m-1-n](x)*(diff(f[n](x), x)), n = 0 .. m-1))-(1/5)*h*(sum(sum(2*f[m-1-n](x)*(diff(f[n-t](x), x))*(diff(diff(f[t](x), x), x))+f[m-1-n](x)*f[n-t](x)*(diff(diff(diff(f[t](x), x), x), x))+x*(diff(f[m-1-n](x), x))*(diff(f[n-t](x), x))*(diff(diff(f[t](x), x), x)), t = 0 .. n), n = 0 .. m-1)), x), x)+_C1*x, x)+_C2*x+_C3

(4)

f[0](x) := 1-exp(x);

1-exp(x)

(5)

for m to N do CHI[m] := `if`(m > 1, 1, 0); f[m](x) := int(int(int(2*CHI[m]*(diff(f[m-1](x), x, x, x))-(2*h*H*mh*mh)*(diff(f[m-1](x), x))+h*H*(sum(f[m-1-n](x)*(diff(f[n](x), x)), n = 0 .. m-1)), x)-h*H*(sum(sum(2*f[m-1-n](x)*(diff(f[n-t](x), x))*(diff(f[t](x), x, x))+f[m-1-n](x)*f[n-t](x)*(diff(f[t](x), x, x, x))+x*(diff(f[m-1-n](x), x))*(diff(f[n-t](x), x))*(diff(f[t](x), x, x)), t = 0 .. n), n = 0 .. m-1))*bet, x)+_C1*x, x)+_C2*x+_C3; s1 := evalf(subs(x = 0, f[m](x))) = 0; s2 := evalf(subs(x = 0, diff(f[m](x), x))) = 0; s3 := evalf(subs(x = 1, f[m](x))) = 0; s := {s1, s2, s3}; f[m](x) := simplify(subs(solve(s, {_C1, _C2, _C3}), f[m](x))) end do:

f(x) := sum(f[l](x), l = 0 .. N);

1-0.7644444444e-1*exp(5.*x)*h^2*x-0.1333333333e-1*x^2*exp(5.*x)*h^2-2.675700596*exp(2.*x)*h^2*x-0.5876096022e-1*exp(6.*x)*h^3*x-0.9282030175e-2*x^2*exp(6.*x)*h^3+.9962792493*exp(3.*x)*h^3*x+.1647896790*exp(5.*x)*h^3*x+0.2066962962e-1*x^2*exp(5.*x)*h^3+3.357118680*exp(2.*x)*h^3*x-.3264340965*exp(4.*x)*h^3*x+0.3999999998e-1*exp(2.*x)*ln(exp(x))*h^2+58.61348006*h^3+1.023148148*h^2*x^3+0.1364197531e-1*ln(exp(x))*h^3*x^3-0.8954734530e-1*exp(2.*x)*h^3*x^4-.1353159884*x^3*exp(4.*x)*h^3+.7542645986*exp(3.*x)*h^3*x^2-0.2830138323e-1*x^3*h^3*exp(3.*x)-0.6455420536e-1*exp(x)*h^3*ln(exp(x))*x+0.4775858416e-1*exp(x)*h^3*ln(exp(x))*x^2+0.8888888887e-3*exp(x)*h^3*ln(exp(x))^2+8.400000000*h*exp(x)-exp(x)-0.6666666666e-1*h*ln(exp(x))+.1416666666*exp(4.*x)*h^2*x-.4790123458*exp(3.*x)*h^2*x+.1333333333*exp(3.*x)*h*x+.3791666665*exp(4.*x)*h^2-1.340020575*exp(3.*x)*h^2+.3111111109*exp(3.*x)*h+5.570191338*h^2*exp(2.*x)-.4500000000*h*exp(2.*x)-0.9874869443e-1*exp(6.*x)*h^3+.4125877323*exp(3.*x)*h^3-4.984787877*h^3*exp(2.*x)-.8010958741*exp(4.*x)*h^3+.3215641638*exp(5.*x)*h^3-5.930474628*h^2*x+36.04284024*exp(x)*h^3*x+8.324321524*x^2*h^2-.5362260993*h^3*x^3-6.207072379*exp(x)*x^2*h^3+1.664189246*exp(x)*h^3*x^3-8.237962963*h+.1200000000*exp(x)*h^2*ln(exp(x))+0.2222222222e-1*exp(3*x)*h*x+24.00299428*h^3*x-2.098561083*x^2*h^3-53.48457977*h^3*exp(x)+0.9949705035e-2*ln(exp(x))*h^3*x^4-0.7308641971e-2*ln(exp(x))*exp(4.*x)*h^3+0.8984910834e-2*ln(exp(x))*exp(3.*x)*h^3-0.3741666666e-1*ln(exp(x))*h^3*exp(2.*x)-.1188740741*exp(5.*x)*h^2-12.53662834*x^2*h+25.90916526*h^2*exp(x)-30.39962862*h^2-0.7499999999e-1*h*exp(2*x)+0.5185185185e-1*exp(3*x)*h+5.372840718*exp(x)*x^2*h^2-25.09181716*exp(x)*h^2*x+0.8976305409e-1*h^3*x^5+0.2158026099e-1*exp(7.*x)*h^3+0.8606919260e-1*h^3*x^4+0.5079365079e-3*x^3*exp(7.*x)*h^3-.3215468487*x^2*exp(4.*x)*h^3+0.1762236380e-1*exp(7.*x)*h^3*x+0.5048727639e-2*exp(7.*x)*x^2*h^3-3.116709690*exp(2.*x)*x^2*h^3+.1066289908*exp(2.*x)*h^3*x^3-8.527777777*h*x-0.2814814814e-2*ln(exp(x))*exp(4.*x)*h^3*x-0.1053497943e-2*ln(exp(x))*exp(3.*x)*h^3*x+0.4848332783e-1*h^3*x^6+.7462278773*h^2*x^4+.5519508187*exp(x)*h^3*x^4+0.9367631194e-1*exp(x)*h^3*ln(exp(x))+3.581893812*exp(2.*x)*x^2*h^2

 

 

NULL


 

Download JVB.mw

 

Analytical solution approach:

 

 

 

 

Dear all

I hope to find the supremum of the sequence of the function using maple 18, but when I run the code there is no results

maximize.mw

Many thanks

 

 

Dear, 

Please, I would like to ask your help with the following situation: 

If we have to solve in Maple a linear system like A.x =b, we employ the command Linsolve. However, how can I solve a system like x.A=b? 

The only method I know is to compute x=b.A-1. Is this an efficient method or there is a better one you recommend? 

Many thanks for your help.  

phi:=(j,x)->piecewise(j=0,exp(x),1/(j-1)!*Integrate(exp((1-theta)*x)*theta^(j-1),theta=0..1))

I want 15 digits after the dot, so I set Digits:=15

Setting j=3, x=0.01 I received

phi(j,x)=0.167084168060000

 

Doing the same in python I receive

0.16708416805754214

Hi, 

Here are two sequences of commands that should give the same kind of plots. But, while the first one returns the expected display, the second doesn't (look to the labels on the histogram plot).

There is no hidden character that could explain this second display. Just that I proceeded this way:

  1. I executed the second sequence once.
  2. Then I told myself that displaying the histogram was superfluous, so I replaced its final semicolon with a colon.
  3. And I finally thought that, no, the histogram had a real interest and that I should display it; and I restored the semcolon (this is what you can see on the second sequence).
    And this add to the histogram the labels inherited from the second plot ...

Nothing dramatic here, but was the development team aware of this curiosity?
 

 

restart:

N := 10:
S := Statistics:-Sample(Normal(0, 1), 10)^+:
Statistics:-Histogram(S);
plots:-logplot(<  < [$1..N]> | S >, labels=["A", "B"]);
 

 

 

restart:

N := 10:
S := Statistics:-Sample(Normal(0, 1), 10)^+:
Statistics:-Histogram(S);
plots:-logplot(<  < [$1..N]> | S >, labels=["A", "B"]);

 

 

 


 

Download Strange_display.mw

My question deals with plotting a function, namely, x(t), from lower to higher values of t.

To this aim, I solved a simple differential equation with given initial conditions and then plotted for the result.

As it is seen, maple starts from lower values of t to higher ones. However, is there a command through which I can reverse the plotting procedure?  

From the attached file, "A question on plotting", we see that the slope of the curve at t=2 is positive when we observe it from "left to right". However, this slope is negative once we start plotting from "right to left".

Is there any command with which I can start plotting from right to left? or change of axis origin?

I would appreciate for your kind help and support.

My best regards

Hadi

 

(D@@2)(T)(0) + :-O(1) + 1/2*sin(1/2*Pi*T(x))^2 + 1/12*sin(1/2*Pi*T(x))*Pi*diff(T(x), x)*cos(1/2*Pi*T(x)) + :-O(2/3*(3/2*Pi^2*diff(T(x), x)*cos(1/2*Pi*T(x))^2*diff(T(x), x, x) - Pi^3*diff(T(x), x)^3*cos(1/2*Pi*T(x))*sin(1/2*Pi*T(x)) + sin(1/2*Pi*T(x))*Pi*diff(T(x), x, x, x)*cos(1/2*Pi*T(x)) - 3/2*sin(1/2*Pi*T(x))^2*Pi^2*diff(T(x), x, x)*diff(T(x), x))/Pi^2)

 

How can I remove the Big O terms from an expression?

Dear Maplesoft,

I inquired about this problem 4 years ago, but never really was able to fix my problem based on the response at the time. This has to do with plotting a parametrized curve where the parametrization involves the numerical solution of a condition. 

Consider the family of cardioids  
           "r = 1 + c*sin(theta), theta = 0 .. 2*Pi"
 in polar coordinates for 
                         "c = 0 .. 2.5"

In this example we find the polar angle 
                           "theta(c)"
 on the evolving family of cardioids where the slope is 
                              "-1"
 as a function of the shape parameter 
                              "c"
 of this family by a procedure involving fsolve, but then try to plot the parametrized curve 
                  "r(c) = 1 + c*sin(theta(c))"
. No direct plotting method works because of evaluation order problems that I do not understand. The first plot is my desired plot but I used an ugly workaround to get the gray curve. Can you fix the direct method with delayed evaluation or something? 

Maplesoft Response. We don't help with this kind of problem. Ask MaplePrimes. 

This evaluation order problem pops up every time you want to plot a curve determined by numerically solving a condition, yet Maplesoft seems to think this is too sophisticated a problem to respond to. Naively trying to animate such curves always derails, so it reveals a weakness of Maple for users who do not belong to the elite class of Maple experts. I have been using Maple for a quarter century, and have made some pretty intricate animations and plots over the years, but always run up against this problem with animating numerically determined curves. Is there a Maple pro out there who can help?
Since I can't find a way to attach my Maple worksheet, here is the URL:
http://www34.homepage.villanova.edu/robert.jantzen/maple/misc/cardioidfamily.mw

 

Hi, I have the following problem:

I want to plot the cone given by 1/16*(3x^2+10xz+3z^2-16y^2) and x>=0, z>=0. I tried it with

implicitplot3d([1/16*(3*x^2+10*x*z-16*y^2+3*z^2), x >= 0, z >= 0], x = -5 .. 15, y = -15 .. 15, z = -5 .. 15, grid = [30, 30, 30], style = surface);

But the result is one surface for each inequaility and not the cone.

If i restrict the range of x and z to be 0..15 and dismiss the additonal inequalities, a big part of the cone surface is missing somehow:

Does anybody know how to fix this? Do I have to use another plotcommand?

Thanks for your help!

Hi, 

This thread is more or less related to a previous one about the Statistics:-Sample procedure.
(see https://www.mapleprimes.com/questions/228421-A-Serious-Problem-With-StatisticsSample )
I've just implemented two variant of the Box-Muller procedure to sample normal rvs.
The source is "The art of computer programming", Donald E. Knuth, 2nd edition, p117 (aka "algorithm P").

The first implementation (BoxMuller_1) is basically what D.E. Knuth writes, except that I "vectorize" some operations in order to avoid using an if.. then..else structure (as a minor consequence I generate a little bit more numbers than required).
This procedure uses the build-in Maple's procedure select (please see the link above and acer's and carl love's replies).
It appears to be relatively slow.
More of this CodeTools:-Usage(BoxMuller_1(10^6)) generates a "conenction to kernel lost" for some unknown reason.

The variant named BoxMuller_2 uses sort and ListTools:-BinaryPlace instead of select.
Ir appears to be around 3 times faster than BoxMuller_1, but remains 10 time slower than Statistics:-Sample(..., method=envelope) (here again, see the link above to understand why method=envelope is needed).

I wonder how it could be possible to speed up this procedure. In particular acer showed in one of his reply (again see the link above) how using hfloats can improve the efficiency of a procedure, but I'm very incompetent on this point.
Does anyone have any idea?

Thanks in advance.

PS: this file has been written with Maple 2015.2


 

restart:

BoxMuller_1 := proc(N)
  local V, S, T, L, X1, X2:
  V  := Statistics:-Sample(Uniform(-1, 1), [ceil(2*N/3), 2]):
  S  := V[..,1]^~2 +~ V[..,2]^~2;
  T  := < subs(NULL=infinity, select(`<`, S, 1)) | V >;
  T[.., 1]  := (-2 *~ log~(T[.., 1]) /~ T[.., 1])^~(0.5);
  X1 := select[flatten](type, T[.., 1] *~  T[..,2], 'float');
  X2 := select[flatten](type, T[.., 1] *~  T[..,3], 'float');
  return <X1 , X2>:
end proc:


BoxMuller_2 := proc(N)
  local V1, V2, S, W, u, r, T, X1, X2:
  V1 := Statistics:-Sample(Uniform(-1, 1), ceil(2*N/3)):
  V2 := Statistics:-Sample(Uniform(-1, 1), ceil(2*N/3)):
  S  := V1^~2 +~ V2^~2;
  W  := sort(S, output = [sorted, permutation]):
  u  := ListTools:-BinaryPlace(W[1], 1);
  r  := [$1..u]:
  T  := (-2 *~ log~(W[1][r]) /~ W[1][r])^~(0.5);
  X1 := T *~ V1[W[2][r]];
  X2 := T *~ V2[W[2][r]];
  return <X1 | X2>^+:
end proc:  

CodeTools:-Usage(Statistics:-Sample(Uniform(-1, 1), 10^5)):
CodeTools:-Usage(Statistics:-Sample(Uniform(-1, 1), 10^5, method=envelope)):
# CodeTools:-Usage(BoxMuller_1(10^6)): # generates a "connection to kernel lost" error msg
CodeTools:-Usage(BoxMuller_2(10^6)):

print():
CodeTools:-Usage(BoxMuller_1(10^5)):
CodeTools:-Usage(BoxMuller_2(10^5)):
print():

S1 := BoxMuller_1(10^5):
S2 := BoxMuller_2(10^5):

memory used=1.17MiB, alloc change=0 bytes, cpu time=12.00ms, real time=12.00ms, gc time=0ns
memory used=3.32MiB, alloc change=32.00MiB, cpu time=64.00ms, real time=64.00ms, gc time=0ns

memory used=148.17MiB, alloc change=119.93MiB, cpu time=706.00ms, real time=637.00ms, gc time=14.63ms

 

 

memory used=67.43MiB, alloc change=186.80MiB, cpu time=946.00ms, real time=762.00ms, gc time=285.14ms
memory used=14.81MiB, alloc change=0 bytes, cpu time=67.00ms, real time=62.00ms, gc time=0ns

 

(1)

if false then
DocumentTools:-Tabulate(
  [
    plots:-display(
      Statistics:-Histogram(S1),
      plot(Statistics:-PDF(Normal(0, 1), x), x=-4..4, color=red,thickness=3)
    ),
    plots:-display(
      Statistics:-Histogram(S2),
      plot(Statistics:-PDF(Normal(0, 1), x), x=-4..4, color=red,thickness=3)
    )
  ], width=60
)
end if:
  

# carl love's procedure with slight modifications t

SampleCheck := proc(X, f, N::posint)
uses St= Statistics;
  local S, M, O, E:
  S:= f(N):
  M:= numelems(S):
  O:= <St:-TallyInto(S, <[$(floor@min-1..ceil@max)(S)]>)>:
  E:= St:-Probability~(X <~ (rhs@lhs)~(O), 'numeric') * M:
  <rhs~(O)[2..] | E[2..] - E[..-2]>
end proc:
 

interface(rtablesize=20):
SampleCheck(Statistics:-RandomVariable(Normal(0,1)), 'BoxMuller_1', 10^5),
SampleCheck(Statistics:-RandomVariable(Normal(0,1)), 'BoxMuller_2', 10^5);

Matrix(11, 2, {(1, 1) = 1, (1, 2) = HFloat(0.029943974977392658), (2, 1) = 5, (2, 2) = HFloat(3.28979552036377), (3, 1) = 121, (3, 2) = HFloat(138.1791685600983), (4, 1) = 2276, (4, 2) = HFloat(2243.2153196005097), (5, 1) = 14488, (5, 2) = HFloat(14245.846696531142), (6, 1) = 35630, (6, 2) = HFloat(35780.43897239682), (7, 1) = 35886, (7, 2) = HFloat(35780.43897239682), (8, 1) = 14071, (8, 2) = HFloat(14245.846696531138), (9, 1) = 2212, (9, 2) = HFloat(2243.2153196005092), (10, 1) = 130, (10, 2) = HFloat(138.1791685601056), (11, 1) = 2, (11, 2) = HFloat(3.2897955203516176)}), Matrix(10, 2, {(1, 1) = 1, (1, 2) = HFloat(3.293310594473029), (2, 1) = 127, (2, 2) = HFloat(138.32680996055558), (3, 1) = 2241, (3, 2) = HFloat(2245.6121457991635), (4, 1) = 14226, (4, 2) = HFloat(14261.068070193269), (5, 1) = 35632, (5, 2) = HFloat(35818.66958395649), (6, 1) = 35864, (6, 2) = HFloat(35818.66958395649), (7, 1) = 14451, (7, 2) = HFloat(14261.068070193272), (8, 1) = 2266, (8, 2) = HFloat(2245.6121457991685), (9, 1) = 125, (9, 2) = HFloat(138.32680996054842), (10, 1) = 1, (10, 2) = HFloat(3.293310594468494)})

(2)

 


 

Download Box-Muller.mw

How to solve this DE by using  Differential transformation method?

diff(f(x),x$3)+1/2 * f(x) *diff(f(x),x$2)=0;

with boundary conditions

  f(0)=1 ; f '(0)= lamda * f ''(0)   and   f ' (x) -> 1  as x -> infinity
where lamda is some constant...

Explore the values of km_digit(n,m) using km_ for all m,0 < or equal to m and less than or equal to 8. 

Look at the output until you can make a conjecture that concerns the pattern obtained.

Hint use km_list(m,6,20) when m is not a multiple of 4 and km_list(m,6,50) when m is a multiple of 4

Hi, 
The choice method=default (the implicit choice) gives dramatically false results as demonstrated here for the sampling of a normal r.v.
It's likely to be the case for any continuous distribution.
In a few words the tails of the distribution are not correctly sampled (far from the mean by 4 standard deviations for a normal r.v., not an extremely rare event in practical applications).

I think the attached file is sufficiently documented for you to understand the problem.


 

restart:


The problem presented here also exists with Maple 2018 and Maple 2019

interface(version)

`Standard Worksheet Interface, Maple 2015.2, Mac OS X, December 21 2015 Build ID 1097895`

(1)

with(Statistics):

X := RandomVariable(Normal(0, 1)):


Generate a sample of X of size 10^6

Here is the R code for those who would like to verify the results and the performances

 

N <- 10^6

R <- 20

Q <- c(0:5)

 

M <- matrix(nrow=R, ncol=length(Q))

 

for (r in c(1:20)) {

  S <- rnorm(N, mean=0, sd=1)

  for (q in Q) {

    M[r, q+1] <-length(S[S>q])

  }

}

 

Expected.Number.of.Outliers <- floor(N - pnorm(Q, mean=0, sd=1) * N)

Observed.Number.of.Outliers <-  round(colMeans(M))

 

Expected.Number.of.Outliers

Observed.Number.of.Outliers

 

Absolute.Differences <- M - kronecker(t(Expected.Number.of.Outliers), rep(1, R))

boxplot(differences)

Remark the loop below takes about 30 seconds to run (to be compared to the 20 minutes
it would take am I used the build-in procedure Select, and to  the 3 seconds R demands).

N := 10^6:
R := 20:

Q  := [$0..5]:
nQ := numelems(Q):
M  := Matrix(R, nQ, 0):

for r from 1 to R do
  S := Sample(X, N):
  for q in Q do
    M[r, q+1] := add(Heaviside~(S -~ q)):
  end do:
end do:

Expected_Number_Of_Outliers := Vector[row](nQ, i -> Probability(X > Q[i], numeric)*N);

Expected_Number_Of_Outliers := Vector[row](6, {(1) = HFloat(500000.0), (2) = HFloat(158655.25393145697), (3) = HFloat(22750.13194817921), (4) = HFloat(1349.8980316301036), (5) = HFloat(31.67124183311998), (6) = HFloat(0.2866515719235352)})

(2)

Observed_Number_Of_Outliers := Mean(M);

Observed_Number_Of_Outliers := Vector[row](6, {(1) = 500291.4, (2) = 158782.3, (3) = 22761.35, (4) = 1349.5, (5) = 51.6, (6) = 1.9}, datatype = float[8])

(3)


While the values of  the Observed_Number_of_Outliers seem to be reasonably correct for q =0, 1, 2 and 3
there are highly suspicious for q = 4 and likely for q = 5 (but N is too small to be categorical)

So let's examine more closely rhe results for q = 4

`q=4`:= convert(M[..,5], list);
 min(`q=4`)

[HFloat(49.0), HFloat(63.0), HFloat(42.0), HFloat(47.0), HFloat(44.0), HFloat(68.0), HFloat(46.0), HFloat(51.0), HFloat(58.0), HFloat(55.0), HFloat(50.0), HFloat(51.0), HFloat(68.0), HFloat(45.0), HFloat(58.0), HFloat(44.0), HFloat(59.0), HFloat(49.0), HFloat(47.0), HFloat(38.0)]

 

HFloat(38.0)

(4)


This means we obtained 20 estimations out of 20 of the probability that X exceeds q=4.
There are only about on chance out of 1 million to get such a result (roughly (1/2)^20 ).

Here is the result R returned for the same quantile q=4

 M[,5]

 [1] 24 37 23 38 30 43 23 30 25 39 25 29 29 36 39 41 35 37 36 34

(9 values out of 20 are less than the expected value of 31.67)

A very simple test based on the Binomial distribution will prove, without any doubt, that the
distribution of the 20 numbers of outliers for q = 4 implies the sampling algorithm is of
is of very poor quality.



Is it possible to obtain correct results with Maple ?


(simulations done below for the case q=4 only)

N := 10^6:
R := 20:

Menv := Vector[column](R, 0):

for r from 1 to R do
  S := Sample(X, N, method=envelope):
  Menv[r] := add(Heaviside~(S -~ 4)):
end do:

`q=4`:= convert(Menv, list);
Mean(Menv);
Variance(Menv);

[HFloat(26.0), HFloat(26.0), HFloat(35.0), HFloat(34.0), HFloat(30.0), HFloat(30.0), HFloat(28.0), HFloat(24.0), HFloat(27.0), HFloat(31.0), HFloat(28.0), HFloat(21.0), HFloat(34.0), HFloat(33.0), HFloat(29.0), HFloat(38.0), HFloat(38.0), HFloat(33.0), HFloat(39.0), HFloat(25.0)]

 

HFloat(30.45)

 

HFloat(24.892105263157895)

(5)



Conclusion, the "default" sampling strategy suffers strong flaw.

Remark: it's well known that one of the best method to sample normal random variables
is Box-Mueller's: why it has not been programmed by default ?

 

 


 

Download Bug_Normal_Sampler.mw


 

1 2 3 4 5 6 7 Last Page 3 of 1817