mmcdara

6234 Reputation

17 Badges

7 years, 318 days

MaplePrimes Activity


These are questions asked by mmcdara

Do you have any idea why the graph of function f (see the attached file) is not displayed?
How can I plot it without using the 

plot([seq([t, f], t in [seq](0.9..1.12, 0.002))]);

command ?

Thanks in advance.

restart:

kernelopts(version)

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

(1)

f := 4.185692792*10^2172*t^2499*exp(-5000.000000*sqrt(t));

# Here is a plot of f

plot([seq([t, f], t in [seq](0.9..1.12, 0.002))]);

0.4185692792e2173*t^2499*exp(-5000.000000*t^(1/2))

 

 

# How can I plot f using simply:

plot(f, t=0.9..1.12);  #no graph

 

# As numelems([seq](0.9..1.12, 0.002)) = 111, I assume
# that forcing numpoints to a number that at least equal
# to this one could give a non null display?

plot(f, t=0.9..1.12, numpoints=1000):  #no graph

# adaptive=true option doesn't help

plot(f, t=0.9..1.12, adaptive=true):  #no graph

# Last attempt by forcing a list of points where f has to be evaluated.

plot(f, t=0.9..1.12, sample=[seq](0.9..1.12, 0.002))

 

 

Download NoPlot.mw

Here is a chunk of a more complex code

# syntax 1

decisions := "accept", "reject":

T := 2:
# The true test is `if`(t > T, ...) where t comes from some computation.
# In order to focus on the issue I assumed t was equal to 1.
`if`(1 > T, decisions[1], decisions[2]);
                   "reject"

To get a more concise writing, I did the following

# syntax 2

decisions := "accept", "reject": 
T := 2: 
`if`(1 > T, decisions);

and received this error

Error, invalid input: `if` expects 3 arguments, but received 2

Why doesn't `if` recognizes that decisions is a two parameters sequence?
Is there a way to force `if` to understand syntax 2 ?

I tried replacing `if` by piecewise: while getting no error I can't understand why I got si strange results:

piecewise(1 > T, decisions);
piecewise(3 > T, decisions);
                               0
                       "accept", "reject"

What mechanism does piecewise use to return these values?

Thanks in advance

If_and_piecewise.mw

I often use DocumentTools:-Tabulate or  DocumentTools:-Layout do display a vector or matrix of plots instead of plots:-display. because I find the latter less practical.
But it seems that the 'background' option is not correctly managed with DocumentTools:-Tabulate or  DocumentTools:-Layout.
The attached file shows that:

  • the 'background' option is correctly managed if each "view" contains a single plot,
  • but not correctly as soon as at least one "view" contains morethan one plot.

DocumentTools_and_Background.mw

How can I get with DocumentTools:-Tabulate  /  DocumentTools:-Layout the same rendering I get with plots:-display?

(While using Maple 2015 this question concerns any other Maple versions)

I hesitated on the title to write and my first idea was to write "How to modify a built-in functions without making a mess?".
I finally changed my mind in order not to orient the answers in a wrong way.

So this question is about the construction of multi-variate distributions and concerns only the Statistics package.
Here are some of the attributes of a univariate random variable that Maple recognizes, and it is quite normal to expect that the construction of a multi-variate random variable (MVRV for short) distribution should get, at least, some of them.

X := RandomVariable(Normal(a, b)):
map(a -> printf("%a\n", a), [exports(attributes(X)[3])]):
Conditions
ParentName
Parameters
CharacteristicFunction
CDF
CGF
HodgesLehmann
Mean
Median
MGF
Mode
PDF
RousseeuwCrouxSn
StandardDeviation
Support
Variance
CDFNumeric
QuantileNumeric
RandomSample
RandomSampleSetup
RandomVariate
MaximumLikelihoodEstimate

If the distribution is continuous the PDF is fundamental in the sense it enables constructs all the other statistics (=attributes) of a MVRV.
But it is nice to use integrated functions, such as Mean, Support, PDF, and so on, to get the expressions or values of these statistics instead of computing them from this PDF.
Let's that I prefer doing this

MyNormal := proc(m, v)
  description "Reparameterized Normal randomvariable, m=mean, v=variance":
  Distribution(
    PDF = (t -> exp(-1/2*(x-m)^2/v)/sqrt(2*Pi*v))
    , Conditions = [Sigma > 0]
    , Mean =m
  )
