abcd

45 Reputation

6 Badges

9 years, 314 days

MaplePrimes Activity


These are replies submitted by abcd

@Axel Vogt  too much ardour om part !

@Carl Love 

I have just published an alternative solution to yours

But it does not meet the original question because Statistics:-Sample(DiscreteUniform(0, 100), N) returns real numbers, not integers.

Even if it is possible to get over this problem by using round(), it seems to me it is not consistent with the definition of a discrete random variable. 
What do you think about that ?

 PS : all "Discrete Distributions" from the package Statistics return floats and not integers.

@Carl Love 

 

Your proposal seems to work perfectly.
There is just one tiny point that could be improved : when f is a bivariate function (Y=f(U,V)) and if TY denotes the Taylor expansion of Y at some point, E(TY^2) returns E((......)^2) (where the .... is the expression of TY).
But E(expand(TY^2)) returns what is expected.

You will find in the attached file an illustration obtained for a low order expansion, up to the second moment of Y.

For higher moments and/or expansion the substitution rules should me completed with relations such that E(U^3) = Moment(U,3) and so on (a simplified example is given at the end of the file)

In the current state what you supplied me fulfils my requirements.

 

I feel that I succeeded in raising a trophy, but thumbs-up icon, when clicked on, display a "1" that rapidly vanishes ???
Let me know if I miserably failed
Thanks

 

Download MathematicalExpectation2.mw

@Carl Love 

 

Brilliant, nothing more to  say

 

By the way, books about "classical" usage of Maple are quite common but it is hard to get some dedicated to "advanced" usage of Maple (as you did here)
For my own I still use the Maple 5 and 10 Programming Guides but I do not always find what I want.
I can understand Maple Primes is not the place for commercial transactions, but could you recommend me a site where those books, if any, could be found ?


Great thanks again, I'll vote you up as soon as I would be allowed to

Sorry for the typing error on the first letter of the title !

@acer 

Really all a world I'm ignorant about.

I think all the material you give here will be very usefull ... after a close examination and probably a lot of sweat and tears.

Thank you again

@vv 

Thank you for your analysis, and no need to apologize : I could have been wrong.

