## Problem in sampling gaussian random variables...

Hi,

A year ago I submitted a problem about the sampling of a Gaussian Random Variable (GRV).
A serious problem with Statistics:-Sample()
In short, the default method (Ziggurat method) used in the Stratistics package to sample a GRV overestimates the weights of the tails of the distribution.

Forcing the method to "envelope" is a way to obtain a correct sample

Statistics:-Sample(Normal(0, 1), N, method=envelope)

(another one is to use for instance the Box-Muller sampling algorithm ; look to the reference above for the fast implementation acer proposed).

I recently observed that the envelope method generates an error ("too many inflexion points...") when the standard deviation of the GRV is not one.
I tried to avoid this error by adding the suboption "range" :

restart:
f := (sigma, k, N) => Statistics:-Sample(Normal, 0, sigma), N,  method=[envelope, range=-k*sigma..k*sigma]):
# this works
f(1, 3, 10):
# these do not work
f(0.1, 3, 10):
f(10, 3, 10):


Here, k is a positive real value (which could depend on N but can be imagined to be around 5 or 6 to fix the ideas
Even with this suboption I keep receivind the same error.

If there is no way to parameterize correctly the envelope method, this means that Maple is unable to sample correctly a GRV.

Of course, if X is a GRV of mean mu and standard deviation sigma on could do this to generate a sample of X:

Xstd := RandomVariable(Normal(0, 1)):
Sstd := Sample(Xstd, 10^6, method=envelope):
S := mu +~ sigma *~ Sstd

But this should not be a permanent solution.

## how to guess 1 or 2 when rsolve is wrong at some n...

second has rsolve solution

compare original sequence

accsum(ListTools[Reverse]([seq(patterngroup[k], k=(mm)..(mm+lengthofsequence))])),

with rsolve solution , it start from third number wrong, some number are wrong but correct at next number,

but i just want to guess next number is 1 or 2

[seq(subs(k=kk, sol), kk=0..(lengthofsequence+1))],

with(SumTools):
with(gfun):
accsum := proc(xx)
local result,mm:
result := []:
for mm from 1 to nops(xx) do
temp := Summation(xx[k], k = 1 .. mm):
result := [op(result), temp]:
od:
return result:
end proc:

patterngroup := [2, 1, 1, 1, 2, 2, 1, 1, 2, 2, 2, 1]: # left is latest, 2,1,1..
lengthofsequence := 5:
for mm from 1 to 12 do
if guessgf(accsum(Reverse([seq(patterngroup[k], k=(mm)..(mm+lengthofsequence))])), x) = FAIL then
print(patterngroup[mm]):
else
sol := rsolve(listtorec(accsum(ListTools[Reverse]([seq(patterngroup[k], k=(mm)..(mm+lengthofsequence))])), u(n))[1], u(k)):
acxxc := accsum(ListTools[Reverse]([seq(patterngroup[k], k=(mm)..(mm+lengthofsequence))])):
olist := [seq(patterngroup[k], k=(mm)..(mm+5))]:
#start from 0
print(patterngroup[mm], olist, accsum(ListTools[Reverse]([seq(patterngroup[k], k=(mm)..(mm+lengthofsequence))])), [seq(subs(k=kk, sol), kk=0..(lengthofsequence+1))], sol, subs(k=(lengthofsequence+1), sol), subs(k=(lengthofsequence+1), sol)-acxxc[nops(acxxc)]):
end if:
od:

## Solving an optimal control problem...

Hello all

I wanna solve an optimal control problem and I have searched the Internet but I could not find any tutorial or video course on how to solve it with the Pontryagin maximum principle method. It is my first time that I want to use MAPLE for solving an optimal control problem and I would be thankful if someone can help me.

$$\max \int_{0}^{1} x_{2} [u(t)-u(t)^2] dt$$

$$\dot{x}_{0} = -(1-u(t)) x_{0}(t)+2 x_{1}(t)$$

$$\dot{x}_{1}(t) = (1-u_{t}) x_{0}(t) +2 x_{2}(t) -[3-u(t)]x_{1}(t)$$

$$\dot{x}_{2}(t) = (1-u(t))x_{1}(t) -2 x_{2}(t)$$

$$0 \le u_{t} \le \frac{1+t^2}{1+t}$$

Thanks

## Given a lagrangian in general relativity , how ca...

Given a lagrangian  in general relativity , how can I calculate equation of motion using euler lagrangian equation in maple software ?

the lagrangian is

L = 1/2 g[mu,nu] diff(x[~mu], lambda) diff(x[~nu],lambda)

here lambda is the affine parameter.  and the metric is

metric coordinate = (t,u,x,y)

## How can I solve two equations?...

How I can find the coefficient an, and bn according to the following solution?

the coefficients an and bn can be found by solving the
two linear equations that come from V = V[0] at eta=eta[0] and
V = V[1] at eta=eta[1], and comparing with following Eq in each
case.

Best

2.mw

## how to plot the Profiles of optimal control functi...

I an unable to prot the optimal  control function and the controls individualy for the diterministic mathematical model with an two or more optimal control. May  any one can give me a sample program on it. Such us the following figure

You may give me direction even.

## Bug in modp1(('Rem')(...))...

Hi there.

It seems like a bug in modp1(('Rem')(...)) with large polynomials with large coefficients.

Please look at the file:

bug_rem.mw

It needs the file polys.m there:

https://dropmefiles.com/9fATR

File polys.m too big for this forum so I used dropmefiles.

Polys.m contain two polynomials x and f_t with large degrees: degree(f_t) = m = 50021, degree(x) = 2*m - 2 = 100040 and large coefficients up to 2^N, where N = ceil(m / 2)+2 = 25013.

I just compute rem(x,f_t) mod 2^N.

As you can see in the first part of doc bug_rem.mw I decreased coefficients of polynomials by additional mod 2^N (with Embed function), where N = floor(N / 2) = 12506. WIth these decreased polynomials and decreased N modp1(('Rem')(...)) function works well and use maximum about 2.5 Gb of RAM.

But in the second part of doc bug_rem.mw with original polynomials and N = 25013 modp1(('Rem')(...)) use maximum about 3.5 Gb of RAM and crash with error:

Error, Maple was unable to allocate enough memory to complete this computation.  Please see ?alloc

This is strange and looks like a bug considering that the test server has 48 Gb of RAM.

Is it a bug or modp1(('Rem')(...)) just need more than 48 Gb of RAM?

How many RAM it needs for this computation?

Thank you

## Maple 2020 Video refreshing Problems after interac...

Hello, I am trying to fix the problem reported below.

I am using the 64 bit version of Maple 2020.1. I am experiencing similar problems with other java applications. So I believe it must be something related to Java.

Moreover, it looks like the local refreshing problem is following the cursor of the mouse, therefore it must be something related to the interaction of the mouse with the GUI.

I am using a I7 CPU, 32 GB of Ram and a Nvidia Geforce RTX 2070.

Is anyone experiencing something like this? How can I fix this?

## plot3d java-lang-thread ...

My personal edition of Maple 2020 throws java-lang-thread for every plot3d. No further output is provided by Maple. How can I further troubleshoot this?

Dave

## XMLTools / error during readin in Maple workbook...

Why do I get an error when using this:/// during readin of a xml attachment in Maple workbook?

Exceltools Import works without problems.

## Operation rules of Dirac Notion in maple...

Is there any programming or package to solve my problem. I am poor in programming.

Thanks sincerely!

## XMLTools / FirstChild...

Any idea why the result of the FirstChild function of the attached file is

_XML_Text("\n  ")

Test.zip

I also miss a more complete example on Maple Help for writing, reading and processing xml files.

## Maple Points on a Plot...

Hello! Sorry if this question was already asked, I just can't find my answer and I don't really know how to form the question since I'm new to using Maple. My question is: How can I find a point on a plot I did in Maple? When I use the cursor position(from when I click Probe info) I can never align it right enough for me to not get a decimal answer. For instance, I can't figure out the y-value for when x=2 because the closest I can get to 2 is like 2.1 which isn't exact enough for me.

## Levelsurface visualization...

To practice more in documentmode
Given  f := x^2 + y^2 + z^2 = 1
surfacelevel on level 1  and surfacelevel upon wich the point (sqrt(3), 3, -2) is located.

1) x^2 + y^2 + z^2 = 1   : what solid ( a sphere with radius 1)  and  plot
2) surfacelevel (solid sphere)   for point  (sqrt(3), 3, -2) and plot
3) Plot together

Doing this calculation solely with contextpanel..no that's not always possible as it seems by trying to plot a sphere.