Doug Meade

 

Doug

---------------------------------------------------------------------
Douglas B. Meade <><
Math, USC, Columbia, SC 29208 E-mail: mailto:meade@math.sc.edu
Phone: (803) 777-6183 URL: http://www.math.sc.edu

MaplePrimes Activity


These are replies submitted by Doug Meade

I, too, have noticed this.

I know there are times of the year when I have more time, but when interesting questions arise I tend to make the time to read more postings (and to contribute when possible).

The beginnings of semesters tend to bring an influx of new users, with the usual - and unusual - questions. So far, this year, this seems to be down. I don't know that there is much of an increase in interesting traffic with new releases. Maybe new users are finding the clickable interface more convenient, and don't need to ask as many questions. Or, they have learned that the MaplePrimes concensus is to avoid these newer interfaces?

Maybe the Maple Portal is providing the information that was once obtained from MaplePrimes. Or, maybe new users are just too intimidated to post on MaplePrimes.

Lots of questions, a few conjectures, but no definitive answers. Maybe someone with some usage statistics could enlighten the community as far as numbers of new members, new topics, total posts, ....

A "best of MaplePrimes" might show new visitors that this is a friendly and welcoming environment in which to learn how to become a better Maple user.

Doug

---------------------------------------------------------------------
Douglas B. Meade  <><
Math, USC, Columbia, SC 29208  E-mail: mailto:meade@math.sc.edu
Phone:  (803) 777-6183         URL:    http://www.math.sc.edu

I think I understand what the MATLAB code is doing, and how you can modify your existing Maple code to take advantage of this.

The MATLAB code is working one page at a time. It reads a page, and processes the ticker symbols on that page. When it reads a page that has no information, the loop ends.

In terms of your current code, what needs to be done is to process the results obtained with the GET one symbol at a time. You'll have to skip over the header information that is returned and process each symbol separately, detecting the end of this page and moving to the next. This ends when an empty page is observed. This should allow you to have a variable number of symbols per page and per index.

I'll see if I can get time to work on this today, but I do have other projects ahead of this in my queue. Maybe I need to work on my multiprocessing skills?

Doug

---------------------------------------------------------------------
Douglas B. Meade  <><
Math, USC, Columbia, SC 29208  E-mail: mailto:meade@math.sc.edu
Phone:  (803) 777-6183         URL:    http://www.math.sc.edu

I think I understand what the MATLAB code is doing, and how you can modify your existing Maple code to take advantage of this.

The MATLAB code is working one page at a time. It reads a page, and processes the ticker symbols on that page. When it reads a page that has no information, the loop ends.

In terms of your current code, what needs to be done is to process the results obtained with the GET one symbol at a time. You'll have to skip over the header information that is returned and process each symbol separately, detecting the end of this page and moving to the next. This ends when an empty page is observed. This should allow you to have a variable number of symbols per page and per index.

I'll see if I can get time to work on this today, but I do have other projects ahead of this in my queue. Maybe I need to work on my multiprocessing skills?

Doug

---------------------------------------------------------------------
Douglas B. Meade  <><
Math, USC, Columbia, SC 29208  E-mail: mailto:meade@math.sc.edu
Phone:  (803) 777-6183         URL:    http://www.math.sc.edu

Alex,

I have not looked closely at the MATLAB code.

Recently (see this thread) we helped you import financial data using Maple. How is this new question related to the previous one? Is your question how to format the URL?

Providing this information might help us to provide more useful response to this question.

Doug

---------------------------------------------------------------------
Douglas B. Meade  <><
Math, USC, Columbia, SC 29208  E-mail: mailto:meade@math.sc.edu
Phone:  (803) 777-6183         URL:    http://www.math.sc.edu

Alex,

I have not looked closely at the MATLAB code.

Recently (see this thread) we helped you import financial data using Maple. How is this new question related to the previous one? Is your question how to format the URL?

Providing this information might help us to provide more useful response to this question.

Doug

---------------------------------------------------------------------
Douglas B. Meade  <><
Math, USC, Columbia, SC 29208  E-mail: mailto:meade@math.sc.edu
Phone:  (803) 777-6183         URL:    http://www.math.sc.edu