I looked carefully your answer to Markiyan and your argument for the elliptic case ("Because the mapping  [u,v]  |-->  [sqrt(u)*cos(v),  sqrt(u)*sin(v)]  is area preserving ..." and that sounded good for me.

And then I thought to the problem in an another way (just for fun) and "felt" the things differently, leading me to this triangular distribution.
Probably, I conceede, some kind of statistical intuition at the outset

To conclude, let me quote the great mathematician Mark Kac, who once wrote something like that (I wasn't capable to recover the original quotation) "for me the theory of probability is not just an harmonious collection of theorems and axioms ... I'm not sure it is even a theory ... before all I believe it is a state of mind"


Thank you again, have a good day

@vv 

 

Let me explain you my reasoning and next help me to find if there is something wrong.

I state the problem in polar, not euclidian, coordinates.

Consider an infinitesimal element enclosed between circles of radii r and r+dr and vector radii θ and θ+dθ.
Its surface is r*dr*dθ.

Now, are you agree with me if I say that if the N points within the circle are uniformly distributed, then each of them carries a mass equal to Pi*R^2/N.
To argue, lets draw a parallel with the Monte-Carlo summation formula :

  • Consider a square (or any other figure a uniform sampling is easy to obtain)os area A which contains the disc and sample M points in this shape : the surface of the disc is just the ratio N/M*A where N is the number of points out of the M that fall within the disc.
    This simple formula means that every points have exactly the same mass, saying 1, (if it wasn't the case the good formula should account for each specific weight wn and would a little bit more complicated).
    The idea behind is those of an "unweighted sample", or in other words "fair apportionment of the mass".

Now, suppose the element [r, r+dr]x[θ, θ+dθ] contains K(r, dr, dθ) points
Consider now the domain [2*r, 2*r+dr]x[θ, θ+dθ] : its area (mass) is twice the mass of the previous one and the number of points it contains is K(2*r, dr, dθ).
By "fair apportionment of the mass", each point having the same mass one must have  K(2*r, dr, dθ) = 2*K(2r, dr, dθ).

The factor 2 can be replaced by any other value (provided we are still within the disc of course) ; which shows that the radial density of the points is proportional to r.
I take it that the pdf of the radius is of the form C*r where C is some suitable normalization constant.
Equating  int(C*r, r=0..R) to 1  I find then C=2/R^2. 

If the pdf of r is 2*r/R^2, then r is distributed according a triangular law (writen in Maple Triangular(0, R, R).


I disagree with you when you say "its a kind of statistical intuition".

But I would admit without shame that my reasoning is wrong as soon as someone (you ?) will have point out where its failure is

So, please feel free to defuse my arguments. One always learn from ones mistakes

Hope to read you soon.

Hi again 

I did two mistakes in my previous answer : 

1) two classical ways to regularize a piecewise continuous function with left and right values L and R near a discontinuity at x=L are :

    1. (L+R)/2 - (L-R)/2 * tanh(C*(x-L))
    2. (L+R)/2 - (L-R)/2 * (2/Pi)*arctan(C*(x-L))

... but not  (L+R)/2 - (L-R)/2 * (2/Pi)*tanh(C*(x-L)) as I wrote

 

2) I wrote alpha(x) * diff(T(x,t), x, x) 
    instead of diff( alpha(x) * diff(T(x,t), x), x)

 

Once these mistakes corrected, the regularized variant of the case with a piecewise continuous thermal diffusion works better (not the truly discontinuous one)
Maple now returns a two slopes stationnary (or close to) temperature profile ... but the slopes are not correct.
I thought it could be related to the value of C (C=100) in the regularization function and I used C=1000 (a sharper alpha profile) : but the result Maple returns then is completely wrong.

If we use a FE or a FV method we would refine the x mesh to capture the transition region : I do not know how to do that with pdsolve.


My apologies for the mistakes 



Download HeatEquation.mw

@Carl Love Oh, you don't havto be sorry.

Maybe I badly explained my first question but your answer perfectly meets my requirement

Thank you again

@Axel Vogt 

 

Very impressive Axel, 
It will be very profitable for me
Thanks a lot

@Markiyan Hirnyk 

 

I believe you should be more explicit when you address tendentious remarks ; what is wrong with you ?

Maybe you do not accept that some obscure people like me dare to propose an alternate solution to yours ?
Did I commited a crime of lese-majesty ? If it is, please let me know, instead to beat around the bush.

When you wrote "Here is an unclear result when realizing your suggestion" ... "Waiting for your reply", you look like someone that like to point out your mistakes in front of others ... "Oh I found an example that prooves your claims are wrong, try do defend yourself".

I'm fed up with this kind of childishness. 

The true thing is that the plots you opposed me exhibit patterns that are easily explainable, in so far that you proceed to a simple analytical analysis instead to trying to bleme me. On this, I consider I've already wasted to much time to keep providing still more explanations to someone that has another agenda

Considering your last message ("Equivocation" ? ) "Sorry, you don't give an answer. Compare with the Wiki article cited by me and your words" : to whom did I not give an answer ?  To you ? I do not care : my purpose is to try to  help people that ask for help, not to chit chat with well thinking established people. Look to my early replies and you will read I never presented myself as a specialist of LP, but just has someone who has a lot of practice in Statistics and who could give advices.

I'm probably much more experienced than you are in managing uncertainties in simulation activities so, please, stop playing the schoolmaster with me

This his my last reply 

 

@Markiyan Hirnyk 

 

I understand the NONNEGATIVE option as equivalent to {x >=0, y >=0}

For this thist case all the "true" solutions (refer to my previous reply) s must be less than 1 for the corner be a maximizer.

Here q=4 (Explanation.mw) and the extreme maximizer has co-ordinates 

subs(q=4, corner)  = 

 

When s=1 this gives 

It is easy to show that the ordinate y(P) of the corner P, as long as it is a true maximizer, ranges from -3/7 to -2, and so is always negative.
At the same time x(P) ranges from 11/7 to 11/4. 

It seems to me, if my hypothesis " NONNEGATIVE equivalent to {x >=0, y >=0}" is true, that all the points P should be projected onto the x axis ????

@Markiyan Hirnyk 

 



Here are a fiexw theoritical developments I did around your first toy problem.
maximize(x+y, {4*x+3*y <= 5, (3+s)*x+4*y <=3})

First : 
The admissible polygon is only right bounded by tho edges, E1 and E2.
One edge, let us say E1, is fixed while the second depends on the value s of the sample drawn from the LogNormal RV.
So, the intersection of E1 and E2, which is the location of the potential maximiser (if it exists) always verify 4*x+3*y-5=0 : and so its perfectly normal that you find, by simplex:-maximise, all the maximizers on the same straight line.

Second : 
If the intersection point P is a maximizer, then the objective function must increase along the edge ranging from x=-infinity to x=x(P) and must decrease along the second edge (from x=x(P) to +infinity).
Otherwise stated, the directional derivative of the objective function along the left half edge must be positive and the one along the right half edge must be negative.
The question is : what are values those two directional derivatives (DD) take ?

On your toy case, it is easy to see that the DD is always negative right to the intersection point P and just conditionally positive at left. More precisely, it is positive at left iif 1-(3+s)/4 is positive, that is s < 1.

  1. If s <1 the corner P is a maximizer
  2. If s=1 the whole left edge is a maximizer
  3. if s>1 the maximazer is x=y=-infinity

You will find above the analysis of a slightly more general case where the second constraint is (3+s)*x+q*y <=3

When q < 0 the corner is always a maximiser, whatever the (positive) value of s.
When q > 0 this is still the case provided s < q-3

As a conclusion : the results you obtained with the first test case are perfectly correct

A similar analysis can be developped for your other test cases

 

 

 

Download Explanation.mw

@Markiyan Hirnyk 

 

 

Look to the output of the maximise proc.

Strangely, not all the values of the lognormal sample provide a result, despite the fact that a plots:-inequal shows there is a solution.

I do not think the "unclear result" you obtained (and I obtained too) is related to the strategy I proposed, but that it is related either to a bad use of maximize or to a problem with htis procedure

Odd behaviour of your test case, of course .. so I 'm waiting for your reply.

 

 

 

Download Markiyan.mw

1 2 3 4 5 Page 2 of 5