The Drake Equation and Speciation

Adaptation of the Drake Equation for determining probability of speciation in populations

A while back, I broke a personal rule of mine and got involved in a debate at work over a controversial subject. Evolution in particular. I wouldn’t let myself get involved except that it was after 5pm, and thus I was off the clock. I’ll add that I have a great deal of respect for the intelligence of the person I was debating. We went back and forth for about 45 minutes as I explained how DNA works, and how cells reproduce, etc etc. In the end I had convinced him that something like evolution does happen, but he was still not sold on the entire theory.

In particular, he was hung up on the notion of speciation. He was fine with a wolf evolving into a dog, or dogs coming to have many breeds. What he didn’t subscribe to was the notion that tiny little changes could carry a species all the way from an amphibian to a horse, or a snake, or a human. So that’s where I left the debate. It was actually the first day of summer and I was already at work an hour later than I needed to be. On the way home I tried to think if there was a way to demonstrate how small changes in a population could become significant over time.  It was then that I recalled something vaguely similar from “Cosmos” by Carl Sagan.

In one chapter regarding extra-terrestrial life, he referred to the Drake Equation. This is a big but simple equation that tells you how many civilizations there are in the universe that can communicate with Earth. Now, of course it doesn’t actually tell you the answer to the question. The idea though, is that you feed the equation certain variables and play around with it. You can tell it your estimates for how many stars might have planets, and how likely a civilization is to try to communicate. You can feed in whatever crazy numbers you want, and see if there’s still a few planets out there.

I figured I could do something similar regarding the likelihood of speciation. Speciation is defined as the evolutionary process by which new species arise. After a number of failed attempts at doing it via computer programming, I remembered one of my own programming tips: “If at all possible, do it in Excel”.

So here’s my Equation. Perhaps it could be called the Darwin Equation. Mostly because Darwin is the name of a guy who, like Drake, has the letters D, A, and R in the first part of his last name.

N = [A / (B * V * W * X * Y)] * Z
(years per each new trait in population), times (the number of traits needed to be adopted)

N = years before speciation occurs

A = time between generations in years
B = number of new offspring per generation
V = chance of any mutation occurring in an individual
W = chance for any mutation to be beneficial
X = chance of beneficial mutation being passed to offspring
Y = chance of inherited beneficial mutation becoming prevalent in population
Z = number of mutations in population before speciation will have occurred

Here’s a link to a spreadsheet that lets you plug in values: Darwin Equation.xls
and if that doesn’t work, or you don’t have Excel, click here to see it in Google Doc’s (The text formatting’s a bit weird).

Perhaps you notice some weird flaws in my reasoning. There’s actually a number of them, but this equation is still useful. First it assumes that all these mutations happen one at a time. Also, it makes broad generalizations about things that aren’t known. It’s a vast oversimplification in all respects -But that’s the entire point.

The beauty of this equation is that one can simply plug in the numbers as desired and play around with the results. Ok, so one hundred new mutations isn’t speciation, then how about a one hundred thousand new mutations? Is that enough?

I’ve been playing around with it myself. Consider a species generating ten thousand offspring every 10 years, and 1/100 odds for each V, W, X, and Y variables, and requiring one hundred new mutations to occur. This works out to ten million years needed for speciation. Don’t like it? Plug your own values in. I don’t like it either. Ten million seems like a lot. Though if mammals first evolved about 200 million years ago, that leaves time for twenty speciation events to have occurred, each being a major step away from where that group started.

Now I know it didn’t really happen that way. This system is way too linear, it’s not meant to actually model how a species changes, it’s meant to model the numbers behind these changes. It allows one to give the most generous possible allowances in support of their own beliefs and see what’s comes of it. I’m a big fan of “upper bounds”. See my boat making notes, and my Whopper combinations. Upper bounds are relatively easy to determine, and are usually useful even with a good amount of error. As with the original Drake Equation, this algorithm smooshes together very large numbers and very small numbers. One in a million chances of a mutation, billions of members in the population. If a girl is one in a million, then there over a thousand of her in China. Some of whom may have beneficial mutations.

Permuting with the King: Part the 2nd

This post is the second installment of my attempt to make sense of Burger King’s claim that there are 221,184 ways to make a Whopper. So, please take a look at the first post if you have not already.

