A random mental walk.

Sunday, December 30, 2018

Devil's Staircase in MATLAB

I can't recall how I stumbled over the description of the Devil's Staircase, but it sounded like an interesting programming problem.  Although I recognized the name, math ability has deteriorated to the point that references to Cantor Sets made no sense until I stumbled over pi.math.cornell.edu/~mec/Summer2009/Whieldon/Math_Explorers_Club%3A__Lesson_Links/Entries/2009/7/31_Lesson_3%3A__The_Devils_Staircase_%26_Other_Uncountable_Problems.html
 and the illustration below:
It took an embarrassing long time to get the coding correct.  I was reminded once again of truism I first heard from Roy Mendelson: The first step to solving a problem is the correct statement of the problem.

It took me a while because I was distracted by a seductively sneaky solution to the problem using MATLAB's array math. If the steps below the middle step could be calculated, all the steps after the middle step could be calculated in one swell foop by adding the value of the end point of the middle step to the array of steps between 0 and the lower x-value of the middle step.

It took me a while to find the appropriate quote from Knuth: "The real problem is that programmers have spent far too much time worrying about efficiency in the wrong places and at the wrong times; premature optimization is the root of all evil (or at least most of it) in programming." (From Computer Programming as an Art, p. 671, https://en.wikiquote.org/wiki/Donald_Knuth)

It was only after I'd solved the problem myself that an online search found a recursive solution (m2matlabdb.ma.tum.de/download.jsp?MC_ID=5&SC_ID=13&MP_ID=104) which provides not only a plot of the staircase, but the Cantor set as well.

(I avoid recursion because 1) I'm not good at it (why not admit it here), 2) recursion generally uses more memory than looping, and, lastly, I suspect that the repetitive function calls is slower.)

From a quick look at the recursive code I like mine even better because the recursive code starts with a conditional check to see how many steps are requested whereas mine will take any step.  (To be frank, however, the recursive code does the mandatory parameter checking.  Mine assumes that the user will not pass an invalid number of steps, e.g., 0 or a negative number, or pass a string or other pathalogical value.)

The recursive code creates the middle step and then if more steps are required generates the left and right side of the Devil's Staircase.  The code involves a lot of multiplication of array values.  My early assembler experience always made me avoid multiplication and array values.  I wish I could blame a cruel instructor for beating into using pointers and addition, but I did it to myself.  As MATLAB doesn't have pointers (yeah, I know, arrays are really pointers) I had to use arrays also.  You can see from the code that calculating a new vector value required two or three multiplications, depending on how you count.  (I'm guessing that the multiplication by 0.5 is accomplished by shifting the bits to the right rather than actually multiplying by 0.5

xr(stufe)=.5*((1-e)*xr(stufe+1)+(1+e)*xl(stufe+1));
yr(stufe)=.5*(yr(stufe+1)+yl(stufe+1));

My MATLAB solution is far from inspired, but much shorter than the recursive method.  The code generates the two member vector (0 and 1) and calls the genXValues function to generate the new values by using every other value in the current vector.  Here's the heart of it:

It' not pretty but it works.




Tuesday, December 25, 2018

Hey A Custom Error!

Anyone out there get this message on outlook?  I was trying to log in and an unknown error occurred. I'm sure alarm bells must be ringing in Redmond as they scramble to track this down.

Saturday, December 15, 2018

Wine & Spirits

Passing a store advertising Wine and Spirits I wondered what wine goes with the ghost of Christmas past?

Would a Merlot go with the specter of a woman spurned by her lover? 

What should be paired with an incubus?

Wednesday, August 15, 2018

Fintech, Adoption & 23% Interest

Always on the lookout for material for my classes, the headline of Hannah Levitt's article in the Wall Street Journal (July 3, 2018) caught my eye:

Personal Loans Surge to a Record High

The article was about fintech, newer players on the consumer lending scene.  Established entities like Goldman Sachs have entered the market along with startups.  What got me though was the lead:

"Heather Turner and her husband needed a few thousand dollars to jump-start the adoption of a teenager from Ukraine.

"The Turners, of Lewiston, Maine, needed a speedy loan and didn’t want to borrow against their house or car. Heather Turner said LendingClub arranged a 3-year loan for less than $10,000 last October at an interest rate around 23 percent -- similar to that of a credit card. Most notably, the loan is unsecured."

TWENTY-THREE bleeping percent!

A whole load of unanswerable questions popped into my mind, not the least of which was the 23%.  Doesn't that border on usury?  What was the need for speed?  What was the time pressure on adoption?  Was the kid on sale?  If the Ukrainian government was set to impose restrictions that fact wasn't in the article.

I understand the compassionate urge, but going into debt?  I didn't have the nerve to try to contact them to find out why, but then there's the internet and a gofundme page to supply the answers.

So Old News

It takes me a long time to get around to reading stuff, and a little longer to actually doing something.  Here's the latest example: An article in the November 18, 2015 WSJ with the headline "Mallinckrodt: Infant Drug, Gown Up Problem".

(I have a soft spot in my heart for Mallinckrodt because I still have their 60 year old notepads with yellow grid lines.  My dad drew cyclic organic compounds on them andI thought they were cool.  Also, I like pronouncing their name.)

The article concerned the drug Synacthen and Mallinckrodt's decision to raise the price of the drug 2,000%, a move which put it on the same footing as all the other bad boys in Pharma who wanted to show that without competition they could stick it to the patients.  The explanation/excuse was that the drug had been sold at a loss and the new price would insure that the company could continue to produce the drug.

The fact that the drug was approved to treat infantile spasms triggered a dim memory of drugs which were approved for one use, but were used for others.

A web search (just now) found a Washington Post article dated January 18, 2017 "Maker of $34,000-a-vial drug to pay $100 million for allegedly preventing competition".  If the revenues from that drug brought in $1 billion in 2015, a penalty of 10% of gross sales might not be too tough to handle.  The charge was that the drug, H.P. Acthar Gel, which once sold for $40 a vial, was acquired by Questcor Pharmaceuticals in 2001.  Questcor raised the prices and was acquired by Mallinckrodt.  When a rival company, Novartis, planned to market Synacthen, a potential competitor to Acthar, Mallinckrodt bought the rights, thereby eliminating a competitor.

There's nothing as comforting as a story which reinforces my believe in the venality behind much of big business.  And I say this knowing that my own financial security is dependent on companies making money, often by sticking it to those who are powerless to resist..

Wednesday, March 28, 2018

"If it costs you your peace, it's too expensive."

An email from International Living (internationalliving.com), a newsletter for expats and expat wannabes contained this quote from Bobby Blanchard who seems happily living simply in Puerto Vallarta: "If it costs you your peace, it's too expensive."

Blanchard and his significant other are getting by on $1,000/month.  I don't know what they aren't doing, but it falls in line with a thought which has been rattling around in my mind for a while: what do you really need? 

For those of us who do not play golf access to a golf course is immaterial.  The though of not being able to play golf would cause others to see their whole life to flash before their eyes.  As I read the messages from International Living I find myself thinking, "Not for me".  Their correspondents enjoy the local shopping (Nfm), the cheap happy hours (Nfm), the inexpensive local wine (Nfm), beer (Nfm), etc.

Sigh.

I'm looking for something, but I haven't seen it described yet.

Saturday, December 30, 2017

"Quarts" Countertops Through Angie's List

Sigh.

A recent kitchen remodeling offering from Angie's provided another example of a failing educational system or a desperate need for enhancing grammar/spellchecking software utilities.  High end kitchens may use granite or quartz, but "quarts"?

A perfunctory web search to see if a recent kitchen upgrade trend had escaped my notice produced only links to quartz countertops.  So someone can't spell, or  someone doesn't give a rip, or there is a vast right-wing/left-wing/radical religious/other-to-be-named-later) conspiracy at work.

The reviews may be trustworthy, but the proof-reading is not.


Sunday, September 10, 2017

CNN carried a video of Senator John McCain telling the host, Jake Tapper, "Every life has to end one way or another." adding a quote whose author he thought it was a playwright, "I always knew that no one could live forever, but I thought there might be one exception."

Well, what is the Internet for?  It was probably William Saroyan: "Everybody has to die, but I always believed an exception would be made in my case."

I wonder if Saroyan's most famous book, "The Human Comedy" is still read in grade schools?  From what I remember many writers felt that Saroyan was unfairly neglected compared to other writers of his era, e.g. Hemingway or Faulkner..

Sunday, August 27, 2017

I was reading a a copy of "Hollywood" by Garson Kanin, fished  from one of the piles of books with which my house is decorated when I came across a section about Marshall Nielan in a chapter devoted to "The Great Profile", John Barrymore.

I don't believe I'd ever heard the Nielan's name before, but was intrigued as Kanin described Nielan's Bits of Life as the funniest film he'd ever seen.  So it was quick to IMDB with this depressing result:


Sunday, June 18, 2017

Toilets

"So," he said, "How's your day been?"

It's not quite a rhetorical question, but I paused before I answered: "This will give you an idea:  I've been looking at toilets for the last hour and a half."

Backstory: I was preparing a lesson on using dynamic blocks in AutoCAD modeled after an online tutorial which used toilets.  (Dynamic blocks can be thought of as a stack of objects with only the top object being visible.)

The tutorial used several types of toilets which the narrator implied were available, but the installation of AutoCAD I used had one suitable toilet block.  To get more, I downloaded a ZIP file of toilet drawings from Kohler.

To make the lesson easier for the class I looked for toilets with shapes different enough to be easily distinguishable.  This probably will not come as a surprise to anyone who's renovated a bathroom, but aside from color, a lot of toilets look very much alike.  so as I was plowing through hundreds of drawings it struck me that I must be looking at a duplicate.  Sure enough the drawing I just looked like looked like another one I'd seen about a minute before.  I did an A-B comparison to see if there was a difference.  Here's the video:

There's a small difference in the diameter of the bolt holes for the seat.

I imagine that someone needed the larger/smaller bolt holes to accommodate the demands of feng shui.  ("Oh no! It's all wrong!   The smaller holes will ruin everything for the toilets pointing north.)  What may be more depressing is that there must be people whose job depends on not only knowing the difference between models of toilets, but remembering the tagline for each.  Of course there must be toilets which "reflect your good taste", but are there toilets which make a bathroom happier or more inviting?

Sunday, January 08, 2017

Barbara Allen/Barbry Ellen/Tecumseh Valley

I was listening to Meg Baird Sing "Barbry Ellen" (about 3½ minutes into the link below) when I was struck by the similarity of her version with Townes Van Zandt's "Tecumseh Valley". Her treatment of "Sweet William on his death bed lay
For love of Barbara Allen.
reminds me of Tecumseh Valley's
"The name she gave was Caroline
Daughter of a miner"
I'll pester one of the music instructors when school is back in session to see if I'm close.

Monday, September 05, 2016

Second Worst Interview on NPR

Michel Martin's interview with former U.S. Attorney General Alberto Gonzales was the second worst interview I've heard in the 31 years I've been listening to NPR.  (The worst interview was Daniel Zwerdling's interview with Stokely Carmichael/Kwame Ture.)

Martin should have asked Gonzales how it was that he could recall events now when he couldn't even remember if he was wearing underwear when he appeared before the Senate Judiciary Committee 9 years ago.  At the hearing Gonzales said ""I cannot recall..." or "I don't recall" over 70 times.

Absolutely appalling.

Tuesday, August 16, 2016

Covert hard Drive Noise

https://arxiv.org/abs/1608.03431
The quick an dirty: using malware and no speakers, researchers could force air-gapped computers - computers logically and physically disconnected from the Internet - to generate audio signals at "effective bit rate of 180 bits/minute (10,800 bits/hour) and a distance of up to two meters (six feet)."  The signal could be received by a computer, smartphone, etc.

That's nice, but at 180 bits/minute that works out to ~23 characters a minute, assuming ASCII encoding.  That might work for a password hack which may be all one needs.  

It might be just the push some organization will need to move to SSDs because the hack wprks by generating a specific audio frequencies by controlling the movements of the HDD's actuator arm. Digital Information can be modulated over the acoustic signals.  No actuator arm no signal.

Our security guy replied to my note about DiskFiltration by saying that a lot of this stuff was coming from last week's BlackHat conference. 

Saturday, July 23, 2016

We Survive a Swarm of Teenagers or Give Me Girls Every Time

An adjunct instructor was contacted about creating a field trip for a summer camp for disadvantaged middle and high school students.  Before you could say, "Whoa!" I was up to my eyeballs recruiting faculty to participate and then introducing the faculty to the adjunct so they'd read her (the adjunct's email) or put a face to a voice.

