Archive for July, 2018

Histograms in grap

Saturday, July 28th, 2018

I know everyone loves it when I talk about arcane typesetting languages, so here’s a response to a fellow who wanted to replicate the histograms at http://www.jmillville.com/project/learnstats/ex9.html in grap.

 

Attached is a commented grap/groff file that draws something like both
histograms.  I commented the grap to explain what I was up to (comments
start with .\"), but feel free to ask about anything that's confusing.

I didn't see immediately how he set the widths of his histogram
bars/buckets, so I used 10-pound-wide buckets centered on 105,110,115...
for all crew (blue) and 5-pound-wide buckets centered on
105,110,115,120... for the rowers (green).  (The bucket width is both
the clustering range and the width of the histogram bars.)

I've attached the grap/groff (called hist.ms), the data file I used
called data, and the postscript it generates when I call

$ groff -Gp hist > hist.ps

on my ubuntu box with groff and grap installed.

I used grap 1.45 from a stock ubuntu .deb.

If I wanted to do this same task as flexibly as possible, I'd probably
preprocess the data using a scripting language and then generate grap
output that I'd run through groff as above.  I'm slowly writing a pic to
svg program in my spare time that would make that more portable to use.

Hope that helps some.

The grap script looks like this:

.G1
.\" Initialize globals
tot105 = tot115 = tot125 = tot135 = tot145 = tot155 = 0
tot165 = tot175 = tot185 = tot195 = tot205 = tot215 = 0

rtot105 = rtot115 = rtot125 = rtot135 = rtot145 = rtot155 = 0
rtot165 = rtot175 = rtot185 = rtot195 = rtot205 = rtot215 = 0
rtot110 = rtot120 = rtot130 = rtot140 = rtot150 = 0
rtot160 = rtot170 = rtot180 = rtot190 = rtot200 = rtot210 = 0

.\" between takes teh following args in order
.\" $1: value to test
.\" $2: center of bucket
.\" $3: bucket width
.\" $4: variable stem
.\" if the test value is in the bucket (between the center +/- width/2) 
.\" the macro increments the variable made from concatenating the stem and
.\" the bucket center.
define between {
  if ($1 >= $2-($3/2) && $1 < $2+($3/2) ) then {
    $4$2 = $4$2 + 1
  } 
}

.\" Copy the test data through between calls to set the globals
copy "data" thru {
  between($1,105,10,tot)
  between($1,115,10,tot)
  between($1,125,10,tot)
  between($1,135,10,tot)
  between($1,145,10,tot)
  between($1,155,10,tot)
  between($1,165,10,tot)
  between($1,175,10,tot)
  between($1,185,10,tot)
  between($1,195,10,tot)
  between($1,205,10,tot)
  between($1,215,10,tot)
  if ($3 == 1) then {
    between($1,105,5,rtot)
    between($1,110,5,rtot)
    between($1,115,5,rtot)
    between($1,120,5,rtot)
    between($1,125,5,rtot)
    between($1,130,5,rtot)
    between($1,135,5,rtot)
    between($1,140,5,rtot)
    between($1,145,5,rtot)
    between($1,150,5,rtot)
    between($1,155,5,rtot)
    between($1,160,5,rtot)
    between($1,165,5,rtot)
    between($1,170,5,rtot)
    between($1,175,5,rtot)
    between($1,180,5,rtot)
    between($1,190,5,rtot)
    between($1,185,5,rtot)
    between($1,195,5,rtot)
    between($1,200,5,rtot)
    between($1,205,5,rtot)
    between($1,210,5,rtot)
    between($1,215,5,rtot)
  }
}

.\" Set up the coordinates and the ticks to match the example
coord x 100, 220 y 0,8
ticks bot in 0.02 down 0.04 from 100 to 220 by 20
ticks top in 0.02 from 100 to 220 by 20 ""
ticks left in 0.02 left 0.08 from 0 to 8
ticks right in 0.02 from 0 to 8 ""
label left "Number of Members"
label bot "Weight in Pounds"
label top "The Boat Race Crew Histograms" size +2

.\" Draw bars for both kinds of crew
bar up 105 ht tot105 wid 10 fillcolor "blue"
bar up 115 ht tot115 wid 10 fillcolor "blue"
bar up 125 ht tot125 wid 10 fillcolor "blue"
bar up 135 ht tot135 wid 10 fillcolor "blue"
bar up 145 ht tot145 wid 10 fillcolor "blue"
bar up 155 ht tot155 wid 10 fillcolor "blue"
bar up 165 ht tot165 wid 10 fillcolor "blue"
bar up 175 ht tot175 wid 10 fillcolor "blue"
bar up 185 ht tot185 wid 10 fillcolor "blue"
bar up 195 ht tot195 wid 10 fillcolor "blue"
bar up 205 ht tot205 wid 10 fillcolor "blue"
bar up 215 ht tot215 wid 10 fillcolor "blue"

.\" Draw bars for rowers
bar up 105 ht rtot105 wid 5 fillcolor "forestgreen"
bar up 110 ht rtot110 wid 5 fillcolor "forestgreen"
bar up 115 ht rtot115 wid 5 fillcolor "forestgreen"
bar up 120 ht rtot120 wid 5 fillcolor "forestgreen"
bar up 125 ht rtot125 wid 5 fillcolor "forestgreen"
bar up 130 ht rtot130 wid 5 fillcolor "forestgreen"
bar up 135 ht rtot135 wid 5 fillcolor "forestgreen"
bar up 140 ht rtot140 wid 5 fillcolor "forestgreen"
bar up 145 ht rtot145 wid 5 fillcolor "forestgreen"
bar up 150 ht rtot150 wid 5 fillcolor "forestgreen"
bar up 155 ht rtot155 wid 5 fillcolor "forestgreen"
bar up 160 ht rtot160 wid 5 fillcolor "forestgreen"
bar up 165 ht rtot165 wid 5 fillcolor "forestgreen"
bar up 170 ht rtot170 wid 5 fillcolor "forestgreen"
bar up 175 ht rtot175 wid 5 fillcolor "forestgreen"
bar up 180 ht rtot180 wid 5 fillcolor "forestgreen"
bar up 185 ht rtot185 wid 5 fillcolor "forestgreen"
bar up 190 ht rtot190 wid 5 fillcolor "forestgreen"
bar up 195 ht rtot195 wid 5 fillcolor "forestgreen"
bar up 200 ht rtot200 wid 5 fillcolor "forestgreen"
bar up 205 ht rtot205 wid 5 fillcolor "forestgreen"
bar up 210 ht rtot210 wid 5 fillcolor "forestgreen"
bar up 215 ht rtot215 wid 5 fillcolor "forestgreen"

.\" Draw a key (Note that the positions here are in the histogram coordinates)
bar 102, 7.8, 155, 6.5
bar 105, 7.6, 120, 7.2 fillcolor "blue"
bar 105, 7.0, 120, 6.6 fillcolor "forestgreen"
"rowers and coxswains" ljust size -4 at 122, 7.4
"rowers and coxswains" ljust size -4 at 122, 6.8
.G2

Enjoy!

Review: Parable of the Talents

Saturday, July 21st, 2018

Parable of the Talents continues the tale Octavia Butler began in Parable of the Sower.

All the praise I heaped on the first part continues to be true of the second (and final) part.  Butler takes her dystopia to its crushing extremes in ways that may feel eerily precognitive.  There are obvious parallels to our current politics despite Talents being published in 1993.  To me that speaks more to Butler’s ability to understand and reflect on American society than any intent to predict the future.  She saw the core features of humanity and America that are on display here and on the news pages back then and put them on paper in this immersive story.  All the facts and philosophies that underlie Talents have permeated the literary and historical scene for quite some time.  It Can’t Happen Here and 1984 lay out the strategy, but Butler humanizes it.

Strongly recommended.

Review: The Line Becomes a River

Thursday, July 19th, 2018

Francisco Cantú has written a book that’s part anthropological field work, part journalism, part memoir, part disputation, and part vision quest.  That description sounds like a recipe for a patchwork of artifice, but Cantú has constructed a work that is much more difficult to describe than it is to understand.  It can be difficult to read, of course;  people are risking their lives in this world every day.

His topics, the southern US border, the policies around crossing it, and the Border Patrol that is the first point of enforcing them, are themselves a patchwork of emotion, history, and ideas.  People feel and think strongly about them and often they have no coherent way to express them in toto.  Cantú’s multi-faceted approach both illuminates the topics and articulates his views.  That articulation varies from matter of fact description to dream interpretation.

It doesn’t always work, of course.  There are passages that seemed overwrought to me.  It is clear he’s picking the incidents and anecdotes he relates to hang them on his themes.  Taken as a whole, I do find it moving and thought provoking.

It’s worth pointing out that his experiences all took place before the 2016 presidential election.  However one might think this has all changed since then, Cantú is clear that there was plenty of complexity and emotion here initially.

I want to put in a good word for the author’s mother.  She’s an incidental but powerful character.  I’d devour a biography of her.

Strongly Recommended.

Review: Hillbilly Elegy

Saturday, July 14th, 2018

J. D. Vance has done a reasonable job walking the line between memoir and social criticism in Hillbilly Elegy.  He tells a sound, comprehensive history of his Kentucky family and how they helped and hindered his life so far.  There are nods to how the culture in which they were steeped affects society in general.  That said, it left me a bit cold.

I agree with most of what he says here, but it’s also very much in line with my experience and upbringing.  I have significant Scots-Irish and Appalachian elements of my heritage as well as Italian and Polish immigrant elements and experience coming of age in a small Western New York town.  Everything he said jibes with that experience, though I was lucky enough to avoid the worst of the substance abuse and broken homes that directly impact Vance.  But Vance thinks that is ignored by modern culture to an extent that I don’t.

Perhaps tellingly, most of what he says about growing up a Kentucky hillbilly fails to resonates with experiences with family and friends in Western New York or my Italian and Polish relatives.  Lots of these values and hardships transcend Appalachia. Part of Vance’s point is that his history is more common than images of America might suggest.  I agree with that, but even so, he doesn’t illuminate much new ground for me.

Review: My Heart Is An Idiot

Sunday, July 8th, 2018

Reading Davy Rothbart’s My Heart Is An Idiot felt a lot like plopping down at a neighborhood bar and striking up a conversation with a guy who’s done some fun things and spins a great yarn.  Beers are traded, and a perhaps you and he are sucked into another.  Rothbart is a down on his luck salt of the earth who you were lucky to meet.

It’s a con.

Rothbart built that impression using his immense craft as a writer and unflinching bravery as a storyteller.  He structures those yarns like a mathematical proof, pulling the reader along into outlandish situations by presenting each step as part of a natural progression.  That’s how you get from “yeah, I’d fly out to Arizona meet a girl I’ve been chatting with online” to dodging traffic while hauling moose legs off a busy highway.  Nothing seems unusual until you – almost certainly a lesser writer – try to relate the same story.

Beyond that, he’s fearlessly honest.  Another way these aren’t just bar stories is in the way he talks about himself and his world.  His broken and idiotic heart turns up  naked and raw and then slips back away. Again, nothing sticks out, but his beliefs and perspective come out in an instant when in life it might take years to get that close.   He bares these bits in ways that make it feel like it’s part of a rambling story, and drops back into the story before his shaggy-dog momentum flags.

As much as the awe-inspiring writing, I like his perspective.

Strongly recommended.