So where I left off I had “found” 81,920 unique Burger King Whoppers. A decent starting point, but still far short of the 221,184 figure I had in mind. I realized that these 81,920 combinations only told which toppings the burger had. They said nothing about what order the toppings went in. Each combination is a marker for a set. I then set about trying to figure out how many ways there were to swap around the ingredients. I won’t get into the details here, but it got complicated and convoluted. I woke up the next morning turning the math over and over in my head and I realized I was wrong in my chosen method.

I had assumed that in a 12 bit binary system, 1/12th of the possible representable numbers had eleven “1”‘s, and 1/12h had ten “1”‘s, and so on. As it turns out it’s more complicated than that. There are 12 different numbers that have only one “1”; {1000000000000, 010000000000, 00100000000,…). Likewise the same goes for numbers with eleven “1”‘s, observe the relation: {011111111111111, 101111111111, 110111111111…}. So, that means 12 out of the 81,920 combinations have 1 single ingredient to be swapped around (or ignored as it results in the same burger each time). And conversely, 8 out of the 81,920 burgers have seven ingredients to be swapped around. (The number of combinations from swapping “n” ingredients equals n factorial (!n) ).

Back to the ingredient distribution again, the number of Burgers with two
toppings is equal to the number of burgers with ten toppings. The value works out to 11+10+10+10+10+10+10+10+10+10+10+10 = 121 or 11+(11*10). Thus 121/81920 burgers have two ingredients to swap around (!2), and another 121/81920 burgers have ten ingredients to be swapped (!10).

For burgers with three or nine ingredients there’s a different formula. I tried to derive it. Really I did. I thought I had it, but I didn’t. There’s probably a great, simple solution on Wikipedia, which I could look up. Fortunately though, I’ve had a sort of Deus ex Machina up my sleeve all along.

I was researching this matter online earlier when I came across The Answer. The big number 221,184 is equal to 213, times 33. How do I know this? I know this because the answer was posted on a website called Answerbag.com, by a user named “xprofessor”. I tried to contact the person but couldn’t find any of their contact information. So, if you’re out there, please step forward and reap your glory. Maybe if you’re in town sometime I can buy you a drink.
Multiple patties
So what’s the significance of this number? Looks like it refers to 13 ingredients that there can be one or none of- and three ingredients that there can be one, two, or none of. But, wait, Burger King has Whoppers with three patties, or three cheeses, Which means…

Oh My GOD!

Burger King is wrong, and I figured it out!

In Part I, I identified 12 ingredients. The official answer needs 16. But I’ll stick to what I know, plus two mystery ingredients that I don’t care to look up at the moment. Let’s say that one can order either one, or none of the following: Mayo, lettuce, tomato, pickle, ketchup, onion, bbq sauce,jalapeno, mystery x, & y. That gives us the 210. And let’s further suppose that one can order one, two, three or none of the following: cheddar cheese, jalapeno cheese, bacon. That gives us the 43 part. And finally, one can order one, two, three, or four patties. (But none with zero, that wouldn’t be a burger). That’s adds 41 to the equation. This actually includes 15 ingredients, so there’s some room for experimentation there.

I now present, my own improved answer to the number of Burger King Whopper combinations: 262,144 = (210) x (43) x (41). And remember that number is a lower bound. Under my original dead end, each of those burgers represents one of many ways to arrange that particular set of ingredients. There’s likely other equally valid ways of multiplying the combinations, depending on what Burger King’s actual rules are. Still though, I’m happy to go to bed tonight knowing that there are more Whopper possibilities in the world.

Boat Noats

This last weekend I wound up entering a cardboard boat contest with my brother-in-law and some friends of his. It was all for charity, and consisted of a contest against other teams to build a boat using only the supplied sheets of cardboard, duct tape, varnish and rope length. The boat would then have to race others in a short course on the ocean.

A few days before the event we did some research before drawing up some candidate designs. Following this we actually fabricated scale models with paper, oak-tag, and even full cardboard. We complemented each other well, as he was very practical and I was very theoretical. In particular I concerned myself with some good rules of thumb for buoyancy.

First, two handy facts to be aware of: One cubic foot of water contains 7.48 gallons, and weighs a bit over 62 pounds. (62.425lbs to be exact)

