Author Archives: stern

Amusing Youth With A Computable Document Format

A few months ago, Wolfram proposed the Computable Document Format, a standard format for files with computable content. If you have a CDF reader, you can execute the computations on your own machine. At this point, only Wolfram itself makes software for producing or reading CDFs, and I see no signs of rapid adoption, though it may be taking off in educational communities or others to which I have little exposure.

If you have Wolfram’s Computable Document Player, or Plugin installed on your computer, you should be able to use the following bit of code, which I created to amuse my daughter after the “day of the week your birthday falls on” code failed to do so.

colorList = ColorData["Indexed", "ColorList"][[1]];

Manipulate[
Rotate[Style[Text["CHILD'S NAME HERE"], FontSize -> size,
FontColor -> colorList[[Round[color]]]], rotation], {{size, 40},
30, 120}, {rotation, 0, 2*Pi}, {color, 1, Length[colorList]}]

[WolframCDF source=”http://www.wheels.org/monkeywrench/wp-content/uploads/2011/09/name.cdf” CDFwidth=”600″ CDFheight=”600″ altimage=”http://www.wheels.org/monkeywrench/wp-content/uploads/2011/09/name.png”]

I actually modified it for the CDF, combining the two lines into a single Module[], which the CDF player seems to prefer, and giving a choice of three names. You might think it would be best to include a text entry field so that the program can display any name you like, but the CDF player is Mathematica at heart, if you feed it a solvable math problem as the name, it will try to solve it. Wolfram therefore disallows free-form text entry.

Trivial birthday code

My daughter asked yesterday what an “application” was, which led to a discussion of computer programming. I demonstrated by writing a one-line program in Mathematica that computed the day of the week her birthday landed on every year since she was born. She was not impressed.

Code below; birthday changed for privacy protection.

Module[{bday},
 TableForm[
  Table[{i, bday = DatePlus["August 1, 2005", {i, "Year"}];
    DateString[bday, {"MonthName", " ", "DayShort", ", ", "Year"}],
    DateString[bday, "DayName"]}, {i, 0, 7}],
  TableHeadings -> {None, {"Birthday", "Date", "Day of Week"}}]]

table of birthdays

For extra credit, it’s not hard to generate a histogram showing the distribution of days of the week.

daysOfTheWeek = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday",  "Friday", "Saturday"};

numboHits[dayOfWeek_] :=
 Module[{holder},
  holder =
   Select[
    Gather[
     Sort[
      Table[
       DateString[DatePlus["August 1, 2005", {i, "Year"}], "DayName"], {i, 0,
        25(*years to check*)}]]], #[[1]] == dayOfWeek &];
  If[Length[holder] == 1, Length[holder[[1]]], 0]]

BarChart[Map[numboHits[#] &, daysOfTheWeek], ChartLabels -> daysOfTheWeek]

birthday histogram

Updated statistics — Jesus does not care for gay marriage at all

Updated (final?) death statistics came out today, and they revolutionize our understanding of God’s view towards the Republican party and its most cherished principles. Evidently, God would prefer that you vote Republican.

 

And he takes a dim view towards gay marriage.

 

 

and if you vote for a Democratic candidate, or marry somebody the same sex you are, Jesus is going to arrange for heavier than usual rains in your vicinity.

 

[boring details: Irene deaths from http://www.google.com/hostednews/ap/article/ALeqM5jpulHUHeBUW4RhBETMtrl3Mw93RQ?docId=ee2cb4f8e6224ad797d81bc73fbe442e
, population data from http://quickfacts.census.gov/qfd/index.html, % voting from McCain from http://en.wikipedia.org/wiki/United_States_presidential_election_in_Connecticut,_2008 and equivalent pages for the other states with Irene deaths, and gay marriage stats from http://en.wikipedia.org/wiki/Same-sex_marriage_law_in_the_United_States_by_state using a dummy variable of 1 if gay marriage is allowed, 0 if it isn’t, and 0.5 if some kind of intermediate right is granted.]

Jesus loves gay marriage

There was an earthquake near Washington DC last week, and a hurricane tore through New York City this morning, for the first time in many years. Naturally, some took this as a sign of God’s wrath. The same sort of thing was said about Hurricane Katrina. Republican presidential candidate Rick Perry regularly treats changes in weather as indicia of Jesus’s favor.

For what it’s worth, the numbers suggest that if Jesus is in fact using hurricanes to guide our behavior, he’s trying to guide us to approve gay marriage

and to vote for democrats.

[boring details: Irene deaths from http://www.ksro.com/news/article.aspx?id=3182755, population data from http://quickfacts.census.gov/qfd/index.html, % voting from McCain from http://en.wikipedia.org/wiki/United_States_presidential_election_in_Connecticut,_2008 and equivalent pages for the other states with Irene deaths, and gay marriage stats from http://en.wikipedia.org/wiki/Same-sex_marriage_law_in_the_United_States_by_state using a dummy variable of 1 if gay marriage is allowed, 0 if it isn’t, and 0.5 if some kind of intermediate right is granted.]