Showing posts with label Binomial Distribution. Show all posts
Showing posts with label Binomial Distribution. Show all posts

Thursday, November 07, 2024

I Hate To Lose

 


Down to Lytes Cary Manor (National Trust), about half an hour’s drive from home. A walk through the grounds, damp and gooey clay, the odd mud pool on the path down to the river. Overcast skies. No sign of that unshielded fusion reactor, so dangerously close at 160 million kilometres.

“Do you think we'll see anyone else?” Clare asked, (the car park had been almost full).

“No,” I said confidently, thinking that the wise visitor would have stuck to the house and immediate gardens, and then made a fast retreat to the tea room.

I got the impression that she'd said, or thought, that we would see around six people.

Halfway round our circuit, just after we had admired the bridge, a man passed us. We exchanged greetings. It was 12.15 pm.

“I always think that we should say good afternoon only after lunch,” she said. (We had said good morning).

“That’s my view too,” I said, though my mind was more on the fact we had, now, met somebody.

“I think there is a better way to think about this,” I said, “something a little less binary. When I said we wouldn’t see anyone else, I really meant we should see zero-ish people. I had in mind a distribution. One is very close to zero, so on balance I'm still right about this.”

She looked at me in disbelief.

Soon afterward, in the distance, we spotted two other walkers. That made a total of three, as we headed back towards the tea room for our hot chocolates.

“OK,” I said, “We’re really talking about two binomial distributions here. Divide our walk into, say, n = 12 equal time slots and assume the probability of encountering another walker in each of these time slots is p. We’re really disagreeing about the value of p.

“In my view p was about one twelfth, which means I should have perhaps expected on average to meet just one person. You said we’d meet six people so for you p is one half - twelve times one half is six.”

They do look like rabbits. The tea room is in the manor house, top left

It was hard to see if she was following the argument as her attention seemed fixed on the weeds growing in the adjacent field, which looked like a crowd of rabbits.

"Now, our standard deviations are different: for me, using the formula sqrt(npq) n = 12; p = one twelfth;  it's just under one - while for you with p = a half, it’s around 1.73, the square root of three.

"So seeing three people for me is two standard deviations out - while for you it’s only 1.73 sds.

“Although technically this aligns more to you, I think morally we’d have to call it a draw.”

She turned to me and said, “Even when you lose you hate to lose.”

Wednesday, February 10, 2016

"My simulated sister is smarter than me"

Apologies that this is a bit techie - and it won't make sense without reading the previous post.

Yesterday I did some simple stats to show that my sister is most likely 8 IQ points smarter than me (to be fair and by symmetry, the converse could also be true).

Health warnings:
  1. expected value only when averaged over large numbers of copies of my sister and myself;
  2. equally true for my brother and myself - the stats are gender-blind.
How far is one sibling likely to be from the parental midpoint average?

Intuitively, you wouldn't expect every sibling to be exactly the average (they're not clones) but over a large family the pluses and minus would sort of average out to the mid-parental mean. But what about if we're just considering the deviation from average, without caring about the sign?

We seem to have a choice: halve the expected difference between two siblings, or find the average (absolute) deviation from the mean. As we saw yesterday, these give different answers.

I therefore decided to run an Excel simulation using the built-in RAND() function. Here's the four coin-set (taking values from 0 to 4):
IF(RAND()>0.5,1,0) + IF(RAND()>0.5,1,0) + IF(RAND()>0.5,1,0) + IF(RAND()>0.5,1,0)
and here is the last part of the spreadsheet model showing 100 tosses of two 4-coin sets (random variables X and Y) showing the number of heads.

If you like, you can consider this a simple four gene model for intelligence, with each gene presenting as two alleles, each of which code up or down for IQ by 7.5 points.



I ran each 100 toss simulation ten times and noted the results in the table on the right.
  • The heading "Mean-IQ" refers to ten runs of the IQ (7.5) value in the "abs(X-Y)" column on the left, showing the mean difference in IQ between the two siblings; 

  • the heading "Dec-IQ" refers to ten runs of the IQ (7.5) value in the "abs(X-2)" column on the left, showing the average deviation (+ and -) of a single sibling's IQ from the parental-midpoint mean.
From yesterday's post the computed values are respectively 8.2 and 5.625.