A boat will only float if it weighs less than the weight of the water it would take to fill it. If one calculates the volume of the inside of a boat, that value will tell you the boat’s maximum potential buoyancy. A boat with a value of one cubic foot has a maximum potential buoyancy equal to the weight of one cubic foot of water, or about 62 pounds.

This is a pretty cool concept, and for me it results in counter-intuitive implications. A little box, 2’x2’x1′ is plenty to hold up a 170 pound man. (4 cubic feet > 240 lbs potential buoyancy) So, in terms of buoyancy any boat large enough for a person to fit into with reasonable comfort, should be able to stay afloat. -Of course, in reality the structural integrity of the boat, and balance, and water proofing are each equally important.

Testing Scale Models

After some failed prototypes, we had a good 1/6th scale model which was put in the bath-tub for testing. It seemed to float alright so we started testing it further by putting little cans of food into it. Two, three, four, went alright, but more than that and it tipped and sank. So, if 12 ounces of cans sunk our 1/6th model, how many pounds would it take to sink the real thing? The question gnawed at our brains. My first guess was to scale it up. 1/6th model, so 1/6th weight, therefore our full boat should be able to hold… 6 x 12 ounces = 72oz = 4.5 pounds? That couldn’t be right.

Coming at the problem from the other end, I had calculated the boat’s full dimensions and volume. Based on that, I got a potential buoyancy figure of close to 200lbs. The 4.5 pound answer had to be wrong. Days went by and we discussed and debated over how to scale-up weight in a model.

Later, I ran the problem by my Dad who granted me the critical insight. For models, when one increases the length by a certain amount, they’re increasing the surface area by a square factor, and the volume by a cube factor. The idea sunk in over the course of an hour or so. Here’s the summarized solution that we ended up working out.

The 1/6th scale refers only to the scaling of lines. In a 1/6th scale, the line between any two points will be 1/6th the length of any line on the full model.

For 1/6 scale 2D surfaces, the full surface area will be equal to the surface area on the model, times 6, squared.

For 3D volumes, the full volume will be equal to the volume in the model, times 6, cubed. Which can be expressed generally as:

VF = (scale-3) VM

(Scale is to be input as any fraction, 1/3, 1/6, etc. VF = volume of full model, VM= Volume of scale model.)

Since we’ve already connected the buoyancy of a boat to the volume of water it contains, then we can regard a volume of size n as being analogous to a weight of size x. In other words, being able to scale-up a volume is equivalent to being able to scale-up a weight, for our purposes.

So 12 ounces of cans in a 1/6th scale model is equivalent to:

(1/6)-3 x  12 = 216 x 12 = 2592 ounces, or 162 pounds.

Now that’s a lot more like it! Further, if you know how much weight you want your finished product to carry, you can swap the volume equation around a bit and get:

VM = VF / (scale-3)
Which tells you how much weight your model will need to be able to handle.

Our boat ended up working fine. We came in 2nd place out of about 12 contestants. The craft performed admirably, handled well, and laid birth nice and dry. Avast. And remember, the materials only cost about $25. For the price of movie admission, you and two friends could spend the day engineering and riding around in a cardboard boat.

Permuting With the King: Part the 1st

———
This article is part one of two. Please note that the conclusion reached at the end of this post is incorrect. The resolution is provided in Part Two.
———

My favorite fast-food place in the North East is Burger King. I’m hesitant to admit it, but something about their menu and pricing really appeals to my dietary id. As normal, their marketing is pushing how friendly they are to special orders. In particular they have an advertisement claiming there are 221,184 different ways to make a Whopper. Enticed by this claim, I felt motivated to see if I could re-derive the number on my own.

First off, I needed to know what I had to work with; that is, what toppings will I be playing around with? A quick brainstorm and double checking gave me the following:

  • mayo (1)
  • lettuce (1)
  • tomato (1)
  • pickle (1)
  • ketchup (1)
  • onion (1)
  • bbq sauce (1)
  • jalapeño (1)
  • cheddar cheese (3)
  • jalapeño cheese (3)
  • bacon (3)
  • pattie (4)

I’ve elected to ignore bread in my equations, assuming there’ll be one on top and one on the bottom. Note those numbers in parentheses to the right of each ingredient. Those values indicate how many times each ingredient can go in a sandwich, and are simply my own guesses. I’m sure if you wanted quadruple-bacon, or a fifth pattie they’d be willing to work with you. So, how many different burgers are there to be made with these ingredients?