My bit of business was a piece of cake: show them how to create a program in Alice to do the following:
.
Not terribly exciting, but it would be the first programming experience for a lot of the kids.  The program could be used to explain how making intelligent decisions concerning logic would enable the same code to work regardless of how the bunny was positioned relative to the chicken.

What could go wrong?  Well for starters, a power outage a few weeks before made about half the PCs unable to login.  The software wasn't working on half the remaining PCs.  And, ever the good sole I had the Computer Center create special single use accounts in the room I was going to use and the computer lab for another presenter.  (The special accounts allowed the students to login, access the web, but not create files on network drives.)

Two former students agreed to demonstrate resonant frequencies.  We were pretty sure that the kids had never heard of the Tacoma Narrows Bridge and they'd be impressed to learn that engineers had to design buildings so that the structures didn't shake apart.  One later had her work schedule changed so it was down to one student.
I tried to use a web cam to allow a whole room to see what was happening on a shaker table.  I needed a long video cable, but the cable sent over didn't have the right pinning, but we managed to survive.  I was told the students were impressed that their minders were impressed.

I did my due diligence: checking out PCs in my room and the room used by another presenter and filing more than 2 dozen help desk tickets.  Because it was summer and the usual tech guy was on vacation, the Computer Center was in some turmoil as the Center's least favorite director was canned earlier in the week, I was rescued by some daring-do not described here lest some unnamed forces react badly.  (Murky I know, but, trust me, it's better that way.)