If we go back to selecting embryos for implantation, which is the right statistic to use to measure our likely IQ gain over the biological default of just taking what comes?

The leftmost statistic, 5.625 IQ points above the mean, would be sort of accurate if we were conceptually considering two embryos, one randomly varying and the other always exactly on the parental midpoint mean. But it wouldn't work, not least because the random embryo might well be below the mean but we're counting all variation as positive. So it's not realistic.

The statistic we get by halving the expected inter-sibling gap of 8.2 IQ points is better as we always select the smarter of the two embryos. However, since both X and Y are varying freely on the range {0,1,2,3,4} it's a bit difficult to correlate the abs(X-Y)/2 gap with the range-midpoint (mean) of 2. At this point we handwave and mutter about symmetry.

And what do you do when the presented embryos are all below the expected average?*

---

* Which with two embryos will occur 25% of the time. I feel like spending some more money and genotyping a few more ...


Tuesday, February 09, 2016

"My sister is smarter than me"

Well, maybe.

Your brother or sister could be exactly the same intelligence as yourself, but that's not the way to bet. Yesterday I wrote about the Carl Shulman and Nick Bostrom paper, "Embryo Selection for Cognitive Enhancement: Curiosity or Game-changer?". They said that the average distance in intelligence between two siblings was 8.4 IQ points.

Hmm.

When I saw that figure I was mightily impressed by their mathematical skills. After much thinking I decided that what they had done was this. They had taken the Gaussian distribution for the IQ of offspring with
mean = parental midpoint IQ; standard deviation = 7.5,
and considered two random variables from this distribution. Let's call them, with a bow to genetics, X for daughter and Y for son.

They had then computed the expected value of abs(X-Y). The absolute value is important here: the expected value of the mere difference (X-Y) is zero, as one sibling taken at random will on average be no brighter or dimmer than the other.



I hate these messy integrals incorporating the bivariate Gaussian distribution with weird boundaries! And apparently so do Carl and Nick: they got their answers by simulation.

But there is another way where we can still be analytic. The answer is in the power of four.

Take four coins and toss them. Count the number of heads - there are five possible outcomes: 0. 1. 2, 3, 4. The respective probabilities are 1/16, 4/16, 6/16, 4/16. 1/16.

The mean number of heads is 2 and the standard deviation of the number of heads is 1. How convenient.
[SD = √(npq) = √(4 * 0.5 * 0.5) = 1].

When you draw the histogram you get something like the above, which is not a million miles away from looking rather ... normal.

If we wanted to make this about sibling intelligence, map the number of heads into IQ scores:
2 heads = IQ 100
3 heads = IQ 107.5
4 heads = IQ 115.
Warning, IQ can go down as well as up.

Now imagine if we had one set of four coins to our left "the daugher IQ" and another set to our right "the son IQ". Throw simultaneously and count the number of left heads and right heads.

The difference (abs, remember, absolute value) in the number of heads is the IQ difference - each head counts as 7.5 IQ points. What do we get?

There's a spreadsheet for that.

Each cell in the bottom table is the product of the corresponding cells in the top two

Now these three tables are either self-evident after a little consideration, or too long to explain. I simply draw your attention to the figure in the bottom right in bold. The sum of all the entries in the third table = 1.09375.

This is the expected value of the difference in number of heads between left and right, "daughter" and "son" coin sets.

To change it into an IQ figure we multiply by 7.5 giving 8.2 ("my sister is 8 IQ points smarter than me!" ... or maybe conversely ...).

If we want the gap between each sibling's expected IQ from the mean expected IQ (over all possible siblings) we halve it to get 4.1. Think about it - don't you just love stats *.

This compares to Carl's and Nick's number of 4.2 based on ten million simulations (table below). Not a bad approximation to the normal distribution and you can see what's going on.

---

Admittedly, extending to the case of 'best of ten siblings' seems a few coin sets too far.



---

* and then I worry about this ...


which equates to 0.75 * 7.5 = 5.625 IQ points.

Time for a simulation ...

Friday, November 07, 2014

Estimating IQ from genotype

This post is a simple back of the envelope calculation based on Davide Piffer's paper as discussed in my earlier post.

First a quick reminder about opinion polls and sampling.

Opinion Polls