end proc:

X := RandomVariable(MyNormal(mu, Sigma)):
Mean(X)
                              m

than doing this

MyNormal := proc(m, v)
  description "Reparameterized Normal randomvariable, m=mean, v=variance":
  Distribution(
    PDF = (t -> exp(-1/2*(x-m)^2/v)/sqrt(2*Pi*v))
    , Conditions = [Sigma > 0]
  )
end proc:

X := RandomVariable(MyNormal(mu, Sigma)):
Mean(X);  # of course undefined
mean := int(PDF(X, x), x=-infinity..+infinity) assuming Sigma > 0
                           undefined
                           mean := 1

So, while all the statistics can be recover from the CDF (provided it exists), it's nicer to define these statistics within the Distribution structure (as in the first construction above).

Now some problems appear when you want to construct the Distribution structure for a MVRV.
The attached file contains the construction of MVRV whose ecah components are mutually independent (to keep the things simple) and both have a Unifom distribution.

MV_Uniform.mw

Here are some observations:

  • Defining a multi-variate PDF goes without problems.
  • Defining the Mean (or many other algebraic or numeric statistics) presents a difficulty related to the type of the arguments the build-in function Mean is aimed to recieve.
    But a workaround, not very elegant, can be found.
  • The case of the Support seems unsolvable: I wasn't able to find any workaround to define the support of a MVRV.
  • I did not consider the Conditions attribute, but I'm not sure that, in the case of, let's say, a bi-gaussian random variable I would be capable to set that the variance is a symmetric positive-definite matrix?

I feel like the main restriction to define such MVRV distributions is the types used in the buid-in functions used in the Distribution structure.

Does anyone have an idea to tackle this problem?

  • Are we doomed to use workarounds like the one I used for defining the MVRV mean?
  • Can we modify the calling sequence of some build-in functions without making a mess and keep them working on build-in distributions?
  • Must we overload the construction of these build-in functions?
    Doing for instance:
    restart:
    with(Statistics):
    local Mean:
    Mean := proc(...) ... end proc

Thanks in advance for any suggestion and help.

In a recent answer I posted, I had a relation of the form

I*Int(f(x), x) = something - 2*I*Int(f(x), x)

and I wanted to isolate the term Int(f(x), x).
The function isolate failed to do it and I was forced to use some workaround to do the "isolation".

Trying to understand what happened here, it seems that isolate fails when the term to isolate is multiplied by the imaginary unit
Here are a few examples

expr := I*(Int(x^2*ln(-x+sqrt(x^2-1)), x)) = g(x) -(2*I)*(Int(x^2*ln(-x+sqrt(x^2-1)), x))

I*(Int(x^2*ln(-x+(x^2-1)^(1/2)), x)) = g(x)-(2*I)*(Int(x^2*ln(-x+(x^2-1)^(1/2)), x))

(1)

# no isolation

isolate(expr, lhs(expr))

I*(Int(x^2*ln(-x+(x^2-1)^(1/2)), x)) = g(x)-(2*I)*(Int(x^2*ln(-x+(x^2-1)^(1/2)), x))

(2)

# isolation

expr_1 := expand(expr / I)
isolate(expr_1, lhs(expr_1))

Int(x^2*ln(-x+(x^2-1)^(1/2)), x) = -((1/3)*I)*g(x)

(3)

# no isolation neither, so the problem is not related to "Int"

expr := I*diff(h(x), x) = g(x) -2*I*diff(h(x), x):
isolate(expr, lhs(expr))

I*(diff(h(x), x)) = g(x)-(2*I)*(diff(h(x), x))

(4)

# no isolation neither, so the problem comes from "I"

expr := I*A = g(x) -2*I*A:
isolate(expr, lhs(expr))

I*A = g(x)-(2*I)*A

(5)

# isolation (of course)

expr := c*A = g(x) -2*c*A:
isolate(expr, lhs(expr))

c*A = (1/3)*g(x)

(6)

 

Download Isolation.mw

I guess this is a known behavior, but why it is so?
Is there a way to force the "isolation" without using a trick like in result (3)

Thanks in advance

4 5 6 7 8 9 10 Last Page 6 of 42