First I’ll deal with only the first 8 ingredients that will appear either (1) or (0) times in each sandwich. Perhaps you can guess where I’m going with this by my wording. I imagine being behind the counter with all the ingredients lined up, each in its own box. And each box has a little light on it that lights up if that ingredient goes in the sandwich I’m making. Each light can either be on or off, so the row of ingredients is actually exactly like counting in binary with 8 bits (or boxes of ingredients in this case). The number of combinations is equal to the number of 8 bit binary numbers, or 28 = 256.

So that’s the first 8 ingredients. Then there are the three ingredients that I’ve decided can come in single, double, triple, or none. These work with the same idea, only in base 4 instead of binary. Since there’s three of these ingredients, with 4 cases, the equation is 43 = 64. Then the last option of up to 4 patties is 51 = 5. (With the zero option creating a no-beef burger, arguably not a Whopper.)

So, to find all the ways these three sets of ingredients can be combined, I can multiply them by each other. (28) * (43) * (51) = 81,920. 81,920 different burgers, each with a unique combination of toppings and ingredients. That’s a lot, but it’s still short of 221,184 claimed. What else?

These 81,920 combinations only tell which toppings the burger has. They say nothing about what order the toppings go in. Each combination is a marker for a set. I think the simplest way to figure out the size of these sets is to start by assuming the double/triple toppings will stick together as a unit. Thus, I’ll assume that two slices of cheddar cheese will always be together, and two patties will always be together. So, in this portion of my reckoning, I’m dealing with 12 slots of ingredients.

How many ways are there to arrange 12 items? The answer comes via combinatorics and permutations. According to Wikipedia :

If n denotes the size of the set – the number of elements available for selection – and only permutations are considered that use all n elements, then the total number of possible permutations is equal to n!, where “!” is the factorial operator.

So, simple. Just get the factorial of 12, and that’s the number of ways to permute each of the 81,920 burgers, so (12!) * 81,920. – But wait. The 12 part there isn’t correct. Yes, there are some burgers that have all twelve ingredients, but there are also many that have a lot of ingredients missing. The straight permutation of 12 results in switching around the absence of ketchup and the absence of cheese and the absence of pickles, and thus does not result in unique burgers.

The solution is that (1/8)th of the eight binary ingredient burgers will have all 8 toppings. And another (1/8th) of those burgers will have 7 toppings, and the next 8th will have 6 toppings. Also of the three base-4 ingredients, 1/3rd will have all 3 ingredients, another third will have 2 ingredients, and so on.

So,

[!8 * ((28)/8)] + [!7 * ((28)/8)] + [!6 * ((28)/8)] + [!5 * ((28)/8)] + …

= total permutations for all eight binary ingredients,

and,

[!3 * ((43)/3)] + [!2 * ((43)/3)] + [!1 * ((43)/3)] = total permutations for all three base-4 ingredients,

and lastly,

[!1 * ((51)/1)] = combinations of the 4 patties.

So, just multiply these all together and I’ll have my version of the answer.

1479456 singles, times 192 triples, times 5 quadruples, equals; (drum-roll please):

1,420,277,760 different burgers, minus the one “zero burger” in there, without any ingredients.

– At least. Remember there’d be more combinations if I allowed the multiple patties and cheeses to permute individually. A person could eat that many burgers in as little as 162,132 years, provided they eat one burger every hour. That’s a big number, much bigger than the 200k-ish figure stated by the good folks at Burger King. I don’t have any hostility or argument against that figure though. I trust that some mathematical type in the company really did sit down and do some equations and get that result. My method gives a quick and dirty maximum value. More difficult is subtracting for combinations that don’t make sense (like only mayonnaise). I played around with my values a bit to see if I could find a combination that returned the same result, but no luck. I’d love to know what the real equation was to see if my method was close.

Please click here for part II of this post for further clarification and corrections.

Homage to my Calculator

I thought I’d take a little detour from strictly mathematical topics, and talk about my favorite tool for math: the TI-82 graphing calculator. I’ve had this tool for over 12 years now, and its pretty amazing as a stand-alone, portable computing device. It all started in high school when I was required to get one for my Algebra class. I engraved my name on it, and one day in Junior year, a friend stuck a dinosaur sticker on the case. The sticker’s still there.