One more question, for now.

Do you know, in advance, if an input is too large, or do you learn this only after doing some computations?

Maybe you have an iterative algorithm and want to ask the user to modify a parameter if it does not terminate in, say, 10 iterations?

Again, any additional details you can provide will only assist us in finding a reasonable solution to your problem.

Doug

---------------------------------------------------------------------
Douglas B. Meade  <><
Math, USC, Columbia, SC 29208  E-mail: mailto:meade@math.sc.edu
Phone:  (803) 777-6183         URL:    http://www.math.sc.edu

One more question, for now.

Do you know, in advance, if an input is too large, or do you learn this only after doing some computations?

Maybe you have an iterative algorithm and want to ask the user to modify a parameter if it does not terminate in, say, 10 iterations?

Again, any additional details you can provide will only assist us in finding a reasonable solution to your problem.

Doug

---------------------------------------------------------------------
Douglas B. Meade  <><
Math, USC, Columbia, SC 29208  E-mail: mailto:meade@math.sc.edu
Phone:  (803) 777-6183         URL:    http://www.math.sc.edu

This has come a long way from my initial post. I've enjoyed following the discussion. One point that is still unclear to me is whether this provides the desired randomness in the selection. Here's how I gathered some data:

restart;
with( Statistics ):
interface( rtablesize=100 ):
r:=proc(a,b,n,m)
    local L;
    a+~ListTools:-PartialSums([0,op(1+~eval(
        combstruct[draw]([L,{L=Prod(Sequence(Z,card<=m-1)$(n-1))}],size=b-a-n+1),
        [Z=1,Epsilon=0,Sequence=`+`,Prod=`[]`]))])
end:
S := NULL:
to 1000 do S := S, r(0,10,6,3)[] end do:

The distribution of selected points can be examined in a number of ways:

Histogram( [S] );
FrequencyTable( [S], bins=11 );
sort( Tally([S]), (a,b) -> evalb( lhs(a)<=lhs(b)) );
 [0 = 1000, 1 = 318, 2 = 428, 3 = 536, 4 = 468, 5 = 478, 6 = 470, 7 = 544,  8 = 425, 9 = 333, 10 = 1000]

This distribution seems fairly representative. Here are some other tally tables:

 [0 = 1000, 1 = 300, 2 = 442, 3 = 553, 4 = 477, 5 = 469, 6 = 474, 7 = 562,  8 = 435, 9 = 288, 10 = 1000]
 [0 = 1000, 1 = 299, 2 = 415, 3 = 544, 4 = 496, 5 = 472, 6 = 467, 7 = 576,  8 = 427, 9 = 304, 10 = 1000]
 [0 = 1000, 1 = 294, 2 = 441, 3 = 534, 4 = 461, 5 = 490, 6 = 498, 7 = 530,  8 = 412, 9 = 340, 10 = 1000]
 [0 = 1000, 1 = 313, 2 = 420, 3 = 554, 4 = 459, 5 = 485, 6 = 465, 7 = 554,  8 = 436, 9 = 314, 10 = 1000]

This is not what I would expect from a uniform distribution. (I expect to see 4000/9 ~ 445 occurrences of each of 1, 2, .., 9.) Am I missing something?

I also did some tests with much longer lists, using r( 0, 100, 20, 10 ). The construction process is not fast, but the results are similar.

Doug

---------------------------------------------------------------------
Douglas B. Meade  <><
Math, USC, Columbia, SC 29208  E-mail: mailto:meade@math.sc.edu
Phone:  (803) 777-6183         URL:    http://www.math.sc.edu

This has come a long way from my initial post. I've enjoyed following the discussion. One point that is still unclear to me is whether this provides the desired randomness in the selection. Here's how I gathered some data:

restart;
with( Statistics ):
interface( rtablesize=100 ):
r:=proc(a,b,n,m)
    local L;
    a+~ListTools:-PartialSums([0,op(1+~eval(
        combstruct[draw]([L,{L=Prod(Sequence(Z,card<=m-1)$(n-1))}],size=b-a-n+1),
        [Z=1,Epsilon=0,Sequence=`+`,Prod=`[]`]))])
