PatrickT

Dr. Patrick T

2108 Reputation

18 Badges

16 years, 300 days

MaplePrimes Activity


These are replies submitted by PatrickT

and here some Python code, just in case you know a bit of that,

http://euler.slu.edu/~goldwasser/class/slu/csci314/2006_Spring/lectures/marriageAlgorithm/

Thanks for bringing this problem up, I followed up Robert's link. Very interesting. Gale and Shapley have made lasting contributions in game theory and economics. Arguably, Shapley ought to have shared the Nobel prize with Bob Aumann (Bob Aumann thinks so), the Shapley value of a game is perhaps his most famous contribution.

The document referenced immediately below this paragraph has an appendix at the end with some code that is more explicit than the wikipedia code. It looks like Matlab code. Adapting it to Maple should not be too hard. But my guess is that for every loop you write in Maple code (and there are quite a few loops), a Maple expert will show you a more efficent way to code, using seq, lists, whatever; this should be a great learning experience for you and, if you report back, for many of us too!

http://bada.hb.se/bitstream/2320/7987/1/2010MI18.pdf

Edit: A nice introduction to the problem, in slides form, by James Heckman (Nobel prize in econ):

http://jenni.uchicago.edu/econ345/2007/slides/gale-shapley_ho_2007-01-25a_mms.pdf

combining Joe's idea with mine, you could do this:

alias(`y*`=ys);

ys;
                               y*

then you would input ys instead of y* but it would output y*, would that work for you? (my display options are 1D math, Maple notation, but 2D math output, in worksheet mode)

combining Joe's idea with mine, you could do this:

alias(`y*`=ys);

ys;
                               y*

then you would input ys instead of y* but it would output y*, would that work for you? (my display options are 1D math, Maple notation, but 2D math output, in worksheet mode)

@awehring 

I would recommend you don't do that, as the star * is the multiplication symbol in 1-D math, and you're bound to get yourself in a muddle at some point with this, why don't you rename your variables ystar instead? or ys or yss (for stationary state) or ye (for equilibrium), etc. ?

@awehring 

I would recommend you don't do that, as the star * is the multiplication symbol in 1-D math, and you're bound to get yourself in a muddle at some point with this, why don't you rename your variables ystar instead? or ys or yss (for stationary state) or ye (for equilibrium), etc. ?

typeset( y[bug] ) would be rendered as typeset( `#msub(mi("y"),mi("bug")"))` ), etc.

typeset( y[bug] ) would be rendered as typeset( `#msub(mi("y"),mi("bug")"))` ), etc.

For the record, here's how to re-import and re-plot the data exported with plottools:-getdata and ExportMatrix. This is useful to check that the range of data has been truncated successfully, quicker than poring over the Matrix data, as a picture speaks a thousand words.

#data exported with plottools-getdata and saved as xyz1.txt
M := ImportMatrix("C:/maple/data/xyz1.txt",delimiter=",");
M[-10..-1]; # visualize data
M[1..10];   # visualize data

plots:-pointplot3d( [ seq( [ M[i,1], M[i,2], M[i,3] ], i = 1 .. LinearAlgebra:-RowDimension(M) ) ]
  , 'style' = line
  , 'color' = blue
  , 'thickness' = 2
  , 'axes' = box
  , 'labels' = [`x`, `y`, `z`]
) ;

For the record, here's how to re-import and re-plot the data exported with plottools:-getdata and ExportMatrix. This is useful to check that the range of data has been truncated successfully, quicker than poring over the Matrix data, as a picture speaks a thousand words.

#data exported with plottools-getdata and saved as xyz1.txt
M := ImportMatrix("C:/maple/data/xyz1.txt",delimiter=",");
M[-10..-1]; # visualize data
M[1..10];   # visualize data

plots:-pointplot3d( [ seq( [ M[i,1], M[i,2], M[i,3] ], i = 1 .. LinearAlgebra:-RowDimension(M) ) ]
  , 'style' = line
  , 'color' = blue
  , 'thickness' = 2
  , 'axes' = box
  , 'labels' = [`x`, `y`, `z`]
) ;

@Preben Alsholm 

That's great thanks Preben, it does all I need.  :-)

