mmcdara

7022 Reputation

18 Badges

8 years, 229 days

MaplePrimes Activity


These are questions asked by mmcdara

Let expr defined this way

expr := piecewise(x(t)<0, -1, x(t)<1, 0, 1) + f(t) + piecewise(t<0, 0, t<1, 1, 0) + x(t)*piecewise(t<0, 1, t<1, 0, 1) + a*piecewise(t<0, 3, t<1, -1, 2)

How can I extract all the operators which contain a piecewise function of  t alone (the three bold operators in the expression above)?

TIA

Hi, 

First question
Let P1 the logical proposition

restart
with(Logic):
local O
P1 := (&not O) &and (&not C) &implies (&not Q);

Is it possible to obtain its contraposition P2  in a form that contains &implies?

# P2 := (Q) &implies &not ((&not O) &and (&not C));


Second question
Why does the modulo 2 canonical form of proposition P5 above contains "1" "plus" other terms:
(if 1 is present this means 1 + something = 1 and then that P5 is a tautology, which is obviously wrong as Tautology(P5) shows)

restart
with(Logic):
local O
P1 := (&not O) &and (&not C) &implies (&not Q);-
P2 := (Q) &implies &not ((&not O) &and (&not C));
P3 := op(1, P2) &and (&not C);
P4 := op(2, P2) &and (&not C);
P5 := P3 &implies P4:

Canonicalize(P5, {O, C, Q}, form=MOD2)

                   C O Q + C Q + O Q + Q + 1


Verificaion of what the modulo 2 canonical form of a proposition including an "addititive" tautology is

T := O &or (&not O):
Canonicalize(T, {O}, form=MOD2);
Canonicalize(T &or S, {O, S}, form=MOD2);
                               1
                               1

Is it that I missed something or is iot a bug?

Watchout: this result has been obtained with Maple 2015.2

TIA
 

Let E be a random variable of expectation mu and A an algebraic expression containing no random variable.
If E has any known Maple distribution, then  Mean(A+E) = A+mu.

But if E is an "abstract" random variable, Mean doesn't seem capable to compute the expectation of A+E.
Notional example:

restart:
with(Statistics):
E := RandomVariable(Normal(mu, sigma)):
Mean(f(x)+E)
                           f(x) + mu
E := RandomVariable(Distribution(PDF = (z -> f(z)), Mean=mu)):
Mean(f(x)+E); 
     int((f(x) + _t) f(_t), _t = -infinity .. infinity)

IntegrationTools:-Expand(%);
        f(x) (int(f(_t), _t = -infinity .. infinity)) + (int(f(_t) _t, _t = -infinity .. infinity))

Questions:

  • Why does Mean not behave as expected for an abstract random variable?
  • Is there a simple way to obtain the expected result (Mean (A+E) = A+mu) (maybe by completing the definition of the distribution of E, or by any other means)?

TIA

PS: I know that I can replace Mean(A+E)  by A+Mean(E)  to obtain the desired result: this is not the type of answer I look for.

PS: I know (since Carl Love showed me how long ago) that I can define a "random variable" plus an operator Expectation such that Expectation(A+E)  by A+Expectation(E) ... but it's not a way I would call simple

Expectation := proc(e::algebraic)
     local a,b;
     if not hastype(e, RV) then e
     elif e::RV then 'procname'(e)
     elif e::`+` then map(thisproc, e)
     elif e::`*` then
          (a,b):= selectremove(hastype, e, RV);
          b*thisproc(a)
     else 'procname'(e)
     end if
end proc:

#------------------------------------------------------------------------

TypeTools:-AddType(
     RV, 
     {RandomVariable, 
     'RandomVariable^posint', 
     '`*`'({RandomVariable, 'RandomVariable^posint'})
     }
):
eval(Expectation(f(x)+E), Expectation=Mean)
                           f(x) + mu

 

In Maple V the display of a lengthy expression often contained "auxiliary variables" named %1, %2, ... to make it more readable ( (a personal point of view, see for instance Introduction to Maple, A. Heck, p 97).
When did this feature disappear? Has it been replaced by something else?

TIA

 

When I have an operation to perform with Maple, my first reflex is to use the "native" Maple procedure(s) because it seems logical to think that they have been written in order to reduce the memory used and/or the execution time.
Unfortunately, this feeling is not confirmed by reading some of the answers provided on this site.

The attached file shows 4 ways (among probably several others) to center and reduce (by columns) a random matrix.
Amid them is the Statistics:-Scale procedure which appears not to be the most efficient (even a double loop outperforms in term of time).
This is just an example among many others (for instance Statistics:-Select can be easily outperformed)

So my question: why deceive the user with magic functions which sometimes have a very relative efficiency?

Scaling_efficiency.mw

First 18 19 20 21 22 23 24 Last Page 20 of 45