On the day of I got a shock when I found an instructor reading his Wall Street Journal in the room where I expected to make a presentation to about 40 kids 3 times.   It went like this:

"Hey Mike, what are you doing here?"
"What do you mean what am I doing here?  This is where I teach my class."

Uh-oh!  Scheduling conflict.  I don't think it was my doing, but definitely now my problem.  After some consultation, pleading, and abasement.  Mike agreed to hold his class next door and I would be out of his usually scheduled room in time for his students to use the computers.

It was an interesting experience because the kids showed up late because they'd walked over instead of coming over by bus.

The girls were great.  The followed instructions, raised hands when they had questions, and responded to questions.  The guys?  The ability to make the chicken cackle seemed irresistible to many.

It was gratifying.  One young woman wanted to know if she could have me as her teacher if she came to my college.  I should have said, "I'd love to have you."  I'm not used to dealing with kids.  What I said instead was, "If you come here you'd have to register for my course."  Bureaucratic.  I should be ashamed of myself.

On the other hand, a couple, including one of their minders, asked how they could get the software.  I gave all the info to the adjunct who got me into this and let her pass it along.

All students survived.  All equipment remained intact and in place.  From my point of view: Success!

I imagine that it might become a yearly summer event.  If so I'd be boring the students if I reused the same demonstration.  It might be cool though to have students send a signal over the web to activate a a piston to push something over an edge.  Shouldn't that appeal to the nihilism of grade school kids?