I think it will be convenient to proceed in two steps, to have Robert's procedure remove the non-numeric entries of the Matrix in a first step, and to have your procedure select a range from the Matrix in a second step. So I'm going to keep the two procs separately.

 

P.S.

I just toyed around for a couple of hours trying to rewrite the procedures to work thus

RemoveNonNumeric(M, 'direction' = row, 'type' = numeric);

RemoveOutOfRange(M, 'direction' = row, 'range' = RealRange(Open(0),2) );

but I got stuck at just about every step and gave up. In the first instance, I think I was nearly there. I'll get back to it when I have spare time and want to work on my Maple coding skill (presently very poor) :-(

@Preben Alsholm 

That's great thanks Preben, it does all I need.  :-)

I think it will be convenient to proceed in two steps, to have Robert's procedure remove the non-numeric entries of the Matrix in a first step, and to have your procedure select a range from the Matrix in a second step. So I'm going to keep the two procs separately.

 

P.S.

I just toyed around for a couple of hours trying to rewrite the procedures to work thus

RemoveNonNumeric(M, 'direction' = row, 'type' = numeric);

RemoveOutOfRange(M, 'direction' = row, 'range' = RealRange(Open(0),2) );

but I got stuck at just about every step and gave up. In the first instance, I think I was nearly there. I'll get back to it when I have spare time and want to work on my Maple coding skill (presently very poor) :-(

According to ?%, The Ditto Operators, quote:

"

% reevaluates the last expression computed

...

Ditto operators do not simply recall the results of past computations but instead reevaluate the results of these computations. Because this behavior can cause unnecessary recomputations, use local variables to save and recall computed expressions in programs. If reevaluation is necessary, use the eval command.

"

eval(264)/6.;
                          44.00000001

so what you're seeing is the above (whatever that is)...

I was looking at whether Robert's RemoveNonNumeric proc RNN could be adapted to take as an option a range. I needed to dig a little bit into the procedure. It's pretty short, but achieves quite a bit.

I note that, according ?hastype Maple help page, the syntax is supposed to be,

U := remove(r -> hastype( M[op(subsop(k=r,d))], 'Not(t)', 'exclude_container' ),[seq(i,i=d[k])]) ;

In other words, Not(something) instead of Non(something), as Robert wrote. It seems that both syntaxes are acceptable. Or is there a subtle difference between them?

the optional argument denoted t, and set to be 'numeric' by default, can take the following:

t = numeric, real, realcons, posint, negint, nonnegint

perhaps there are more? I have also successfully tested this:

t = AndProp(real,constant)

But apparently something like this:

t = AndProp(real,RealRange(0,1))

doesn't work. And indeed, 'hastype' doesn't accept a range of values,

hastype([1,2,3], 'RealRange(4,6)', 'exclude_container');
                             false
hastype([1,2,3], 'RealRange(1,3)', 'exclude_container');
                             false

Or am I misunderstanding the syntax?

Is there a small tweak to make hastype accept RealRange?

Thanks!

I was looking at whether Robert's RemoveNonNumeric proc RNN could be adapted to take as an option a range. I needed to dig a little bit into the procedure. It's pretty short, but achieves quite a bit.

I note that, according ?hastype Maple help page, the syntax is supposed to be,

U := remove(r -> hastype( M[op(subsop(k=r,d))], 'Not(t)', 'exclude_container' ),[seq(i,i=d[k])]) ;

In other words, Not(something) instead of Non(something), as Robert wrote. It seems that both syntaxes are acceptable. Or is there a subtle difference between them?

the optional argument denoted t, and set to be 'numeric' by default, can take the following:

t = numeric, real, realcons, posint, negint, nonnegint

perhaps there are more? I have also successfully tested this:

t = AndProp(real,constant)

But apparently something like this:

t = AndProp(real,RealRange(0,1))

doesn't work. And indeed, 'hastype' doesn't accept a range of values,

hastype([1,2,3], 'RealRange(4,6)', 'exclude_container');
                             false
hastype([1,2,3], 'RealRange(1,3)', 'exclude_container');
                             false

Or am I misunderstanding the syntax?

Is there a small tweak to make hastype accept RealRange?

Thanks!

First 24 25 26 27 28 29 30 Last Page 26 of 93