ti82

The calculator was my sidekick during the high school years when I started being able to understand math. I can be a visual learner sometimes. With a function plotter I could see the equations I was working with, and how they intersected and curved and rose and fell.

Also I really got into programming in Ti-BASIC, which ultimately led me to a Computer Engineering major in college. I mostly wrote simple games, or little formula evaluators. The highlight of my “career” was in an Algebra II class when I wrote a program to find the angles in a triangle. I shared the program with a few kids, one of whom announced to the teacher how good it was. The teacher thought it was great, and in a few minutes I had a stack of calculators on my desk from everyone who wanted a copy.

Texas Instruments has a great line of calculators, and the 82 is towards the lower end, but even after all this time I’m still surprised at all the use I can get out of it. It’s so handy to have a device that does function plotting in Rectangular and Polar fields, has a spreadsheet with a data plotter, and is easily programmable. Not to mention the matrix, probability, and calculus features. I don’t think there’s any complicated piece of technology that I know my way around better – yet there are still features I haven’t taken advantage of yet.

Today, I keep one at home and another at my desk at work. I can whip up a simple BASIC program to handle price-margins on products or sales discounts. I can keep track of trends and data in the Stat tables, and then fit the data to curves and plot equations.

The features of this machine are reasonably comparable to the early Mac computers:

Apple IIc+ TI-82
Speed 4MHz 6MHz
memory 128KB 28KB

Not bad for the palm of your hand.

After all this time, I realize that my sidekick is starting to get old and outdated. I plan on retiring the guy when the time comes. I considered getting a netbook, but for the price I’d rather have a full featured laptop and I’d lose the portability. Other than that, I have an old PocketPC that’s actually 116MHz. I’d love a function plotting utility for it, but haven’t found one yet (any suggestions?). I think the iPhone might be where I head next. I’m sure I could get some simple coding platforms that would run on it. My inner geek is rather aroused at the prospect of having Mathematica in my pocket.

Raising Polar Coordinates in a Rectangular world

For this post I thought I’d write about using polar equations and coordinates. A polar grid is more useful for certain applications such as Trigonometry. Alternatively Rectangular, or Cartesian graphing is the “standard” typically used for algebra, and most any kind of graph I can think of.

This last Summer I took up amateur astronomy as a hobby. I wanted a way of quantifying a star’s location at a given time, and figured I could do so with two numbers; the “aroundness” and the “upness” of the star. Imagine a star just over the horizon. Using a magnetic-compass I can figure out its bearing, say due east at 90° ; an “aroundness value” of 90. And imagine I were to measure the star’s angle “up” from the horizon. The horizon is defined as 0°, and a star directly overhead would be 90°. So a star appearing half way up might have an “upness” value of 45°.

Real astronomers are more likely to use the words “Bearing” instead of “aroundness”, and “Ascension” rather than “upness”.

Now, before I had my star data, I had the idea of making a computer program to help me organize it all. I thought it would be cool to have a way to visualize the points. My first thought was that I could take my bearing/ascension data and just display it directly on the rectangular plain of my 2d graphics environment. It’s only for my own use, so it doesn’t matter much if things are hopelessly distorted. Consider 3 stars in the sky, in a triangle directly overhead. They could all have the ascension value of 85°, and bearings of 120°, 240°, and 360°. They’d be close to each other in a ring in the sky, but translated directly to rectangular they’d be a in a straight line, appearing each third of the way along the graph. There should be a better way.

Converting Polar Coordinates for Display on a Rectangular Grid

On a rectangular grid, points are defined with an X value and a Y value, expressed as an ordered pair (X,Y). On a polar grid, points are expressed with a radius value and an angle value, or (r, θ). As it turns out my aroudness and upness measurements correspond exactly to concept of angle and radius for a point in polar. To convert the points for display, Trig functions are used.

Refer to this diagram:

Unit circle

I believe from this diagram alone (and a century or two in seclusion) a clever person could derive 95% of all Trigonometry.

For the point “P”, we can get its location in terms of X and Y via Sine and Cosine. Sin(angle) gives the Y value, and Cos(angle) gives the X value.