Tuesday, June 28, 2016

Trump and the Jerk Pride Movement

Donald Trump, the gift that keeps on giving.

When David Letterman, the former host of the Late Night Show, heard that Donald Trump decided to enter the presidential race he moaned that he had retired too early.

Trump has truly been an inspiration for pundits to sharpen their wit.

Patricia Nelson Limerick, faculty director and chair of the Center of the American West at the University of Colorado, co author of "The Frontier in American Culture", called Trump the standard-bearer for the currently booming “Jerk Pride Movement”  (www.denverpost.com/2015/12/18/limerick-jerk-studies-101/).

Her research, dating back many years established that the consensus of people who dealt with the public (waiters, hotel clerks, cab drivers, etc) was that 15% of the public were jerks.

Quoting from the article,
Trump should be understood as the standard-bearer for the currently booming “Jerk Pride Movement,” in which the Fifteen Percent stride vigorously out of the closet and present themselves to the world, shouting out wildly over-generalized, destructive, and polarizing sentiments and then, still shouting, congratulating themselves for their impressive forthrightness.
Because Limerick claims that her “research” showed the percentage of jerks in the population is 15% she was surprised that a cab driver put the number at only 5%.   Five percent,” he repeated. “But they move around a lot.”

Thinking this could be the basis of a serious question in a research methods class (sociology, psychology, marketing, analytics, etc.)  I forwarded the information to several profs in those areas.

Yes, it’s part of a joke, but assuming that the cab driver were correct, that the true number is 5%, what other error other than exceptionally poor math skills, double counting, or really poor sampling technique would explain the discrepancy?

Saturday, June 11, 2016

Flotsam from 2014

I discovered some mail and papers from 2014.  There were some medical bills, since paid, some phone numbers without associated names, some jokes which must have come from "Prairie Home Companion" on the back of an old final exam, and notes on the back of a quarterly statement from an annuity.

The annuity:

I remembered calling the annuity to find out what a "non-qualified annuity" was.  The guy I reached seemed delighted to enthusiastically explain everything in great detail.  I knew I had just become just-like-everyone-else because I couldn't follow him.

It is not supposed to be that way.  Maybe I was tired, It means that I should call again and this time record some definitive answers to some simple questions.  If I only knew what those simple questions might be.

The jokes:

"Cross-country skiing is easier in a small country."

"Go for the juggler."  (The punch line for a number of related jokes: "What should you if attacked by a mob of clowns?" and "How do you kill a circus?")

