A thoroughly unscientific study of computers in the New York City court system

I am on jury duty today. Civil court, as it turns out. I last served in 2003, when I sat on one of the “murder and mayhem” grand juries (grand juries in New York specialize in drugs, family, violent, or white collar crime). On the violent crime grand jury we heard about a dozen cases, none of which I am allowed to disclose, though I will say that one of the accused had tried to kill himself by pressing a running power drill against his head until, I think, he broke the bit, then slashed his wrists, jumped out of an eighth story window, and survived. I proposed that we waive any indictment in exchange for this superman’s agreeing to be dropped on Afghanistan, but that power is evidently not available to grand juries.

Anyway, since my last stint they have installed Wifi in the court building.

I’m seeing 47 unambiguous PCs on the network and 12 Macs, with another 56 I’m not sure about. All the official machines seem to be PCs. I’ve noticed one machine with a public directory featuring a bootleg collection of hiphop recordings.

The man two seats to my right has fallen asleep and is snoring. Everybody else is jealous.

Posted in Uncategorized | Leave a comment

reversing the x-axis in a Mathematica graph

Sometimes you have data in which the dependent variable decreases as the independent variable increases, and for reasons of clarity in illustrating it, you want to flip the x-axis and show an increasing line (or vice versa). For example, sometimes you have

and you want to display it as

Unfortunately, Mathematica’s default behavior is to show both axes growing as you go up and to the right, and there is no simple option to change that. You can achieve this however by transforming your data by hand so that it is displaying the desired way, and then setting the “Ticks” variable of the plotting function to display the Ticks in reverse order. You can’t just say “reverse,” you have to create a list of the new tick labels and where you want them to go. This is generally done with a call to the Table[] command.

I more commonly flip the X axis than the Y, and given data in {{x1,y1},{x2,y2} . . . {xn,yn}} format, the following code makes it very easy to do.

xFlipper[listofXYpairs_] :=
Map[{Last[listofXYpairs][[1]] + First[listofXYpairs][[1]],
0} + {-1, 1}*# &, listofXYpairs]

Options[xFlippedTicks] = {numPoints -> 10, digits -> "All"};

xFlippedTicks[listofXYpairs_, OptionsPattern[]] :=
Table[{Last[listofXYpairs][[1]] + First[listofXYpairs][[1]] - i,
If[OptionValue[digits] == "All", i,
Round[i, 10^-OptionValue[digits] // N]]}, {i,
First[listofXYpairs][[1]], Last[listofXYpairs][[1]], (
Last[listofXYpairs][[1]] - First[listofXYpairs][[1]])/
OptionValue[numPoints]-1}]

The numpoints variable sets how many points to show on the X axis. The digits variable can reduce the number of the digits shown in the tickmarks if needed to make the graph more useful or attractive.

The first graph above was produced with

ListPlot[returnPairs, PlotLabel -> "Expected IRR vs. Upfront cost",
AxesLabel -> {"Amt Paid", "IRR"}, Joined -> True, Mesh -> True]

Given these two functions, we can transform it to the second graph above with

ListPlot[xFlipper[returnPairs], PlotLabel -> "Expected IRR vs. Upfront cost",
Ticks -> {xFlippedTicks[returnPairs, numPoints -> 5], Automatic},
AxesLabel -> {"Amt Paid", "IRR"}, Joined -> True, Mesh -> True]

(The “automatic” in the Tick specification tells Mathematica to continue to handle the Y axis automatically.)

Posted in mathematica | Leave a comment

Depressed preschoolers

Pamela has a new, big article in The New York Times Magazine, it is about depressed preschoolers.

Posted in pamela | Leave a comment

Pamela on the question of how liberal Liberals really are

In The New York Times this weekend: Are Liberals More to the Right Than They Think?

Evidently, people globally are not as liberal as they like to think. The study in question deals just with economic liberalism, not other questions of social equality. Enjoy!

Posted in pamela | Leave a comment

tagging time series plots in Mathematica

I hate legends on time series graphs. It’s invariably a hassle trying to figure out which color or which little marker corresponds to which line, and the legend takes up space and distracts from the data. Far better to tag the end of each data series on the graph itself, as in this example:

This is actually easy to do in Mathematica, especially if you have a standard datatype, as we do, that includes the name of the data series in its header.

Similarly, it is sometimes better to forgo datapoints entirely and to simply graph using the explanatory text itself.

Here is the code that produced the latter graph:

masterdata = {{"short person", 1, 2}, {"taller person", 2,
3}, {"the tallest", 3, 4}};

graphingdata = Map[{#[[2]], #[[3]]} &, masterdata];

ListPlot[graphingdata, PlotRange -> {{1, 3.5}, {1.5, 4.5}},
PlotMarkers -> Null,
PlotLabel -> "Often it is nice to use text rather than dots",
Epilog ->
Map[(Text[
Style[#[[1]], FontFamily -> "Times New Roman",
FontSize -> 9], {#[[2]], #[[3]]}, {-1.2, 0}] &), masterdata]]

Edward Tufte would approve.

Posted in mathematica | Leave a comment