On greedy algorithms and rodeo clowns
John D. Cook | Singular Value Consulting
by John
10h ago
This weekend I ran across a blog post The Rodeo Clown Theory of Personal Development. The title comes from a hypothetical example of a goal you don’t know how to achieve: becoming a rodeo clown. Let’s say you decide you want to be a rodeo clown. And let’s say you’re me and you have no idea how to be a rodeo clown. … Can you look at the possibilities currently available to you and imagine which of them might lead to an overall increase of rodeo clowndom in your life, even infinitesimally? Each day you ask yourself what you can do that might lead you closer to your goal. This is a greedy algo ..read more
Visit website
Finding strings in binary files
John D. Cook | Singular Value Consulting
by John
3d ago
There’s a little program called strings that searches for what appear to be strings inside binary file. I’ll refer to it as strings(1) to distinguish the program name from the common English word strings. [1] What does strings(1) consider to be a string? By default it is a sequence of four or more bytes that correspond to printable ASCII strings. There are command options to change the sequence length and the character encoding. There are 98 printable ASCII characters [2] and 256 possible values for an 8-bit byte, so the probability of a byte being a printable character is p = 98/256 = 0.38281 ..read more
Visit website
Extract text from a PDF
John D. Cook | Singular Value Consulting
by John
3d ago
Arshad Khan left a comment on my post on the less and more utilities saying “on ubuntu if I do less on a pdf file, it shows me the text contents of the pdf.” Apparently this is an undocumented feature of GNU less. It works, but I don’t see anything about it in the man page documentation [1]. Not all versions of less do this. On my Mac, less applied to a PDF gives a warning saying “… may be a binary file. See it anyway?” If you insist, it will dump gibberish to the command line. A more portable way to extract text from a PDF would be to use something like the pypdf Python module: from pypd ..read more
Visit website
Length of a general Archimedean spiral
John D. Cook | Singular Value Consulting
by John
3d ago
This post ties together the previous three posts. In this post, I said that an Archimedean spiral has the polar equation r = b θ1/n and applied this here to rolls of carpet. When n = 1, the length of the spiral for θ running from 0 to T is approximately ½ bT² with the approximation becoming more accurate [1] as T increases. In this post we want to look at the general case where n might not be 1. In that case the arc length is given by a hypergeometric function, and finding the asymptotic behavior for large T requires evaluating a hypergeometric function at a large argument. Here’s an example w ..read more
Visit website
How big will a carpet be when you roll or unroll it?
John D. Cook | Singular Value Consulting
by John
3d ago
If you know the dimensions of a carpet, what will the dimensions be when you roll it up into a cylinder? If you know the dimensions of a rolled-up carpet, what will the dimensions be when you unroll it? This post answers both questions. Flexible carpet: solid cylinder The edge of a rolled-up carpet can be described as an Archimedian spiral. In polar coordinates, this spiral has the equation r = hθ / 2π where h is the thickness of the carpet. The previous post gave an exact formula for the length L of the spiral, given the maximum value of θ which we denoted T. It also gave a simple approximat ..read more
Visit website
Approximating a spiral by rings
John D. Cook | Singular Value Consulting
by John
5d ago
An Archimedian spiral has the polar equation r = b θ1/n This post will look at the case n = 1. I may look at more general values of n in a future post. The case n = 1 is the simplest case, and it’s the case I needed for the client project that motivated this post. In this case the spacing between points where the spiral crosses an axis is constant. Call this constant h. Then h = 2πb. For example, when rolling up a carpet, h corresponds to the thickness of the carpet. Suppose θ runs from 0 to 2πm, wrapping around the origin m times. We could approximate the spiral by m concentric ..read more
Visit website
Hypergeometric function of a large negative argument
John D. Cook | Singular Value Consulting
by John
5d ago
It’s occasionally necessary to evaluate a hypergeometric function at a large negative argument. I was working on a project today that involved evaluating F(a, b; c; z) where z is a large negative number. The hypergeometric function F(a, b; c; z) is defined by a power series in z whose coefficients are functions of a, b, and c. However, this power series has radius of convergence 1. This means you can’t use the series to evaluate F(a, b; c; z) for z < −1. It’s important to keep in mind the difference between a function and its power series representation. The former may exist where the latte ..read more
Visit website
Precise answers to useless questions
John D. Cook | Singular Value Consulting
by John
1w ago
I recently ran across a tweet from Allen Downey saying So much of 20th century statistics was just a waste of time, computing precise answers to useless questions. He’s right. I taught mathematical statistics at GSBS [1, 2] several times, and each time I taught it I became more aware of how pointless some of the material was. I do believe mathematical statistics is useful, even some parts whose usefulness isn’t immediately obvious, but there were other parts of the curriculum I couldn’t justify spending time on [3]. Fun and profit I’ll say this in partial defense of computing precise answers t ..read more
Visit website
Pairs in poker
John D. Cook | Singular Value Consulting
by John
1w ago
An article by Y. L. Cheung [1] gives reasons why poker is usually played with five cards. The author gives several reasons, but here I’ll just look at one reason: pairs don’t act like you might expect if you have more than five cards. In five-card poker, the more pairs the better. Better here means less likely. One pair is better than no pair, and two pairs is better than one pair. But in six-card or seven-card poker, a hand with no pair is less likely than a hand with one pair. For a five-card hand, the probabilities of 0, 1, or 2 pair are 0.5012, 0.4226, and 0.0475 respectively. For a six-ca ..read more
Visit website
Solar system means
John D. Cook | Singular Value Consulting
by John
1w ago
Yesterday I stumbled on the fact that the size of Jupiter is roughly the geometric mean between the sizes of Earth and the Sun. That’s not too surprising: in some sense (i.e. on a logarithmic scale) Jupiter is the middle sized object in our solar system. What I find more surprising is that a systematic search finds mean relationships that are far more accurate. The radius of Jupiter is within 5% of the geometric mean of the radii of the Earth and Sun. But all the mean relations below have an error less than 1%. The radius of Mercury equals the geometric mean of the radii of the Moon and Mars ..read more
Visit website

Follow John D. Cook | Singular Value Consulting on FeedSpot

Continue with Google
Continue with Apple
OR