end:
S := NULL:
to 1000 do S := S, r(0,10,6,3)[] end do:

The distribution of selected points can be examined in a number of ways:

Histogram( [S] );
FrequencyTable( [S], bins=11 );
sort( Tally([S]), (a,b) -> evalb( lhs(a)<=lhs(b)) );
 [0 = 1000, 1 = 318, 2 = 428, 3 = 536, 4 = 468, 5 = 478, 6 = 470, 7 = 544,  8 = 425, 9 = 333, 10 = 1000]

This distribution seems fairly representative. Here are some other tally tables:

 [0 = 1000, 1 = 300, 2 = 442, 3 = 553, 4 = 477, 5 = 469, 6 = 474, 7 = 562,  8 = 435, 9 = 288, 10 = 1000]
 [0 = 1000, 1 = 299, 2 = 415, 3 = 544, 4 = 496, 5 = 472, 6 = 467, 7 = 576,  8 = 427, 9 = 304, 10 = 1000]
 [0 = 1000, 1 = 294, 2 = 441, 3 = 534, 4 = 461, 5 = 490, 6 = 498, 7 = 530,  8 = 412, 9 = 340, 10 = 1000]
 [0 = 1000, 1 = 313, 2 = 420, 3 = 554, 4 = 459, 5 = 485, 6 = 465, 7 = 554,  8 = 436, 9 = 314, 10 = 1000]

This is not what I would expect from a uniform distribution. (I expect to see 4000/9 ~ 445 occurrences of each of 1, 2, .., 9.) Am I missing something?

I also did some tests with much longer lists, using r( 0, 100, 20, 10 ). The construction process is not fast, but the results are similar.

Doug

---------------------------------------------------------------------
Douglas B. Meade  <><
Math, USC, Columbia, SC 29208  E-mail: mailto:meade@math.sc.edu
Phone:  (803) 777-6183         URL:    http://www.math.sc.edu

Like this?

eps := [i/10 $ i=1..5];
                              [1   1  3   2  1]
                              [--, -, --, -, -]
                              [10  5  10  5  2]
a := 0;
                                      0
gp := Matrix( 5,5, (i,j)->a+(j-1)*eps[i] );

Then you can access a specific row with, say,

gp[1];
                              [   1   1  3   2]
                              [0  --, -, --, -]
                              [   10  5  10  5]                        


You could do the same with an Array, not a Matrix, but the output for the Matrix is a little cleaner.

Doug

---------------------------------------------------------------------
Douglas B. Meade  <><
Math, USC, Columbia, SC 29208  E-mail: mailto:meade@math.sc.edu
Phone:  (803) 777-6183         URL:    http://www.math.sc.edu

Like this?

eps := [i/10 $ i=1..5];
                              [1   1  3   2  1]
                              [--, -, --, -, -]
                              [10  5  10  5  2]
a := 0;
                                      0
gp := Matrix( 5,5, (i,j)->a+(j-1)*eps[i] );

Then you can access a specific row with, say,

gp[1];
                              [   1   1  3   2]
                              [0  --, -, --, -]
                              [   10  5  10  5]                        


You could do the same with an Array, not a Matrix, but the output for the Matrix is a little cleaner.

Doug

---------------------------------------------------------------------
Douglas B. Meade  <><
Math, USC, Columbia, SC 29208  E-mail: mailto:meade@math.sc.edu
Phone:  (803) 777-6183         URL:    http://www.math.sc.edu

Scott is correct, but doesn't fully explain why the b := a assignment is problematic.

When a is an Array, the assignment b := a means that [A]rrays a and b both have the same address. So, subsequent changes to b also change a. See, for example,

restart;
a := Array(1..5);
                           Array(%id = 181004748)
print( a, b );
                          Array(%id = 181004748), b
b := a;
                           Array(%id = 181004748)
addressof( a ), addressof( b );
                            181004748, 181004748
b[1] := 3;
                                      3
print( a, b );
               Array(%id = 181004748), Array(%id = 181004748)

This holds true within the procedure because the Array a is passed by address, not its value. If you really want a copy of an Array, I suggest looking at the Copy command in the ArrayTools package.

