mmcdara

6548 Reputation

18 Badges

8 years, 97 days

MaplePrimes Activity


These are replies submitted by mmcdara

@acer 
This is a pretty explanation of how Maple operates.

But the CDF of a random variable X is, by definition, a non decreasing function of x in the range x = ]-infinity, +infinity[.
For a continuous random variable  it is even a strictly increasing function from the support of X to [0, 1]. So each p in [0, 1] has a unique inverse in the in the support of X ("support" is important xhen the CDF exhibits a plateau : in such cas the inverse image of p can be a  an interval).

The CDF here is a strictly increasing function from -5 to 5, as CDF(X, x) shows.
Rigorously Quantile(X, x) should return a single value, not 5 values !
If it does so, this is because Quantile(...) does not work on the true CDF, but on the expression it has over the support of X.
Doing this, Quantile ignores what the CDF is outside this support, and naively extends the CDF outside of [-5, 5]

I think this is a rough error in the implementation of the Quantile function.

The piece of code below avoids the problem in the present case.

convert(CDF(X,x), Heaviside):
solve(%=p,x);
allvalues(%);
evalf( eval(%,p=0.2) );

 

@vv 

I focused on the alias part of your answer, thus forgetting the LargeExpression package you refered to.

I hope my omission is excused

Thank you for indicating me this package

@acer This post by John May is endeed very interesting.

Thanks for the link

@Carl Love 

You wrote "you see that my use of indets and alias is not ad hoc and involves no copy-and-paste from solution to input, right?" :Yes, absolutely.


My initial question was a part of a broader one and your help has been already precious 


I thank you again for your overall contribution.

@Carl Love As an amateur I confess using indets with a very limited number of types.
A quick look to its help page showed me it is a much more powerful command than I thought

 

Thanks for the reminder

@Carl Love 

It works perfectly well.

Now that you explain it, it seems to me that I have indeed already observed this strange interaction between restart and other commands you refer too.
In any event this separation is a rule I will never forget.

Thank you a lot

@vv  but I guess you write these "alias" commands after having seen the output of the command "solve" ?
In a manner of speaking, some kind of ad hoc operation, isn' it ?
Of course it helps to have a synthetic form of the solution, but it is not as if Maple was performing this operation by itself.

Furthemore it is not easy "browse" the solution, recognize the "RootOf" patterns, and execute the "alias" commands without copy/paste actions.

Nevertheless I keep in mind the function "alias". Thank you for that

@Carl Love 

 

Thank you Carl, but the result is not the one I expected.

Maybe my question was not very clear.
So you will find below the type of output I would have to obtain (from Heck's book)


I work with Maple 2015.2 and  OS X El Capitan 10.11

Did I forget anything for testing?


Here is the modified Maple 2015 worksheet including your command

Download Maple2015.mw

 

@tomleslie 

I feel stupid not having found it alone.

But MaplePrimes is for that too ...isn't it ?

Thanks

@acer 

Great thanks to your answer that contains extremely useful coding advices


@tomleslie  Good point !


To complete my question and help you to understand where it comes from, I owe you some explanations


The problem appeared yesterday at my office.
I wanted to construct a list L of, saying, N numbers, initialized with zeros, and do some operations on it 
The first idea then was to realize the command  L :=[(seq(0, n=1..N)]:

I was using Maple 2015.1 on a Windows 7 PC with 64 Gb of memory.

N was equal to 10000 and Maple returned me an error saying that it was unable to assign a long list and suggested me to use array instead.
(unfortunately I am now at home and Maple 2015.2 on OS X 10.11 accepts this "long" list, so I cannot provide you the exact error message Maple delivered me on my professional PC ... I will publish it tomorrow)

Listening Maple I used the command L := Array(1..N):


The "structure" L is split in parts of equal lengths and each of them is sent on a different processor to be processed.
So, with 4 proccessors, I wanted to send L[1..N/4] on proc 1, L[N/4+1..N/2] on proc 2 ans so on.

-------------------------------------
The procedure that runs on each processor is of the form :

F := proc(LocalL::array)
  local N, n, x:
  N := numelems(LocalL):
  for n from 1 to LocalN do
      ...
      x := LocalL[n]:
     ...
  end do:
  ...
end proc

-------------------------------------
Next :

for n from 1 to N
   L[n] := ....
end do: 

for ProcNumber from 0 to Grid:-NumProc() do

   StartFrom := ...      # depends on N, ProcNumber and NumProc()
   Goto         := ...      # depends on N, ProcNumber and NumProc()

   Grid:-Run(ProcNumber, F(L[StartFrom...Goto]):

end do:

-------------------------------------

On processor 1 (0) F proceeds as expected, but the command  x := LocalL[n] on the other processors returns

Error, Array index out of range

This is because LocalL is a "local" array with indices ranging from N/4+1 to N/2 on the 2nd processor, from N/2+1 to 3*N/4 on the third and so on : So indices 1 to N/2 are known only on the first processor.


Obviously I could have avoid this problem by declaring L as a Matrix or Vector.
Or still using array but passing StartFrom and GoTo as arguments of F.
Or maybe using some convert(...) of the piece of L befor sending it to F ?


Finally the core problem is "why I cannot initialize a long list (with seq) on my ptrofessional PC ?"


Thank you for the help




@Carl Love  I often forget the existence of the lprint command.

Could you please take a look at the reply I am about to send to tomleslie ?

(I do not know how to reply simultaneously to two people ...)

Thanks for your help 

@Markiyan Hirnyk ...  should we follow that ? Surely not !

But what makes you think that what's done is incorrect?

In fact the term "p value" and some related notations are a kind of paradigm in statistics

Regards

 

@Carl Love
Your solution is undoubtedly more concise, "automatic" (and elagant) than my proposal and goes quickly to the essential.
When I read it I was debating whether should publish "mine" ?

But I thought it could be interesting for Tazatel to understand why the problem is in fact easy to solve. Let say that I was more interested by explanation and pedagogy than by efficiency ... or elegance

I feel like you should have publish your whole approach, from the "manual" treatment to the final elegant solution, for your phrase "The implicit nature of the model can be handled by subtracting one side from the other and using 0 as the dependent variable values." might be thought of as "pulling a rabbit out of a hat" (although you declare "The model is linear in the parameters a and b")

I am not a Maple pro and I have often a lot of difficulties to understand some solutions that, sometimes, look to me as an exercise in style.
On the one hand I agree with you thet "the essence of elegance in programming is to reduce such redundancy".
But on the other hand the best is the enemy of good ... and elegance can be the enemy of readibility, maintenability and shareability (think to people that develop codes used by others).

Your last remark makes me smile : until I came here I had never use the tilde but only map and zip.
It is people like you who have showed me this "trick" I am now a fan of (but when I develop code for others, I keep prefering "map" ... )


 

@Carl Love 

First : In french the term is "p valeur", a word to word translation of "p value". But a lot of statistician use in fact "p value" even in discussions in french

Second : the summary Maple 2016 provides is an exact copy (even if it is not explicly mentioned) of the output of the "lm" function of the statistical language R. 
R being a world reference in Statistics, I guess we can accept blindly the structure of the summary Maple returns.
Note : even the notation P(>|t|) is used in R ; so I do not  think it would be suitable to replace it

 

kind regards

 

First 133 134 135 136 137 138 Page 135 of 138