One extra step though, is that the “upness” or “radius” value hasn’t been used yet. The X and Y values just obtained are the values on the unit circle of the diagram, where the hypotenuse is equal to one. Multiply both the X and Y values times the Radius (bearing) value in order to put the point the right distance from the center of the screen. That’s it.

Isn’t that awesome?

So here are some equations:

Y = sin(θ) x radius
X = cos(θ) x radius

Applications

It should be pretty evident that if you want to move a polar point over to the right a bit you can convert it into rect. and just increment or decrement either the X or Y value. ie, X + 3 will put the point 3 places to the right. The really cool thing though is that the points can be rotated in a circle by keeping them in polar and incrementing the angle value. Even better, if you’re working with a set of points, you can “zoom in” on them by incrementing the radius value. Just keep increasing it and the points will get further and further from the center until they go off the regions of your graph.

I plan on doing a second post on this topic. where I’ll go over other types of transformations that can be done with a point using rectangular and polar grids.

Meditations on the Beer-a-mid

Being a discourse on the properties, and methods of construction, of the so called Beer-a-mid.

358px-beeramid

This structure should have 120 cans.

The “Beer-a-mid”, or Beeramid, or perhaps even Byramid, is a slang term for stacks of beer cans in a pyramid shape. Of course it doesn’t have to be beer cans. Really any kind of beverage-can works. (Or for that matter, any unit or particle). I had the idea of working out some kind of equation to tell how many cans would be in a pyramid of a given height.

First off, there are different types of beeramids. By definition, I suppose the simplest would have to be a zero-dimensional structure, consisting of one can. The equation describing this is: “number of cans = 1 can”. Let me know if that’s too complicated. Then there’s a sort of “linear”, 1-dimensional pyramid, which is simply a line of cans. Things actually become interesting though when the subject is a 2-dimensional pyramid. What’s the equation for that?

Going from top to bottom, the first layer will have one can, the second layer will have two cans. The third layer will have three and so on. Still not all that difficult. The total number of cans in a pyramid is the sum of the number of cans in each row. So a 4 layer pyramid has (1 + 2 + 3 + 4) cans, or 10 cans. I started thinking about it, and found that this is pretty simple to express using Sigma notation:

2d -pyramidH = height.

So, 2d Pyramids, done. How about a 3d pyramid? Here there are some choices. In particular, the base of the pyramid may be shaped in different ways. The Giza pyramids have a square base. But there’s also the tetrahedron, a pyramid with a triangle base. Let’s consider that one first.

From top down, the first layer has one can. The second layer has three cans. The third layer has 6 cans. Less straightforward this time. However, each layer on the 3d pyramid is just a 2dpyramid on its side. Further, the “Height” of this 2d pyramid is equal it’s place on the 3d pyramid. So, the 3rd layer of the 3d pyramid is a 2d pyramid of height 3. The 8th layer of a 3d pyramid is a 2d Pyramid of height 8. Since I already have an equation for 2d pyramids, I can add up progressively higher layers using a nested sigma formula:

3d - tri base The only input variable is height “H”. Note the 2d pyramid equation tucked in there.

I used a regression utility to work the results of this into  polynomial form: number of cans = 3s- tri polynomial. I don’t understand how this works, or why it works, but it’s pretty handy for a quick calculation.

With that down, what about 3d Pyramids with square bases? Turns out that each layer of the pyramid is a square, with an area equal to it’s layer number squared. So, the 2nd layer has 4 cans (22 = 4), and the third layer has 9 cans (32 = 9). The equation for that pyramid can be gotten by making a small change to the triangle base equation. The inner sigma is gotten rid of, and replaced with a squaring operation:

3d - squ base

So those are my equations. Kind of cool. The nested loops translate pretty easily into programming languages so I already have a program on the ti-82 that will do all this for me. That’s probably one of the nerdiest things I’ve ever done. Ah well.

And what comes next? I wanted to work out something more general. I’ve found that bases of n-sided shapes don’t always come together in real life. There’s something lurking there, like determining which 2d shapes with integer sides have integer areas. Something like that anyway. And what about can overlap!? The above equations all have a can resting on top of two or more cans in the layer below it.  But a can could just as easily be placed directly on top of a single can below it.  The cans represent perfect, abstract points, only they’re real things. The variations are crazy.  And I can’t help but think of the Platonic Solids. Ahh well. Perhaps I’ll work something more general out, and  cover that at a later date.