We assume a large population of interest and we sample n individuals (often 1,000) with a yes-no question. Something like "Are you going to vote for the Labour Party in the forthcoming election?" We want to know how likely it is that the population as a whole votes in the same proportions as found in our survey. Suppose p is the fraction of the sample-population who tell us they will vote yes (example: 0.32).

This is just the same as throwing a biased coin (Heads with probability 0.32) a thousand times and seeing how many Heads we actually get. Clearly on average we'll get 320 Heads [the mean of our sample is np]. Of more interest, however, is the standard deviation of the mean if we took sample after sample (or coin-throwing exercise after coin-throwing exercise). We would like to know the upper and lower bounds of 'yes' respondents we would get in, say, 95% of the samples we took, corresponding to +/- 1.96 standard deviations. We can be pretty confident that those bounds would play out in real life (nineteen times out of 20).

The standard deviation of a binomial distribution, which is what we have here, is √(npq) where n is the size of the sample (example, 1,000), p is the probability of the 'yes' outcome (example: 0.32) and q is the probability of the 'no' outcome (0.68 = 1-p).

The 95% confidence interval around the mean np is +/- 1.96 standard deviations - which we approximate here to 2. We also approximate p and q to 0.5 as this is the largest value of √(pq).

Plugging the numbers in, we get the 95% confidence interval as: 2 times √(0.5 x 0.5 x n) = √n.

In our running example with 1,000 people sampled (√1000 equals around 32), this tells us that the interval 320 +/- 32 will  contain the number of 'yes' answers we'll get 95% of the time. We sometime prefer to have the results as a proportion, usually written as a percentage, in which case we divide everything by n.

The mean number of 'yes' voters here is 320/1,000 = np/n = p (0.32 or 32%).

The 95% confidence interval here is 32/1,000 = n/n = 1/n  (usually described as +/- 3%).

Note that if we had sampled just 100 voters, we would have a 95% confidence interval of +/- 1/√100 = +/- 10%. We're already losing quite a bit of predictive power.

Asking just 10 people, the 95% confidence interval is 1/√10 = 0.32 = approx. 30%. So the three people who said they'd vote 'yes' .. in multiple surveys that number could dip as low as zero and as high as six. Pretty much worthless in forecasting the election.

---

To apply this to IQ I'm going to use the data in Davide Piffer's paper, as discussed in my earlier post - to which you may need to refer.

Looking at my own results I had 16 alleles to play with, of which 7 were 'good for intelligence'. So this is an opinion poll where I was able to survey only 16 people. Duh!

My computed allele frequency was 44% against a European average of 35.5% so I'm 8.5 percentage points up from the average.

Looking at the Chinese/Japanese figures we see an allele frequency score of 39.1% (a difference of 3.6% from the European mean) which corresponds to an IQ difference of 5 IQ points from Europeans. I'm going to assume a linear relation - an additive model.

To convert a difference of mean allele frequency to IQ difference we multiple by 5/3.6 = 1.4. So the estimate of my IQ is 8.5 * 1.4 = 12 points above the European average of 100. In my incorrigible vanity I'd like to believe that 112 is rather on the low side! What is the 95% confidence interval for this calculation?

Since n = 16, and following the path described above, the 95% confidence interval is +/- 1/√16 = 25%.

That's the allele frequency limits so my true allele frequency (of those hundreds or thousands of 'good alleles driving IQ') is probably in the range 44% +/- 25% or [19%, 69%]. To change these limits into IQ scores multiply the confidence interval of +/-25%  by 1.4 giving +/- 35 IQ points

We may be 95% confident that my IQ is in the range [77, 147].

So I guess we can be 95% confident that I'm neither extremely educationally subnormal nor Albert Einstein!

The take-home message is that we need hundreds of alleles to give us a big enough sample to get the error bounds down. The concordance of twins brought up together for IQ is around 0.86 so non-genetic factors will still prevent us getting all the way.

BTW we're just a few years from getting to that 'hundreds of IQ-affecting alleles' point, so although this is a fun exercise, reality will be along soon enough.

Saturday, August 20, 2011

Ship of Fools?

Part 1

Did you read the SF story where a future population is oppressed by ... well, an evil oppressor, and the time-travelling hero hands the Resistance the ultimate secret weapon, the U.S. Constitution? It may be one of the classic SF clichés but it speaks to a bedrock conviction of American culture: Democracy is Wonderful.

