sand15

765 Reputation

11 Badges

10 years, 213 days

MaplePrimes Activity


These are replies submitted by sand15

@Muhammad Usman 

As I'm naturally touchy, let's just say that I don't really appreciate your phrase "I am waiting for your positive response" which sounds to me like a do-my-job-and-do-it-well injuction.

That said, let's move on to the technical aspects and the reasons why "Here some lines are directed toward zero which is not needed".
There is no "needed" here: those lines are here because RK11 does not have the desired structure for surfdata, period.

In the end, your problem is this: you want to represent information and you've made the wrong choice of the Maple function. So match your needs to the possibilities offered by Maple and find a visualization that makes sense to you and that Maple accepts.

The attached file presents detailed explanations and propose an alternative visualization (that you might consider this a "positive response" or not is irrelevant to me and I'm done with this thread).

Help-2_sand15.mw

Another possibility is given here  I_am_done_after_that.mw (I don't have time to explain what I've done, particularly as I have the feeling that "positive response" simply means 'result' and doesn't include the explanations that come with it).

@NIMA112

With @acer's suggestion L writes cos(v*y)*C where C does not depend upon y: so you don't even need Maple to integrate this.

The smoothing dependes upon two parameters (s__M and s__T) which controls thesmoothing in directions HAMM and HAMT respectively.
The higher their values the lower the smoothing.
For s__M = s__T = 2 the suface presents some spurious oscillations wich are removed when s__M = s__T = 1.

If you are interested only in qualitative results, you can search for the couple (s__M , s__T) which suits you the best.
Help_smoothing.mw

If you are interested in quantitative results, (for instance to do prediction) you must an approximative reconstruction with very specific models.
As @acer mentionned using cubic interpolation will be a poor idea.

EDITED 2024/03/22 GMT 19:00
Here is a variant of my file Help_smoothing.mw where the approximating surface is build using Kernel Regression.
If you set the parameter shrink to a small value, let's say 0.1 (I infer that much smaller values could lead to numerical problems) you will get a surface close to what ArrayInterpolation(..., method=nearest) gives.
Kernel_regression.mw

By the way, given the values of MAE[i, j, k] I adice you to do this

surfdata(
   [ seq([seq([op(i1, HAMM), op(j1, HAMT), log[10](MAE[1, i1, j1]) ]
   , j1 = 1 .. nops(HAMT))]
   , i1 = 1 .. nops(HAMM))]
   , axes = boxed, color = cyan
   , labels = ["M", "N", "MAE"]
   , labeldirections = [horizontal, horizontal, vertical]
   , labelfont = [Arial, 16, bold]
   , axesfont = [Arial, 14]
   , transparency = .1
   , style = pointline
)


Given the logarithmic range, this plot is almost like the one you could obtain by plotting only data above 1.
If you want something more correct you can do this

surfdata(
   [ seq([seq([op(i1, HAMM), op(j1, HAMT), log[10](MAE[1, i1, j1]) ]
   , j1 = 1 .. nops(HAMT))]
   , i1 = 1 .. nops(HAMM))]
   , axes = boxed, color = cyan
   , labels = ["M", "N", "MAE"]
   , labeldirections = [horizontal, horizontal, vertical]
   , labelfont = [Arial, 16, bold]
   , axesfont = [Arial, 14]
   , transparency = .1
   , style = pointline
   , view=[default, default, 1..143]
)

I don't understand what yiu are trying to achieve with

nminz, nmaxz := (min, max)(newz); C := .666*(1-ImageTools:-FitIntensity(newz)); PC := PLOT(GRID(0 .. 1, 0 .. 1, newz, COLOR(HUE, C)), STYLE(PATCHNOGRID))

and with what comes before?

What does "I want to plot the density plot for all points with the range ..." mean?


I was quite surprised that Maple 2024 offered such a feature. All the more so if it's not removable (but I only have Maple 2021 at my office  and can no longer judge).
Nevertheless scrolling matrices can be of great help and this could be done easily in previous version by using package Spread Spread.mw

@emendes
@dharr : sorry for interfering

This a rough version of a code which seems to do the job (if I understood correctly your problem).
It is likey that a lot of improvements can be done to make it faster.

A core problem remains: it may happen that not all the twins are assigned or that not all the elements of L are assigned a twin.
What do you wish to do when these situations occur?

Here is the raw code:

restart

randomize();

171109231251299

(1)

NL    := 1000:
NT    := 10^5:
L     := [$1..NL]:
r     := rand(1..1000):
Twins := {seq(r()+~{0, r()}, k=1..NT)}:

tstart := time():

rt   := rand(1..NT):
pick := rt():
LT   := table([L[1] = Twins[pick]]):

remains := remove(has, Twins, Twins[pick]):

count := 2:
while remains <> {} do
  NT      := numelems(remains):
  rt      := rand(1..NT):
  pick    := rt():
  
  LT[L[count]] := remains[pick];

  remains := remove(has, remains, remains[pick]);
  count   := count+1:
end do:

eval(LT):

tcalc := time()-tstart

15.004

(2)

printf("Number of elements of L associated to a twin = %d\n", numelems(LT));
printf("Number of non associated elements of L       = %d\n", NL-numelems(LT));

Number of elements of L associated to a twin = 702

Number of non associated elements of L       = 298

 

# Check that no member of a twin is assigned more than once

{entries(LT, nolist)}:
op~(%):
numelems(%):
is(% = 2*numelems(LT))

true

(3)
 

 

Download Twins_mmcdara.mw

@dharr : maybe you'll find it interesting to go further.

@Joe Riel 

ifactor must indeed contain an implicit loop.

By the way, here is a simplified version of my previous code. Its performances are still poor compared to a with-while-loop-code (as @vv  mentioned).
 

NT := proc(p, q)
  local fp, fq:
  if divide(p, q) then
    fp := ifactor(p); 
    fq := ifactor(q);
    algsubs(fq=X, fp);
    degree(%, X);
    printf("%d divides %d  %d times \n", q, p, %)
  else 
    printf("%d does not divide %d \n", q, p)
  end if;
end proc:

 

@vv 

I know, but this was not my purpose. I only wanted to provide a solution which requires no explicit loop (even if on might comsider  map and "~" are disguised loops).
In my mind it was just a kind of stylistic exercise.

@Scot Gould 

What I like about your videos is that you do the course live, filling in the worksheet step by step.

I myself have developed a series of courses for corporate training courses on statistics which are based on the use of Maple (which implies that people already have some knowledge of Maple).
And the main question is "Is it better to build the worksheet (or document) live, or to run a step-by-step worksheet that's already been written (as Robert Lopez does)?"
I feel that your choice is well suited to short videos and I wonder whether it would be appropriate for one-hour training sessions, for example.

@Scot Gould 

I didn't know at all about this site, it's an excellent initiative and I will promote it around me.

@acer 

I would have thought the opposite.
Thanks for the reply

@dharr 

Ok, the "it is the coefficient in the expansion (1+x)^alpha = sum(binomial(alpha,k)*x^k,k=0..infinity)" definition makes sense as long as do not wanr to draw any parallel to the factorials (IMO).

An opinion confirmed by this source Binomial_Theorem :
In section
Generalizations > Newton's generalized binomial theorem
"In order to do this, one needs to give meaning to binomial coefficients with an arbitrary upper index, which cannot be done using the usual formula with factorials. However, for an arbitrary number r, one can define ..."

At last, the Maple: dictionnary (entry binomial coefficient) says more or less the same thing than the source above.

Thanksagain for your precious comments.

@dharr 

Thank you @dharr for this inquiry which must have taken up a lot of your time.

I have carefully reas and read again your reply and I still do not understand if 0

  1. results from a decision not to return an error but something like "caution, the result "0" is a convention when b < a",
  2. or a mathematical extension of the definition of binomial(a, b) for b < a?

As I mentioned earlier, I couldn't find any mathematical result on the expression of binomial(b, a) when b < a (which does not mean there is none).

What is also disturbing is than convert(binomial(b, a), factorial) produces an error when b < a.
Which seems to mean that the object convert produces is not the same than the original one expressed differently.

In fact all this leaves me a bit hungry in spite of your excellent work.

@dharr 

I didn't know this tip to avoid the syntax error, very valuable information.
Good luck for the continuation.

@dharr 

Hi,
You missed one: the loop starts with m=2 and thus dff(..., eta$(m-2)) is not correct :-)

1 2 3 4 5 6 7 Last Page 1 of 24