"What is all dressed up and no place to go?"  A Unitarian corpse.

A classic chemistry joke:
"I've lost an electron!"
"Are you sure?"
"I'm positive."
And this, a joke many women have found funny:
Q: What is the difference between a married man and a dead man?
A: When you're dead you don't wish you were married."

Wednesday, June 01, 2016

Stumbled Across Two Books About Wine and Drink

Adventures on the Wine Route: A Wine Buyer's Tour of France (2013) by Kermit Lynch.  I read a bit here and there.  Lynch is a charming writer to whom I'm now grateful for the Billat-Savarin description of the two features which distinguish man from beast: 1) Fear of the future and 2) Desire for fermented liquors 

Notes on a Cellar-Book ((2008) by George Saintsbury and Thomas Pinney  According to the notation, Saintsbury was a gifted and prolific writer.  I stumbled around online and found this quote from his critical introduction to Gibbons: ""There were some things—not many—which he did not and could not know; but almost everything that there was for him to know he knew."  That seems to be the type of praise every critic would want.

Friday, May 20, 2016

I saw Star Wars: The Force Awakens and Resent the Waste of Time

I saw Star Wars: The Force Awakens at a local library. It stirred memories:

  • A friend and I paid $1 each to see Robin Hood: Prince of Thieves. As the movie played we'd whisper to each other: "99¢",  "98¢", until Sean Connery appeared to kick the value from 45¢ to 50¢
  • Then there was my father's voice, "Who wrote this crap?"

The film brought to mind that old, snarky comment: "The dialog was so wooden as to constitute a fire hazard."  The dialog would have been right at home on title cards.

The First Order's got technology to destroy multiple planets with a super-duper weapon, but don't have video surveillance of their own installation.  Maybe it's a fixer-up film:  Hollywood makes the film and viewers can amuse themselves patching plot holes.   Sorry guys, I have stuff to do I real life.

Friday, November 20, 2015

The incomprehensible is just perfect

The mud line on the Doonesbury strip quoted James Parker's piece in the November 3rd Book Review section on Donald Trump's opinions (www.nytimes.com/2015/11/08/books/review/is-legitimate-satire-necessarily-directed-at-the-powerful.html):

Trump’s opinions — which I don’t believe are ­really opinions at all, but random clots and thrombi of rhetorical ectoplasm gathered from the ether with high-end paranormal pooper-scoopers.
Much like Ball's description of Trump as a gap in the space-time continuum, the statement forms a nice companion or parallel to the phenominon of the Trump campaign.

I look forward to the Iowa vote to see how reality as represented by physical votes matches the polls and surveys.  If a sizeable percentage of Republican voters believe that the President is a Muslim and a smaller, but statistically signiicant percentage of adults, still believe that Obama was born in Kenya it is hard to make a reasonable prediction.

I see only two courses of action: relax and laugh or relax and cry.

Friday, September 11, 2015

Flesh-colored gap in the space-time continuum

An item on Doonesbury's Mud Line sent me to the Atlantic website to read Molly Ball's August 13, 2015 article "Donald Trump and the Search for the Republican Soul" (www.theatlantic.com/politics/archive/2015/08/donald-trump-and-the-search-for-the-republican-soul/401192/).  A good article, main memorable by the a great quip,  flesh-colored gap in the space-time continuum."

Credit is hereby given to Ms Ball.

Donald Trump, God's gift to comedians, is a true phenomenon.  (David Letterman lamented having left his late night talk show 2 weeks before the Donald announced his candidacy.)  Rational beings, in my belief, would regard Trump as an exceptionally wealth clown with a surprising limited vocabulary worth of a few chortle-inducing sideshow.

That he isn't, or because he's been the front-runner in the polls for the Republican nomination for President, (polls show have him as the front runner with 32% of likely Republican voters) makes me wonder if all this noise is because no voting has yet taken place.  I look forward to the primaries where levers get pulled.  (Metaphors may be changing.  Voting may be when pen meets paper.)

There was a recent piece on WNYC radio this morning in which a magazine author (didn't get the names and can't find it on their web site) argued that Trump was a failure as a businessman.  The argument was that had Trump put the $40 million he inherited in 1974 into the general stock market (equivalent of an S&P market index fund) he would have more money than he has with all his business dealings.

My simple check is that the author is wrong.  In 1974 the S&P was in the mid 80's to the mid-90's.  The high for this year was 2063.  A hypothetical standard investment would have increased a shade under 24 times.  So $40 million times 24 is $960 million.  Not a trivial sum, but not a billion which now seems to be the benchmark for serious money.

Blog Archive