In truth it would be wonderful if the average voter wasn’t so incredibly ignorant:
  • Half of Americans don’t know that each state has two senators
  • Less than 40% know their representatives’ party affiliations
  • 45 percent of adult apparently believe that Karl Marx’s communist principle “from each according to his abilities, to each according to his needs” is actually part of the U.S. Constitution.

How on earth do we get sensible representatives, policies and decisions from this ocean of baleful ignorance? We know that most voters don’t understand micro- or macroeconomics and fail to appreciate the subtleties of foreign policy. Given the likely effects of their one vote, it’s even been argued that it’s rational for them not to invest much time in preparing for an act of so little practical consequence.

Thankfully, it might not be quite as bad as it appears.

An example: suppose the 160 million registered voters in North America have to vote for candidates Ms Right or Mr Wrong. If we have 160 million totally ignorant citizens, then Ms R and Mr W are each going to get around 80 million each and it’s a toss-up as to who will win. We can model this outcome by simply imagining that each voter has a coin and just flips it: Heads for Ms R and Tails for Mr W.

If we imagine running that vote over and over again, then 99% of the time the total number of votes cast for each candidate would each be within 17,000 of the magic balancing 80 million votes. That is, when we counted the number of votes for Ms Right (or Mr Wrong) then with 99% probability the number of votes she or he would receive would lie between 80 million minus 17,000 and 80 million + 17,000. This is the magic of statistics* and also a possible answer to our dilemma.

Suppose that there are 20,000 well-educated and politically-engaged people in the electorate (just 0.0125% of the 160 million voting population).

Suppose that Ms Right’s political supporters successfully persuade these 20,000 to vote the Right way. A result! Democracy has successfully delivered the goods, despite an electorate which scarcely deserves such good fortune. So Democracy works even with overwhelming public apathy and ignorance if there is tiny crowd of political sophisticates who take the trouble to research the issues and vote the right way.

But be cautious: is this a model which describes the actual political world we see around us? Sadly not: in point of fact the true situation is even worse than widespread and systemic ignorance. The population-at-large in fact exhibits perverse and self-defeating bias: the people systematically vote for candidates and policies which act against their own self-interests.

How and why this happens will be discussed in part 2 of this article below.

---

* Where did that come from?

We have a population n of 160 million. Each individual has a probability of p=0.5 to vote for Ms Right and an equal probability q=0.5 to vote for Mr Wrong. This is a standard binomial distribution with standard deviation √(npq) = 0.5 * √(160 million) = 6,325. Plus or minus 99% corresponds to +/- 2.57 standard deviations = +/- 16,250 which we round up to 17,000.

The idea that the average voter is ignorant of politics is based on the idea that the personal cost of staying current with political issues is quite high, while the chances of any one person’s vote making a difference to outcomes is miniscule. It is therefore rational to not bother and stay ignorant (the theory is called Rational Ignorance).

Part 2

In Part 1 we encountered the theory of Rational Ignorance, the idea that your one vote makes such a small difference that it isn’t worth your time and effort to stay current with political issues. We showed that if the overwhelming mass of people voted at random, democracy would still work if a small elite were sufficiently educated and motivated to study the issues and vote the right way.

But we all know that it just isn’t so. People do not vote randomly: they are strongly opinionated and actively engaged with the issues – despite not studying them. In ‘The Myth of the Rational Voter’, Bryan Caplan flags three areas where voters passionately rally to counterproductive policies which actively harm their own self-interests.

1. Anti-Market Bias

Despite the fact that capitalism is the most successful form of economic organization ever seen on the planet, most people are profoundly suspicious of it. Adam Smith’s famous observation about the trade of the businessman: ‘By pursuing his own interest he frequently promotes that of society more effectually than when he really intends to promote it. I have never known much good done by those who affected to trade for the public good,’ has never been believed by the general public.

The public’s instincts are to go with regulation, price subsidies and Government provision of essential goods and services, believing that market mechanisms are driven by private greed, keep prices sky-high, lead to shoddy output and don’t give a damn about customers (i.e. themselves).

