mmcdara

7891 Reputation

22 Badges

9 years, 63 days

MaplePrimes Activity


These are replies submitted by mmcdara

@gkokovidis 

Thanks for the reply, 

Regards

@gkokovidis 

I do not thing that curly brackets are the cause of the error the OP has met.
Maybe an hidden character?
The problem is that we can't find the cause without a true mw file.

@acer 

Thanks for the details.

See you soon

@acer 

Thanks for your comments and extra work.

rowspan is indeed an interesting feature, specially when used with padding.
Unfortunately I still don't understand how padding really works. is padding =50 (the value I used after a few trials and errors) a percentage of the height of the cell or a number of pixels?

For instance rowspan=4, padding=50 do not have the same effect in your code and in mine, could it be the consequence you use widthmode=pixels as I use widthmode=percentage?


Why a higher value of padding can move upward or downward what is written in other columns (it seems that padding is not local to a Cell but that Maples resizes (sometimes) all the cells according to the value padding has).

Do you have any answers to all this?

@adel-00 

To plot one unknown (n(t) ot u(t)) versus t + another parameter do this (it takes a lot of seconds for the surface to be displayed).
Next adapt it to yourself to your own problem.


 

restart

dsys:={diff(n(t),t)=-2*(n(t)-N)+(u(t)-abs(M)*exp(I*phi))*exp(-2*I*omegap*t/lambda)+conjugate((u(t)-abs(M)*exp(I*phi))*exp(-2*I*omegap*t/lambda)),diff(u(t),t)=-2*(1-I*delta)*u(t)+2*(n(t)-N)*exp(-2*I*omegap*t/lambda)+2*abs(M)*exp(I*phi)}:

dsys := dsys union {n(0)=0,u(0)=0}:

undefined_quantities := indets(dsys, name):

params := convert(undefined_quantities minus {t}, list)

[M, N, delta, lambda, omegap, phi]

(1)

res1 := dsolve(dsys union {n(0)=0,u(0)=0}, numeric, parameters=params);

# example: the moving param is M


f := proc(s, m)
  local data:
  data := params=~[m, 1, 1, 1, 1, 1]:
  res1(parameters=data):
  eval(Re(n(t)), res1(s))
end proc:

plot3d('f(s, m)', m=1..2, s=0..1, labels=['M', s, 'n(t)']);

 

 


 

Download Try_This_2.mw



 

@Maple_lover1 

If you want a LaTeX table you should use directly what nm prosed instead of what tom and myself did.
If you want to print a "pretty" table within tour worksheet, then its better to refer to tom and myself.

It's up to you.

@tomleslie  @Maple_lover1

Hi, tom's reply solves the issue I mentioned about the difference between Maple 2015 and Maple 2019 and beyond:
In Maple 2015 the syntax is 

DocumentTools:-InsertContent(Worksheet(Group(Input( W )))):

while it is 

DocumentTools:-InsertContent(Worksheet( W )):

for 2019 and beyond;

I don't know what "Group" has become meanwhile?

@Madhukesh J K 

Ok, 
I hope you will be able to fix issue about the occurence of complex values.
I don't think that modifying the bcs will help a lot because this seems intrinsic to the equations themselves; perhaps linearizing some terms and/or using an ad hoc integratio algorithm could help?

Good luck

@Carl Love 

Ok, sorry for the misinterpretation

What you simulate is known as the "Drunkard's walkThe_Drunkard's_Walk

Here your drunkard moves a step forward or a step back with equal probabilities.
He (she maybe) does this 1000 times and "dis" is how far he is from his starting position.
His move is is described by a  Random_walk

There exist a huge collection of results about the "Drunkard's walk" (Mean number of steps for him to reach a given distance from his starting position, "dispersion" of the arrival distances, and so on)
See for instance random.htm for a simple approach

Enjoy

@acer 

Hi, 
I was replying the same thing as I realized that the original code was of an unnecessary complexity (and thus extremely slow).
The "complete" revision I have posted doesn't mean your reply is useless.
 

@acer 

Thanks, using iscont is a little bit tedious if they are many discontinuity points, but it will do the job.

To @Carl Love : I will indeed consider piecewise functions.

My first idea to find intervals such that [a..b], [a..b), (a..b] or (a..b), where a and b are two consecutive discontinuity points, was to use solve.
The fact that I got a strange result forced me to ask for your help.

 

restart:

f := x -> piecewise(x < 0, 0, x < 1, 1, x < 2, 1+1*x, 0)

proc (x) options operator, arrow; piecewise(x < 0, 0, x < 1, 1, x < 2, 1+x, 0) end proc

(1)

