Friday, November 22, 2019

Fun with numbers for November 22, 2019

How lucky can asteroid miners be?



So, I was speed-rereading Orson Scott Card's First Formic War books (as one does; the actual books, not the comics, BTW), and took issue with the luck involved in noticing the first formic attack ship.

Call it the "how lucky can you get?" issue.

Basically, the miner ship El Cavador (literally "The Digger" in Castilian) on the Kuiper belt had to be incredibly lucky to see the formic ship, since it wasn't in the plane of the ecliptic, and therefore could be anywhere in the space between 30 AU (4,487,936,130 km) and 55 AU (8,227,882,905 km) distance from the Sun.

The volume of space between $r_1$ and $r_2 $ for $r_2 < r_1$ is $4/3\, \pi (r_1 - r_2)^3$, so the volume between 30 and 55 AU is 219,121,440,383,835,000,000,000,000,000 cubic kilometers.

Let's say the formic ship is as big the area of Manhattan with 1 km height, i.e. 60 km$^3$. What the hay, let's add a few other boroughs and make it 200 km$^3$. Then, it occupies a fraction $9 \times 10^{-28}$ of that space.

To put that fraction into perspective, the odds of winning each of the various lotteries in the US are around 1 in 300 million or so; the probability of the formic ship being in a specific point of the volume is slightly lower than the probability of winning three lotteries and throwing a pair of dice and getting two sixes, all together.

What if the ship was as big as the Earth, or it could be detected within a ball of the radius of the Earth? Earth volume is close to 1 trillion cubic kilometers, so the fraction is 1/219,121,440,383,835,000, or $4.56 \times 10^{-18}$; much more likely: about as likely as winning two lotteries and drawing the king of hearts from a deck of cards, simultaneously.

Let us be a little more generous with the discoverability of the formic ship. Let's say it's discoverable within a light-minute; that is, all El Cavador has to do observe a ball with 1 light-minute radius that happens to contain the formic ship. In this case, the odds are significantly better: 1 in 8,969,717. Note that one light-minute is 1/3 the distance between the Sun and Mercury, so this is a very large ball.

If we make an even more generous assumption of discoverability within one light-hour, the odds are 1 in 42. But this is a huge ball: if centered on the Sun it would go past the orbit of Jupiter, with a radius about 1 1/3 times the distance between the Sun and Jupiter. And that's still just under a 2.5% chance of detecting the ship.

Okay, it's a suspension of disbelief thing. With most space opera there's a lot of things that need to happen so that the story isn't "alien ship detected, alien weapon deployed, human population terminated, aliens occupy the planet, the end." So, the miners on El Cavador got lucky and, consequently, a series of novels exploring sociology more than science or engineering can be written.

Still, the formic wars are pretty good space opera, so one forgives these things.



Using Tribonacci numbers to measure Rstats performance on the iPad


Fibonacci numbers are defined by $F(1) = F(2)= 1$ and $F(n) = F(n-1) + F(n-2)$ for $n>2$. A variation, "Tribonacci" numbers ("tri" for three) uses $T(1) = T(2) = T(3) = 1$ and $T(n) = T(n-1) + T(n-2) + T(n-3)$ for $n>3$. These are easy enough to compute with a cycle, or for that matter, a spreadsheet:


(Yes, the sequence gets very close to an exponential. There's a literature on it and everything.)

Because of the triple recursion, these numbers are also a simple way to test the speed of a given platform. (The triple recursion forces a large number of function calls and if-then-else decisions, which strains the interpreter; obviously an optimizing compiler might transcode the recursion into a for-loop.)

For example, to test the R front end on the iPad nano-reviewed in a previous FwN, we can use this code:


Since it runs remotely on a server, it wasn't quite as fast as on my programming rig, but at least it wasn't too bad.

Note that there's a combinatorial explosion of function calls, for example, these are the function calls for $T(7)$:


There's probably a smart mathematical formula for the total number of function calls in the full recursive formulation; being an engineer, I decided to let the computer do the counting for me, with this modified code:


And the results of this code (prettified on a spreadsheet, but computed by RStudio):


For $T(30)= 20,603,361$ there are 30,905,041 function calls. This program is a good test of function call execution speed.


Charlie's Angels and Rotten Tomatoes



Since the model is parameterized, all I need to compute one of these is to enter the audience and critic numbers and percentages. Interesting how the critics and the audience are in agreement in the 2019 remake, though the movie hasn't fared too well in the theaters. (I'll watch it when it comes to Netflix, Amazon Prime, or Apple TV+, so I can't comment on the movie itself; I liked the 2000 and 2003 movies, as comedies that they were.)



Late entry: more fun with Tesla



15-40 miles of range, using TSLA's 300 Wh/mile is 4.5 kWh to 12 kWh. Say 12 hours of sunlight, so we're talking 375 to 1000 W of solar panels. For typical solar panels mounted at appropriate angles (150 W/m2), that's 2.5 to 6.7 square meters of solar panels…

Yeah, right!



No numbers: some Twitterage from last week


Smog over San Francisco, like it's 1970s Hell-A


Misrepresenting nuclear with scary images


Snarky, who, me?



Alien-human war space opera – a comprehensive theory





Friday, November 15, 2019

Fun with numbers for November 15, 2019

How many test rigs for a successful product at scale?


From the last Fun with Numbers:


This is a general comment on how new technologies are presented in the media: usually something that is either a laboratory test rig or at best a proof-of-concept technology demonstration is hailed as a revolutionary product ready to take the world and be deployed at scale.

Consider how many is "a lot of," as a function of success probabilities at each stage:


Yep, notwithstanding all good intentions in the world, there's a lot of work to be done behind the scenes before a test rig becomes a product at scale, and many of the candidates are eliminated along the way.



Recreational math: statistics of the maximum draw of N random variables


At the end of a day of mathematical coding, and since Rstudio was already open (it almost always is), I decided to check whether running 1000 iterations versus 10000 iterations of simulated maxima (drawing N samples from a standard distribution and computing the maximum, repeated either 1000 times or 10000 times) makes a difference. (Yes, an elaboration on the third part of this blog post.)

Turns out, not a lot of difference:


Workflow: BBEdit (IMNSHO the best editor for coding) --> RStudio --> Numbers (for pretty tables) --> Keynote (for layout); yes, I'm sure there's an R package that does layouts, but this workflow is WYSIWYG.

The R code is basically two nested for-loops, the built-in functions max and rnorm doing all the heavy lifting.

Added later: since I already had the program parameterized, I decided to run a 100,000 iteration simulation to see what happens. Turns out, almost nothing worth noting:


Adding a couple of extra lines of code, we can iterate over the number of iterations, so for now here's a summary of the preliminary results (to be continued later, possibly):


And a couple of even longer simulations (all for the maximum of 10,000 draws):


Just for fun, the probability (theoretical) of the maximum for a variety of $N$ (powers of ten in this example) is greater than some given $x$ is:




More fun with Solar Roadways


Via EEVblog on twitter, the gift that keeps on giving:


This Solar Roadways installation is in Sandpoint, ID (48°N). Solar Roadways claims its panels can be used to clear the roads by melting the snow… so let's do a little recreational numerical thermodynamics, like one does.

Average solar radiation level for Idaho in November: 3.48 kWh per m$^2$ per day or 145 W/m$^2$ average power. (This is solar radiation, not electrical output. But we'll assume that Solar Roadways has perfectly efficient solar panels, for now.)

Density of fallen snow (lowest estimate, much lower than fresh powder): 50 kg/m$^3$ via the University of British Columbia.

Energy needed to melt 1 cm of snowfall (per m$^2$): 50 [kg/m^3] $\times$ 0.01 [m/cm] $\times$ 334 [kJ/kg] (enthalpy of fusion for water) = 167 kJ/m$^2$ ignoring the energy necessary to raise the temperature, as it's usually much lower than the enthalpy of fusion (at 1 atmosphere and 0°C, the enthalpy of fusion of water is equal to the energy needed to raise the temperature of the resulting liquid water to approximately 80°C).

So, with perfect solar panels and perfect heating elements, in fact with no energy loss anywhere whatsoever, Solar Roadways could deal with a snowfall of 3.1 cm per hour (= 145 $\times$ 3600 / 167,000) as long as the panel and surroundings (and snow) were at 0°C.

Just multiply that 3.1 cm/hr by the efficiency coefficient to get more realistic estimates. Remember that the snow, the panels, and the surroundings have to be at 0°C for these numbers to work. Colder doesn't just make it harder; small changes can make it impossible (because the energy doesn't go into the snow, goes into the surrounding area).



Another week, another Rotten Tomatoes vignette


This time for the movie Midway (the 2019 movie, not the 1972 classic Midway):


Critics and audience are 411,408,053,038,500,000 (411 quadrillion) times more likely to use opposite criteria than same criteria.

Recap of model: each individual has a probability $\theta_i$ of liking the movie/show; we simplify by having only two possible cases, critics and audience using the same $\theta_0$ or critics using a $\theta_1$ and audience using a $\theta_A = 1-\theta_1$. We estimate both cases using the four numbers above (percentages and number of critics and audience members), then compute a likelihood ratio of the probability of those ratings under $\theta_0$ and $\theta_1$. That's where the 411 quadrillion times comes from: the probability of a model using $\theta_1$ generating those four numbers is 411 quadrillion times the probability of a model using $\theta_0$ generating those four numbers. (Numerical note: for accuracy, the computations are made in log-space.)



Google gets fined and YouTubers get new rules


Via EEVBlog's EEVblab #67, we learn that due to non-compliance with COPPA, YouTube got fined 170 million dollars and had to change some rules for content (having to do with children-targeted videos):


Backgrounder from The Verge here; or directly from the FTC: "Google and YouTube Will Pay Record $170 Million for Alleged Violations of Children’s Privacy Law." (Yes, technically it's Alphabet now, but like Boaty McBoatface, the name everyone knows is Google. Even the FTC uses it.)

According to Statista: "In the most recently reported fiscal year, Google's revenue amounted to 136.22 billion US dollars. Google's revenue is largely made up by advertising revenue, which amounted to 116 billion US dollars in 2018."

170 MM / 136,220 MM =  0.125 %

2018 had 31,536,000 seconds, so that 170 MM corresponds to 10 hours, 57 minutes of revenue for Google. 

Here's a handy visualization:






Engineering, the key to success in sporting activities


Bowling 2.0 (some might call it cheating, I call it winning via superior technology) via Mark Rober:


I'd like a tool wall like his but it doesn't go with minimalism.



No numbers: recommendation success but product design fail.



Nerdy, pro-engineering products are a good choice for Amazon to recommend to me, but unfortunately many of them suffer from a visual form of "The Igon Value Problem."

Saturday, November 9, 2019

Fun with numbers for November 9, 2019

Science illustrations made by people without quantitative sensibility


From a tweet I saw retweeted by someone I follow (lost the reference), this is supposed to be a depiction of the Chicxulub impact:


My first impression (soon confirmed by minor geometry) was that that impact was too big; yes, the meteor was big for a meteor (ask the dinosaurs…), but the Earth is really really big compared to meteors. Something that created such a large explosion on impact wouldn't just kill 75% of the species on Earth, it would probably kill everything on the planet down to the last replicating protein structure, boil the oceans, and poison the atmosphere for millions of years.

Think Vorlon planet-killer, not Centauri mass driver. 🤓

Using a graphical estimation method (fit a circle over that segment of the Earth to get the radius in pixels, so that we can translate pixels into kilometers), we can see that this is an overestimation of at least 6-fold in linear dimensions (the actual crater diameter is ~150km):


6-fold increase in linear dimensions implies 216-fold increase in volume (and therefore mass); using the estimated energy of the actual impact from the Wikipedia, the energy of the impact above would be between $2.81 \times 10^{26}$ and $1.25 \times 10^{28}$ J or up to around 22 billion times the explosive power of the largest H-bomb ever detonated, the Tsar Bomba.

The area of the Earth is 510.1 million square kilometers, so that's 43 Tsar Bombas per square kilometer --- which is a lot, considering that the one Tsar Bomba that was detonated had a complete destruction radius in excess of 60 km (or an area of 11,310 square kilometers) and partial destruction (of weaker structures) at distances beyond 100 km (or an area of 31,416 square kilometers). And, again, that's 43 of those per square kilometer; so, yeah, that would probably have been the end of all life as we know it on Earth, and I wouldn't be here blogging about it.

A more accurate measurement, using a bit of trigonometry (though still using Eye 1.0 for the tangents):


Because of the eye-based estimation, it's a good idea to do some sensitivity analysis:



(Results are slightly different for the measured case because of full-precision calculation as opposed to dropped digits in the original, hand-calculator and sticky notes-based calculation.)

It gets worse. In some depictions we see the meteor, and it's rendered at the size of a planetoid (using the graphical method here too, because it's quick and accurate enough):


To be clear on the scale, that image is 442 pixels wide, the actual Chicxulub meteor at the same scale as the Earth would be 1-7 pixels wide, which is smaller than the dots in the dotted lines.

For additional context, the diameter of the Moon is 3,474 km, so the meteor in the image above is almost 1/3 the diameter of the Moon (28% to be more accurate) and that impact crater is over 1/2 the diameter of the Moon (60% to be more accurate).



Solar energy density in context



2 square kilometers for 100 MW nameplate capacity… and they're in the shade in that photo, so not producing anything at the moment.

Capacity factor for solar is [for obvious reasons] hard bound at 50%. For California, our solar CF is 26%; let's give Peter Mayle's Provence slightly better CF at 30%, and those 2 square km of non-dispatchable capacity become about 1/20 of a single Siemens SGT-9000H (fits in 1200 square meters with a lot of space to spare for admin offices and break room, works 24/7).




Nano-review of R Programming Compiler for the iPad



Basics: Available on the iOS app store; uses a remote server to run the code, so must have a net connection. Free for the baseline but seven dollars for plots and to use packages, which I paid. The extended keyboard is very helpful considering the limitations of the iPad keyboard. (Also runs on the iPhone and the iPod touch, though I haven't used it on them yet.)

I wouldn't use it to develop code or even to run serious models, but if there's a need to do a quick simulation or analysis (or even as a matrix calculator), it's better than Numbers. Can also be used offline to browse (and edit) code, though not to run it.

The programmer-joke code snippet in the above screen capture run instantly over a free lobby internet in a hotel conference center, so the service is pretty efficient for these small tasks, which are the things I'd be using this for.



Some retailers plan to eat the losses from tariffs


From Bain and Company on Twitter:


My comment (on twitter): Yeah, these are well-behaved cost and demand functions so when a tariff is added to the cost, typically the quantity drops and the price rises, unless there's some specific strategic reason to incur short-term opportunity costs.

Rationale (from any Econ 101 course, but I felt like drawing my own, just for fun):


Note that Bain's breakpoint at 50% of the tariff is the solution to the problem under linear demand with constant marginal cost, but other shapes of demand can make that number much bigger, for example, this exponential leads to 74% (numbers rounded in the diagram but not in the computation):


The demand function is nothing awkward or surprising, just a nice decreasing exponential:


On the other hand, if the marginal cost decreases with quantity, particularly if marginal cost is strongly convex, there's a chance the actual price increase from a tariff is higher than the tariff, even with linear demand:



Note that this is different from lazy markup pricing. Lazy markup pricing always raises the price by more than the tariff, so in places where such outdated pricing practices [cough Portugal /cough] are common, tariffs have a disproportionate negative impact on the economy and general welfare.



Late non-numerical entry: Another news item based on not understanding the life cycle of technologies

From Bloomberg (among many others) we learn that there's a new solar energy accumulator technology, and as usual the news write it up as if product deployment at scale is right around the corner, whereas what we have here is a lab testing rig… that's a lot of steps before there's a product at scale. And many of those steps are covered with oubliettes.



Friday, November 1, 2019

Fun with numbers for November 1, 2019

Fast-charging batteries


From the web site that hangs off of the brand equity of the very prestigious journal Science: "New charging technique could power an electric car battery in 10 minutes

Congratulations to the team improving battery technology. But:

I. According to the news, this is a technology demonstration, though that might be inaccurate (the original report makes it a testing rig, which is one step farther back from a final product). There's a lot of work to do (and many avenues for failure) before this becomes a deployable product, much less at scale.


II. Charging a 75 kWh battery (AFAIK, the smallest battery in a Tesla car) in 10 minutes requires a charging power of 450 kW. Even using 480 V as the charging voltage, that's still a 937.5 A current; those cables will need some serious heft, and any impurities in the contacts will be a serious fire hazard.

III. A typical gas pump moves about 3 l of gasoline per second. Gasoline has around 34 MJ/l energy density, so that pump has a power rating of 102 MW, 227 times higher energy throughput than the new battery. Even if the distance/energy efficiency of internal combustion engines is lower than electric motors, that's a big difference. Also, you can buy Reese's peanut butter cups at gas stations.



More fun with Rotten Tomatoes



Watchmen (HBO series) shows that sometimes when data changes, the conclusions change.


Despite the caterwauling of many in the comic-book nerd community (not that I would know, as I don't belong… okay, I occasionally might take a look, but I'm not a comic book nerd… not since the early 70s…), data show that it's much more likely that the critics and the audience are using similar criteria for their evaluation of Joker than opposite criteria.

How much more likely? Glad you asked:

210,565,169,600,721,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000 times more likely.

Ah, the power of parameterized models: you set them once, you can nerd out on them till the end of time. (I haven't watched either the show or the movie. Maybe when they get to Netflix or Amazon Prime.)


Added Nov 3: Haven't watched it yet, but Rotten Tomatoes data shows that critics are 1,361,188 times more likely to be using the same criteria as the audience than opposite criteria to evaluate "For All Mankind."



Some progress in nuclear fusion?



Some simple physics:
1 kg mass = 9E16 J of energy ($E = mc^2$)
Coal has 30 MJ/kg specific energy
10E6 kg coal have 3E14 J (assuming Bloomberg meant using combustion)
Fusion is to have 1/300 efficiency relative to pure mass-energy conversion?

Kudos. Now, get to it!



Shredded Sports Science eats an apple


Shredded Sports Science has a video making fun of people who know even less about fitness and nutrition than the "experts" in those "sciences," where he takes a bite of an apple and says "one rep," another bite, "two reps," the joke being on Chris Heria of Thenx.


Huh, the quant says, I wonder how the numbers will go…

Let's say a warm-up set of 100 kg squats and the total vertical path is 1 m. How much energy does one rep use, just for the mechanical work?

Naïve physics neophyte: huh, zero, the rep starts and ends at the same point.

No. The mechanics of the rep are different on the way down and on the way up: assuming that the weight moves at constant speed most of the time, the down movement requires the body provide work to counteract acceleration, so we can approximate the total work by 2 * 100 * 9.8 * 1 = 1960 J.

Note that this is just the mechanical part. Muscles have less than 100% efficiency and that efficiency changes as fatigue increases, hence the heat (heat, and to a smaller degree, changes to the mix of waste products of muscle contraction, represent losses in efficiency).

The other side of the coin is the chemical energy in that apple, which is measured by the magic ['delusion' or 'deception' also work here] of mistaking the simple process of combustion for the very complex processes of digestion and respiration. But let's pretend…

Apples are basically 1/3 sugar and 2/3 water, with some esters and ester aldehydes for taste and aroma, so for a small bite let's say 15g of apple we get 5 g of sugar; that's 20 kCal or ~ 84,000 J.

Shredded Sport Science's little joke would point to a combined digestion, respiration, and muscle contraction efficiency of 2.33%.

Evolution would have selected this biochemical parameterization right out of the gene pool.



Fun with energy



Talk about counting calories in a way that matters. (From the BP energy stats 2019; and yes, their tables are in MtOE, not calories, but unit changes are trivial, except maybe for gymbros.)



Bay Area versus Europe


With the return of Silicon Valley on HBO, there's a lot of hating on the Bay Area going around, so here's a thought in numbers…