Given a competitive market, the truth of the matter is almost completely the reverse, as people would realize if they compared their grocery stores to almost any Government department they deal with. But people don’t trust markets.

2. Anti-Foreign Bias

Left to themselves, many people would choose to erect impenetrable tariff walls at our borders and keep all foreign imports out, stopping those perfidious foreigners stealing our jobs.

Protectionism misses a revelation about the gains from trade which has been known for 250 years. In a simple example suppose an American worker can make 10 cars or 5 bushels of wheat in a given time, while a Mexican can make 1 car or two bushels of wheat in the same time. Mexico is a poorer country, and not as productive as America. Obviously there is no point trading with them.

Take one American auto worker and one American farmer. Together they make 10 cars and 5 bushels of wheat.

Take three Mexican auto workers and one Mexican farmer. Together they make 3 cars and 2 bushels of wheat.

Total: 13 cars and 7 bushels of wheat.

Now let them specialize and trade. The 2 Americans make cars, 20 of them while the four Mexicans make wheat, 8 bushels of it.

Total: 20 cars and 8 bushels of wheat. So there is a point in trading with Mexico.

The Law of Comparative Advantage encourages countries to specialize in what they’re good at and trade with others doing the same. The result is prosperity, even if your trade partners damage their own economies through protectionism. Alternatively, you could be North Korea.

Does the general public buy this argument? Not at all. They listen to steel workers, about to lose their jobs because steel-making in America is uncompetitive, and they rally to their defense. Keep cheap steel imports out! In doing so, they make all other American goods which incorporate steel more expensive for themselves and less competitive on the world market. But, hey, we saved the steel workers!

Or did we?

3. Make-Work Bias

The third area where public opinion gets it wrong is layoffs. Capitalism works, and we all get richer, by continually churning obsolete technologies in favor of newer, more productive ones. In the short-term workers in these declining industries lose their jobs; in the longer term they tend to get new and higher-paid jobs. Still, we hear more about those unfortunates who don’t.

In 1800 it took 95 out of every 100 Americans to work the land to feed the country. In 1900 it took 40, while today it takes just 3 in a 100. That was a lot of farmers let go. Do you see them hanging around the poor parts of town begging for handouts? There was a lot of pain in the wrenching transitions which saw an agricultural economy transition to a modern technological one. At every step of the way, compassionate people cried ‘stop!’ – fighting to freeze the status quo and avoid redundancies.

Yet who today would want to go back?

---

There is a common factor to these three biases. Humans are social creatures: we have empathy with others in our social group. Our emotions reward efforts for the common good and prompt us to help those suffering misfortune and not stand idly by: that’s how we evolved.

Capitalism in its most effective, competitive mode deliberately pits people against people and disrupts bedded-down patterns of life in favor of disruptive change. Locally it can damage lives even as it globally increases prosperity and opportunity. Our emotions don’t ‘get’ the way complex, holistic capitalism works and in our guts we don’t really approve. And when it comes to elections (where the act of voting is very distant from any personal economic consequences) we vote our feelings.

Economist Bryan Caplan calls this ‘Rational Irrationality’ and it explains a lot about modern politics, even the forced-hypocrisy of otherwise honest politicians who are forced to advance correct policies by stealth in the face of heated populist opposition.

---

Further Reading: The Myth of the Rational Voter, Bryan Caplan (2007), Princeton University Press.

---

Opinion Polls

As a bonus here’s a quick review of how opinion polls work. The pollsters ask, say, 1,000 people if they intend to vote for Ms R. Let’s suppose she’s languishing a little and the poll gives her 33% support. The standard deviation of this sample of voters is, as before, √(npq). We could use p=0.3, q=0.7 but it’s easier and more conservative just to stick with p=q=0.5 so that √(pq) = 0.5, its maximum value.

So one standard deviation σ is 0.5 * √(1,000) = 0.5 * 31.6 = 15.8.

The 95% confidence interval around 33% is +/- 1.96 standard deviations, 1.96 * 15.8 = 31. The pollsters express this as a percentage, 31/1,000 = 3.1% and they tell you that Ms R is currently polling at 33% with a margin of error of plus or minus 3.1%.

They’ll be right nineteen times out of twenty.

---

[Note: this was originally going to be a couple of articles for sciencefiction.com but I think you'll agree that they're better here.]