# I hope I'm not mistaking with the symbols "(" and ")"
# (
#   french notation for left opened and right close interval is ]..]
#                   for left closed and right open  interval is [..[
#   and I believe you note them (..] and [..)
# )
#
# I would like to find these intervals:
#
# (-infinity, 0)
# [0, 1)
# [1, 2)
# [2, +infinity)

plot(f(x), x=-1..3, discont=[showremovable=[color=red, symbolsize=50]], color=blue, thickness=3);

# PS: arguments of showremovable are not taken into account

 

# An incomprehensible result : it seems to mean that f(x) is always > 2
# only the second case is correct.

solve(f(x)=y, x)

piecewise(y < 2, [], y < 3, [-1+y], 3 <= y, [])

(2)

limit(f(x), x=2, left)

3

(3)

# The former results are contradict by this

solve(f(x)=0, x);  # (-infinity, 0) union [2, +infinity)
solve(f(x)=1, x);  # [0, 1)
 

RealRange(2, infinity), RealRange(-infinity, Open(0))

 

RealRange(0, Open(1))

(4)

# discontinuity points

df := [ discont(f(x), x)[] ];

[0, 1, 2]

(5)

# values of f at at he discontinuity points

fdf := f~(df):

# real ranges of x such that f(x) = y with y in fdf

print~( [seq([y, solve(f(x)=y)], y in fdf)] ):

[1, RealRange(0, Open(1))]

 

[2, 1]

 

[0, RealRange(2, infinity), RealRange(-infinity, Open(0))]

(6)

 


 

Download Example.mw

@acer 

I think that I didn't understand your original goal. Based on the original code you gave (and with those R commands slightly in mind) I had the impression that you were trying to get a kernel-density-plot based on given Samples, rather than from symbolic RVs.
You understood correctly: I was  trying to get a kernel-density-plot based on given Samples indeed.

Hence the suggestions to try surfdata with dimension=2, and direct writing to an Image format, etc. I didn't mention plots:-listdensityplot,...
This was again a perfectly good solution. But as you noticed yourself, "That's not so nice because the effect is a blurred rendering".
There are in fact two methods to build this "image":

  1. either we build a kind of bivariate histogram (my original post) and visualize it in some way, with matrixplot or surfdata+ImageTools for instance
  2. either you decide not to compute this histogram, concretely a matrix whose entries are integers conting the numbre of occurrences in a 2D cell, but to build directly a 2D kernel approximation.
    Note this could also be a strategy for univariate samples (KernelDensity plot instead of Histogram), even it I am not in his favor because the kernel representation can smooth excessively small details and that this effect is often dificult to detect and avoid.

In the bivariate case I believe that people are more "qualitative" in the sense that are satisfied by a rather smooth representation of a 2D sample. Density maps are often too regularized but their use is more to help visualizing what happens that to provide something one really rely upon.
But at the very end the only thing that matters is the sample itself, whatever the pretty representation of it one can use.

I was working on the presumption that one would be starting from (only) samples of unknown distributions. I suppose there may be room for both goals.
The most interesting case is the one of samples from unknown distributions.
The domain I'm working can be summarized this way:

  • You have a differential system S(x1(t), ...xn(t), t, p1, ...pk) where x1(t), ...xn(t) are the unknowns, t the independent variable and p1, ...pk random variables.
  • You have also a vectorial (but independent of t) functional J J of x1(t), ...xn(t) which we considered as "parameterized" by p1, ...pk.
  • The goal is to build the distribution of J (joint distribution if J is vectorial) and use it for further computations.

So I don't know what the distribution of J is.
It is generally captured by intensive Monte Carlo simulation (solving S for random realizations of p1, ...pk) or by a Markov Chain Monte Carlo approach.
Whatever the method we use we have a sample of J, that is a collection of N P-dimensionnal points xhere P is the dimension of the vector J.
In the particular case P=1 it's easy tip "see" what the distribution of J looks like. It's much more difficult if P > 1 ans traditional scatterplots are not of very useful (thay can only enable to detect "shapes" of the cloud and infer some correlations or dependencies but not much more).

For the moment I have not deeply analyzed your answer further than It might be interesting to tune ...
But I wanted to see a quick answer on the first points so that you don't think that I am abandoning your work.

Last point
I notice that you bumped down your Sample size to N=10^3, perhaps for time cost and perhaps also because at N=10^4 the points occlude the filled color gradient of the density plot.
you are entirely right.

I will be exploiting your latest work over the next two days.

PS: Definively excellent your trick to replace points by lines

Thanks

 

@acer 

Great!

Thanks

@acer 

I'd written a reply 10 hours ago and the forgot to send it!!!
The link is repaired in my previous post.

Sorry

First 96 97 98 99 100 101 102 Last Page 98 of 154