Also, I am not sure what you are trying to do with the gp[i] := b line. If you give us a description of what you are trying to do, I think we might be able to show you a more efficient way to reach your goal - probably without even needing to use a loop.

I hope this is useful,

Doug

---------------------------------------------------------------------
Douglas B. Meade  <><
Math, USC, Columbia, SC 29208  E-mail: mailto:meade@math.sc.edu
Phone:  (803) 777-6183         URL:    http://www.math.sc.edu

Scott is correct, but doesn't fully explain why the b := a assignment is problematic.

When a is an Array, the assignment b := a means that [A]rrays a and b both have the same address. So, subsequent changes to b also change a. See, for example,

restart;
a := Array(1..5);
                           Array(%id = 181004748)
print( a, b );
                          Array(%id = 181004748), b
b := a;
                           Array(%id = 181004748)
addressof( a ), addressof( b );
                            181004748, 181004748
b[1] := 3;
                                      3
print( a, b );
               Array(%id = 181004748), Array(%id = 181004748)

This holds true within the procedure because the Array a is passed by address, not its value. If you really want a copy of an Array, I suggest looking at the Copy command in the ArrayTools package.

Also, I am not sure what you are trying to do with the gp[i] := b line. If you give us a description of what you are trying to do, I think we might be able to show you a more efficient way to reach your goal - probably without even needing to use a loop.

I hope this is useful,

Doug

---------------------------------------------------------------------
Douglas B. Meade  <><
Math, USC, Columbia, SC 29208  E-mail: mailto:meade@math.sc.edu
Phone:  (803) 777-6183         URL:    http://www.math.sc.edu

The easiest way to create a contourplot without seeing the contours is to use thickness=0 to set the contour width to 0. But, you still see the contours because the color used to fill between regions defined the contours are different. Also, I prefer to use contourplot3d (not just because it is generally faster than contourplot):

contourplot3d(-5*x/(x^2+y^2+1), x = -3 .. 3, y = -3 .. 3, filledregions=true, contours=33, thickness=0, axes=boxed, orientation=[-90,0] );

It's odd (to me) that this 3d plot cannot be rotated in real time. Is this a bug? Or something new in contourplot3d? Or ???

Now, back to the original question. My first thought for creating the OP's requested plot is to use plot3d, with style=patchnogrid (as suggested by Scott). To get better color in the picture, I usually use shading=zhue (red is highest and violet is lowest). For example:

plot3d(-5*x/(x^2+y^2+1), x = -3 .. 3, y = -3 .. 3, axes = boxed, style = PATCHNOGRID, shading=zhue, orientation=[-90,0] );

I hope these are helpful for you,

Doug

---------------------------------------------------------------------
Douglas B. Meade  <><
Math, USC, Columbia, SC 29208  E-mail: mailto:meade@math.sc.edu
Phone:  (803) 777-6183         URL:    http://www.math.sc.edu

The easiest way to create a contourplot without seeing the contours is to use thickness=0 to set the contour width to 0. But, you still see the contours because the color used to fill between regions defined the contours are different. Also, I prefer to use contourplot3d (not just because it is generally faster than contourplot):

contourplot3d(-5*x/(x^2+y^2+1), x = -3 .. 3, y = -3 .. 3, filledregions=true, contours=33, thickness=0, axes=boxed, orientation=[-90,0] );

It's odd (to me) that this 3d plot cannot be rotated in real time. Is this a bug? Or something new in contourplot3d? Or ???

Now, back to the original question. My first thought for creating the OP's requested plot is to use plot3d, with style=patchnogrid (as suggested by Scott). To get better color in the picture, I usually use shading=zhue (red is highest and violet is lowest). For example:

plot3d(-5*x/(x^2+y^2+1), x = -3 .. 3, y = -3 .. 3, axes = boxed, style = PATCHNOGRID, shading=zhue, orientation=[-90,0] );

I hope these are helpful for you,

Doug

---------------------------------------------------------------------
Douglas B. Meade  <><
Math, USC, Columbia, SC 29208  E-mail: mailto:meade@math.sc.edu
Phone:  (803) 777-6183         URL:    http://www.math.sc.edu
First 22 23 24 25 26 27 28 Last Page 24 of 76