Leading digits of primes

How are the first digits of primes distributed? Do some digits appear as first digits of primes more often that others? How should we even frame the problem? There are an infinite number of primes that begin with each digit, so the cardinalities of the sets of primes beginning with each digit are the same. […]

Books and revealed preferences

Revealed preferences are the preferences we demonstrate by our actions. These may be different from our stated preferences. Even if we’re being candid, we may not be self-aware. One of the secrets to the success of Google’s PageRank algorithm is that it ranks based on revealed preferences: If someone links to a site, they’re implicitly […]

Any number can start a factorial

Any positive number can be found at the beginning of a factorial. That is, for every positive integer n, there is an integer m such that the leading digits of m! are the digits of n. There’s a tradition in math to use the current year when you need an arbitrary numbers; you’ll see this […]

Progress on the Collatz conjecture

The Collatz conjecture is for computer science what until recently Fermat’s last theorem was for mathematics: a famous unsolved problem that is very simple to state. The Collatz conjecture, also known as the 3n+1 problem, asks whether the following function terminates for all positive integer arguments n. def collatz(n): if n == 1: return 1 […]

Physical constants in Python

You can find a large collection of physical constants in scipy.constants. The most frequently used constants are available directly, and hundreds more are in a dictionary physical_constants. The fine structure constant α is defined as a function of other physical constants: The following code shows that the fine structure constant and the other constants that […]

Cauchy, Benford, and a problem with NHST

Introduction Samples from a Cauchy distribution nearly follow Benford’s law. I’ll demonstrate this below. The more data you see, the more confident you should be of this. But with a typical statistical approach, crudely applied NHST (null hypothesis significance testing), the more data you see, the less convinced you are. This post assumes you’ve read the […]

Technical notes on math and software

Table of contents Math diagrams Numerical computing Probability Differential equations Category theory Cryptography Logic Python Probability approximations Regular expressions C++ Special functions Typesetting: TeX, HTML, Unicode Emacs R Miscellaneous math My notes on cryptography have their own page. Math diagrams Diagram of probability distribution relationships Modes of convergence Topological properties diagram Category Relationships in Mathematical […]

Leading digits and quadmath

My previous post looked at a problem that requires repeatedly finding the first digit of kn where k is a single digit but n may be on the order of millions or billions. The most direct approach would be to first compute kn as a very large integer, then find it’s first digit. That approach […]