John May

Dr. John May

2896 Reputation

18 Badges

17 years, 162 days
Maplesoft
Pasadena, California, United States

Social Networks and Content at Maplesoft.com

Maple Application Center
I have been a part of the Mathematical Software Group at Maplesoft since 2007. I have a Ph.D in Mathematics from North Carolina State University as well as Masters and Bachelors degrees from the University of Oregon. I have been working on research in computational mathematics since 1997. I currently work on symbolic solvers and visualization as well as other subsystems of Maple.

MaplePrimes Activity


These are replies submitted by John May

There was for a while a links browser  created to support tables and frames (which were not supported by lynx at the time).  Since, lynx has caught up and I don't know if links is still actively developed.

John

For a one-off, it is definitely simplier to cut and paste the table to make it plain text.  That is in fact the very first thing I did with this page. 

However, my goals with this post and the follow up, were to 1. do those whole thing automatically for as many years worth of data as I wanted, and 2. do it all in Maple.

John

This turns out to not be too bad. It is just a matter of isolating the desired table and then stripping out the non-table elements from that.


s := FileTools:-Text:-ReadFile("online.html");
# Split over the tables
ssplits := [StringTools:-RegSplit("<table[^>]*>|</table>", s)];

# Find the largest table and use it
l:=max(map(length,ssplits));
member(l, map(length,ssplits), 'loc');
s := cat("<table>",ssplits[loc],"</table>");

with(XMLTools):
xt := ParseString(s);
thedata := map(GetChildByName, GetChildByName(xt, "tr"), "td");
thedata := remove(x->x=[], thedata);

# The try/catch here is because I am too lazy to parse
# the non table HTML elements more carefully
# It is not very safe but gets the job done here

thedata := map(x->map(proc(y)
  try
    StringTools:-Trim(TextText(GetChild(y,1)))
  catch:
    "0"
   end try end proc
, x), thedata);

# maybe you want this?
header := thedata[1];

# remove the , from numbers and then parse:
numbdata := map(x->map(
    y->parse(StringTools:-Substitute(y,",","")), x), thedata[2..-3]);

 

John

If I save the page to "foo.html", I am not able to import it directly with XMLTools.

> XMLTools:-ParseFile("foo.html");
Error, (in XMLTools:-ParseFile) White spaces are required between 
publicId and systemId.

It might be easy to massage it, however.  I will look at it after I finish Part 2 of this post.

John

In the 2005 Top 3: Jordan was male 72% of the time (it is a near miss on my list). Alexis was female 80% of the time, and Angel was male 82% of the time.

John

This chart uses a looser definition of "unisex" than I use.

John

You don't really need the environment variables for the solve call.   I prefer to avoid using them when possible.

Two options:

# Explicit as a option to solve:

solve({e1,e2,e3},{x,y,a}, Explicit);

# Map allvalues over the solution:

map(allvalues, [solve({e1,e2,e3})]);

The _EnvAllSolutions only really affects equations with an infinite number of solutions, so it doesn't have any effect on this system.

John

You don't really need the environment variables for the solve call.   I prefer to avoid using them when possible.

Two options:

# Explicit as a option to solve:

solve({e1,e2,e3},{x,y,a}, Explicit);

# Map allvalues over the solution:

map(allvalues, [solve({e1,e2,e3})]);

The _EnvAllSolutions only really affects equations with an infinite number of solutions, so it doesn't have any effect on this system.

John

I guess this is more what was intended:

 for i from 1 to 5 do cat(`f_`,i) := unapply(i,x); end do;

John

I guess this is more what was intended:

 for i from 1 to 5 do cat(`f_`,i) := unapply(i,x); end do;

John

The problem with not specifying variables, rather than specifying them all as a list (with variables first) is that you will get parameters solved in terms of variables. 

solve({eq});
{Pi00 = p2 + p6, Pi01 = 1 - p2 - sigma01 - sigma00 - p6, Pi10 = p6,
    Pi11 = 1 - p6 - sigma11 - sigma10,
    p0 = 1 - p1 - p2 - sigma01 - sigma00 - p6, p1 = p1, p10 = -p11 + sigma10,
    p11 = p11, p2 = p2, p3 = 0, p4 = sigma01 - sigma11 - sigma10 + sigma00,
    p5 = 0, p6 = p6, p7 = 0, p8 = sigma01, p9 = -sigma01 + sigma11,
    sigma00 = sigma00, sigma01 = sigma01, sigma10 = sigma10, sigma11 = sigma11
    }

While with a list, some of the solvers try to respect the variable order. In this case that works (as below) even if it does not work in every case.

John

The problem with not specifying variables, rather than specifying them all as a list (with variables first) is that you will get parameters solved in terms of variables. 

solve({eq});
{Pi00 = p2 + p6, Pi01 = 1 - p2 - sigma01 - sigma00 - p6, Pi10 = p6,
    Pi11 = 1 - p6 - sigma11 - sigma10,
    p0 = 1 - p1 - p2 - sigma01 - sigma00 - p6, p1 = p1, p10 = -p11 + sigma10,
    p11 = p11, p2 = p2, p3 = 0, p4 = sigma01 - sigma11 - sigma10 + sigma00,
    p5 = 0, p6 = p6, p7 = 0, p8 = sigma01, p9 = -sigma01 + sigma11,
    sigma00 = sigma00, sigma01 = sigma01, sigma10 = sigma10, sigma11 = sigma11
    }

While with a list, some of the solvers try to respect the variable order. In this case that works (as below) even if it does not work in every case.

John

Take a look at:
http://maplesoft.com/products/Maple/system_requirements.aspx

Under Macintosh®, it says "10.4.5 or later" so 10.5.5 is supported.

John

convert/base basically just calls irem in a loop, so it is definitely better than my function if you want to compute all the digits. 

If you just want one digit, computing it directly is probably a better than convert/base.  Especially for large integers.

John

convert/base basically just calls irem in a loop, so it is definitely better than my function if you want to compute all the digits. 

If you just want one digit, computing it directly is probably a better than convert/base.  Especially for large integers.

John

First 9 10 11 12 13 14 15 Last Page 11 of 19