Tuesday, December 9, 2014

Quis custodiet ipsos custodes?

There have been a lot of stories recently about police abuses of power. Undoubtedly, these stories are not representative. The vast majority of police-civilian interactions do not end with death or violence. Most cops are good cops.

But that doesn't matter, when the whole system is bad.

When a police officer can kill someone with no provocation, on camera, and get away with it, it doesn't matter that there are more good cops than bad cops, because the good cops are part of a system that does nothing to stop the bad cops.

And it's not just the major abuses like that. I've heard (not being a cop, I don't know for sure) that police officers will usually not give other officers tickets for traffic violations. Of course, that's a very minor thing, but it's indicative of the problem. Police officers are held to a lower standard of conduct than civilians.

"With great power comes great responsibility." Unless you're a cop.

Monday, November 24, 2014

Binary Addition

Before, I talked about how to use binary to represent a number using only two values. But what if you want to actually do something with those numbers? How do you add numbers using Boolean operations?

Well, let's start with a simple case: adding two one-bit numbers. We'll call them X and Y, and since they each only have one binary digit they can only have the values 0 or 1. So here are the cases we need to account for: 0+0=0, 0+1=1, 1+0=1, 1+1=10.

Notice the answer for that final case has two digits. A Boolean function can only return one value, so how can get that? By having two functions, one for each digit.

So, the function for the rightmost digit has to satisfy this truth table:
XYZ0
000
011
101
110
What Boolean operation does that look like? XOR.

The function for the next digit will have to satisfy this truth table:
XYZ1
000
010
100
111
That's the same as the AND operation.

I'm using the subscripts here to indicate which digit in the overall number. So our two bit answer Z has the individual bits Z1Z0, where Z1 = X AND Y, and Z0 = X XOR Y;

So, that's how you can add two one-bit numbers. But what if you want to add bigger numbers? Well, the way you add the second bits together is pretty much the same as the first bits, with one major difference: You need to account for the bit that got carried from the sum of the first bits. If that carry bit was 0, then the result of the next bit will be same as the first. But if it's one, then the result is increased by one. So, 0+0+1=1, 0+1+1=10, 1+0+1=10, 1+1+1=11.
So, now we have these two truth tables:
X1Y1CZ1
0000
0101
1001
1100
0011
0110
1010
1111
X1Y1CZ2
0000
0100
1000
1101
0010
0111
1011
1111
So, Z1 = X1 XOR Y1 XOR C and Z2 = (X1 AND Y1) OR (X1 AND C) OR (Y1 AND C). C, the carry bit, comes from the second bit of the result of the sum of the first two bits, that is C = X0 AND Y0.

Each subsequent bit works just like the second, with the second bit of the previous result being carried over. Generally, and Zn = (Xn AND Yn) OR (Xn AND Cn-1) OR (Yn AND Cn-1), and Cn = Xn XOR Yn XOR Cn-1.

Here's another challenge for you: How do you do subtraction in a similar manner?

Sunday, November 2, 2014

Utilitarianism, Capitalism and Utility Monsters

A common criticism of utilitarianism is the idea of a utility monster. Suppose you had some extra ice cream, and you decided to give it away, so as to maximize utility. You only have enough to give to one person, and there are only two people available for you to give it to: Alice and Bob. If Alice likes ice cream, and Bob does not, then obviously you should give your ice cream to Alice. Giving it to Bob wouldn't increase his utility. What if Bob did like ice cream, but Alice like it more? Then, you should still give your ice cream to Alice, because that maximizes utility. What if Alice likes everything more than Bob does? Then you should take Bob's stuff and give it to Alice, because that will maximize total utility.

On a separate note, utilitarianism and capitalism go really well together.

Utilitarianism says you should try to maximize utility. When you buy something, you do so because it will make you happier, or help you achieve your goals, in other words, increase your utility. And you're trying to get best deal, you don't want to pay any more money than you have to. So money works as a not too bad proxy for utility. Which is good, because it's hard enough to get people to agree what utility is, let alone measure it in any meaningful way.

Before, I talked about the spherical cows of economics, that is, the conditions under which the free market is maximally efficient. One of those spherical cows in economic equality. A rich person can outbid a poor person, not because they value what they're buying more, but simply because they have more money to spend.

But if money is a proxy for utility, then maybe the rich person really does value it more. Maybe the rich person, in fact, has a greater capacity to value things at all. In other words, maybe rich people are utility monsters.

Sunday, October 26, 2014

Binary

Before, I talked about some of the things computers can do using only two values. But what about numbers? How can computers do arithmetic with only 0s and 1s? The answer to that question is "binary". If you already know what binary is, this post will just be a refresher.

Before I begin explaining binary, let's go over how the number system we normally use, that is, base ten, works. How do you count? How do you determine what the next number is?

Well, you start with 0, which is followed by 1, then 2, 3, 4, 5, 6, 7, 8 and 9. You pretty much just have to memorize that sequence. But what comes after 9? 10. That's interesting. It's not just another symbol, it's two symbols, and two symbols we've seen before.

Let's continue. After 10 comes 11, 12, 13, 14, 15, 16, 17, 18, 19. Hey, that looks familiar. Those numbers are the same as the first ten, except with a 1 on the front of each of them. And what comes after 19? 20. And the same sequence as before will repeat again, except with a 2 on the front, instead of a 1. And after that comes 30. And then, the same sequence will repeat again, but with a 3 this time.

Hey, wait a minute. The number on the front is itself going through that sequence too, it's just waiting for the second number to cycle through before going to the next step. So, after 30 comes 40, then 50, 60, 70, 80, 90.

So, what comes after 99? 100. Another symbol got added, just like when 9 turned into 10. And that's all there is to counting. You can continue following these same steps forever, and you'll never run out of numbers. Let's write out these steps a little more explicitly.

First, you have to memorize a sequence of symbols: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9].
Then, to get the next number after the current one, replace the rightmost digit with the next symbol in the sequence. If it's already at the last symbol, then set it back to the beginning of the sequence, and repeat the last step for the next digit to the left. If there is no digit to the left, it's implied to be 0, so 1 is added.

But notice, there's nothing special about that sequence of symbols. You could follow the same rules using any sequence of symbols. For example, you could use this sequence: [a, b, c, d]. Then you would count a, b, c, d, ba, bb, bc, bd, ca, cb, cc, cd, da, db, dc, dd, baa...

Or you could use this sequence: [0, 1]. Then you would count 0, 1, 10, 11, 100, 101, 110, 111, 1000...

And that's what binary is. Counting, with only 0 and 1.

What if you want to convert from one base to another? If you have a number in base ten, and want to know how it's written in binary, or the other way around?

Well, one way to do that is just to count. Numbers are the same, regardless of how they're written, so if you count up the same number, it will be the same in every base.

Base ten0123456789101112
Binary01101110010111011110001001101010111100

But that's going to be cumbersome for large numbers. Is there an easier way?

Yes, there is. Notice, that in any base, the number 10 represents the number of symbols in the sequence you're using. There are ten symbols in [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], and 10 represents ten. There are two symbols in [0, 1] and 10 in binary represents two. That's not a coincidence, and I trust you're smart enough to figure out why that is.

A consequence of that is that the number 100 in any base is going to be equal to the number of symbols times itself. 10*10 = 100. And this gives you the concept of "place". You know, the digit furthest to the right is the ones place, the next digit to the left is the tens place, the next digit to the left is the hundreds place and so on.

That concept applies to any base. The rightmost digit will always be the ones place. The digit there stands for itself. The next digit to the left will be multiplied by the base. Each further digit to the left will be multiplied by the base again. So in binary, you get the ones place, the twos place, the fours place, the eights place, and so on.

So, for example, let's try that on this binary number: 101011
The rightmost digit is 1, and it's in the ones place, so it's equal to 1.
The next digit is 1, and it's in the twos place so it's 1*2 = 2.
The next digit is in the fours place, but it's 0, and 0 times anything is still 0, so it's 0.
The next digit is 1, and it's in the eights place, so it's 8.
The next digit is in the sixteens place, but it's 0.
The next digit is in the thirty-twos place, so it's 32.
So, the value is 32 + 8 + 2 + 1 = 43.

What about the other way? Converting a number from base ten to binary? That's a little bit harder to describe, so I'll explain with an example. Say we're converting the number 57. What we need to do is divide that number by 2 and find the remainder. 57 / 2 = 28 remainder 1. The remainder is the rightmost digit of our binary number.
To continue we need to divide 28. 28 / 2 = 14 remainder 0. The next digit in our binary number is 0.
14 / 2 = 7 remainder 0.
7 / 2 = 3 remainder 1.
3 / 2 = 1 remainder 1.
1 / 2 = 0 remainder 1.
So our binary number is 111001.

In other words, in each step you need to divide your number by two. The remainder is the next digit of the binary number, starting from the right and going left. You're done when the result of the division is zero.

And that is how you can represent numbers, using only 0 and 1.

Monday, August 18, 2014

Can't Touch This

A surprisingly common notion that comes up in science popularization is that nothing ever touches. This comes up things from youtube videos to the remake of Cosmos. As far as the scientific facts go, they're right. When you touch something, say when you pick up a ball, the electrons in the atoms of your fingers repel the electrons in the atoms of the ball, so the atoms in your fingers never come near the atoms in the ball. Near, that is, relative to the size of an atom.

But I wouldn't say that means nothing ever touches. Rather, it's a microscopic description of the macroscopic phenomenon of touch.

As an analogy, consider temperature. You can feel temperature as things feel hot or cold. You can measure temperature with thermometers. You can come up with laws that describe how heat flows from hot things to cold things. But on a microscopic scale, temperature is just speed. When atoms and molecules vibrate faster, they're hot. When they vibrate slower, they're cold.

But that doesn't mean that temperature doesn't exist. Rather, that's what temperature is. Thermometers still work, and the laws of thermodynamics are still accurate. They just refer to an emergent property of a complex system, rather than fundamental property.

I would argue the same applies to touch. Electrons repelling each other is what touching is.

Admittedly, this is entirely an argument over semantics. It's just about the definition of the word "touch", rather than any actual facts. But I think this definition is better and more useful. Because if nothing ever touches (except maybe where fusion occurs, like in the heart of a star), then the word "touch" never makes any useful distinctions, which is the purpose of a word.

Thursday, August 7, 2014

The Monty Hall Problem

Suppose you're on a game show, and you're presented with three closed doors. Behind one of the doors is a car, and behind the other two are goats. You pick a door, let's say door 1. Before opening that door, the host, Monty Hall, opens a different door, let's say door 2, revealing a goat, and asks you if you want to switch which door you choose. Should you switch?

Counter-intuitively, the standard answer is yes. There is a 2/3 probability that the car is behind door 3, and only a 1/3 probability that the car is behind door 1. I'll prove it with math.

Bayes theorem says. In English, the probability of a hypothesis H given a piece of evidence E is equal to the probability of the evidence given the hypothesis times the prior probability of the hypothesis divided by the prior probability of the evidence

Let's define a few variables. We'll say C1, C2 and C3 stand for the car being behind door 1, 2 or 3, respectively. We'll also say O1, O2 and O3 stand for Monty opening door 1, 2 or 3, revealing a goat.

So, what we're interested in finding is P(C3|O2) or P(C1|O2). So, let's plug our variables into the equation.


Ok, so what are each of those terms? Well, P(O2|C3) = 1. Monty can't open the door you chose, and he's not going to open the door with the car. That only leaves one option. P(C3) = 1/3. With no information, we have to assume there's equal probability for the car to be behind each door.

By the law of total probability,, since Monty can choose either door 2 or door 3. P(O2|C2) = 0, since Monty won't open the door with the car behind it. Thus

Plugging those numbers back into the equation, we get. By the same logic,.

Here's another way to think about it. When you pick door 1, it either has the car behind it (probability 1/3) or it doesn't (probability 2/3). When Monty opens door 2, it doesn't change those probabilities. There's still a 1/3 probability your door has the car, and a 2/3 probability your door doesn't have the car. Since door 2 now has a probability 0 of having the car, that means door 3 must have the whole 2/3rds.

But what's really interesting to me about the Monty Hall problem is that it's not just dependent on what Monty does, it's also dependent on why he does it. Everything I've said is true for the standard problem, in which Monty always opens a door, and always reveals a goat. But if those things change, Monty can perform exactly the same actions, and get exactly the same results, but we'll still get different probabilities.

For example, suppose Monty only opens another door if you picked the door with the car. You pick door 1, and Monty opens door 2, revealing a goat. Should you switch? In that case, you definitely don't want to switch, because Monty wouldn't have opened a door at all if you had guessed incorrectly the first time. In this case, P(O2|C3) = 0, so P(C3|O2) = 0, and P(O2) = P(O2|C1)*P(C1), so P(C1|O2) = 1.

Alternatively, suppose Monty always opens a door, but opens one of the two you didn't pick at random. Again, you pick door 1, and Monty opens door 2, revealing a goat. It's possible Monty could have opened door 2 and revealed the car, but not this time. In this case, the probability that the car is behind door 1 and the probability that the car is behind door 3 are both 1/2. The reason is that he's twice as likely to open a goat door if you've chosen the car door than if you had not chosen the car door, so you do get information about the door you chose.

You can also find that using Bayes' theorem as before. P(O2|C2) = 0, since the goat can't be behind the door with the car. P(O2|C1) = P(O2|C3) = 1/2, since there's a 1/2 probability that Monty will open door 2, regardless of which door the car is behind.


But what if you don't know what strategy Monty is following? What if all you know is that there's a car behind one of the three doors, you picked door 1 and Monty opened door 2, revealing a goat. Maybe he's making a decision based on one of the three strategies I just described. Maybe he's using some other strategy. How do you calculate the probabilities then? What decision should you make?

I honestly have no idea.

Sunday, August 3, 2014

A Defense of the Free Market

I've written before in defense of socialism, but that doesn't mean I'm opposed to the free market. Quite the opposite, in fact. The free market is a very powerful tool, and under the right conditions it's maximally efficient.

However, like any tool, it can be misused and abused. But that doesn't mean it should be completely banned, just that it should be used in a carefully controlled manner. There are those who think that regulating a market makes it non-free, but they're wrong. Regulations can help establish the conditions a free market needs to work efficiently.

One of the best uses for the free market is the production of luxuries, for example, video games. They're not a necessity, like medical care, so no will die if they can't afford them. They're not a natural monopoly, like electrical transmission, so lots of people can make them and drive competition. They don't have significant externalities, like pollution, so the costs and benefits are primarily borne by the buyers and sellers. And the free market environment is great for the spurring greater innovation and variety.

That is exactly the kind of thing for which the free market should be used.

Monday, June 30, 2014

Religious Exemptions

Today, the Supreme Court ruled that Hobby Lobby doesn't have to provide its employees with insurance that covers contraception, because that would violate Hobby Lobby's religious freedom. Legally speaking, the Supreme Court probably made the right decision. The Affordable Care Act has a religious exemption written into it.

That's the problem. Laws shouldn't have religious exemptions. I'm not just talking about this law, I'm talking about any law. Or rather, no law should have a specifically religious exemption. Laws can have exemptions that include religious reasons, but they shouldn't be exclusive to religious reasons.

There are two reasons for this. One is that religious belief shouldn't be treated any differently than any other belief. If a religious conviction is enough to exempt you from a law, then a secular conviction should be as well. Otherwise you would be elevating religious beliefs above secular beliefs.

The second reason is that it violates the separation of church and state. You might not think so, since usually religious exemptions are intended to prevent laws from hindering the free exercise of religion. But that's the problem. It forces the government to decide what is or is not a valid religious belief to qualify for an exemption.

Not only does that violate separation of church and state, it does so in a way that is biased against minority religions. Members of major religions generally won't have any problems convincing a judge that their belief is sincere. Only members of small religions will have to worry about not being allowed to practice their religion freely, which seems like exactly the kind of thing that freedom of religion is supposed to prevent.

But what about free exercise of religion then? Well, generally laws are passed for reasons. If those reasons are good, they probably apply to everyone, religious and non. You can't murder people, even if you really truly believe that the god Huitzilopochtli needs them to make the sun rise.

If a religious exemption is really necessary, it can probably be rephrased to be secular, and still apply to the religious. For example, non-profit organizations are tax-exempt, whether they're churches or not. (Though current law more or less automatically gives religious organizations non-profit status, which is the kind of thing I'm arguing against here.)

And if that's not possible, maybe the law shouldn't be a law in the first place. If "I really truly believe in " is a good enough reason to be exempt from a law, then "I really truly believe in " should be as well, based on religious beliefs not being treated differently than secular beliefs. And if that's good enough, then pretty much anyone who doesn't want to follow the law doesn't have to, which completely defeats the purpose of it being a law in the first place.

Thursday, May 22, 2014

Prescriptivism and Descriptivism

On the internet and in newspapers, it's not uncommon to see rants about how our language is deteriorating. Words that meant one thing fifty years ago are used completely differently today. New words are made up and used as if they were cromulent. Kids these days speak grammatically uncorrectly.

And generally there will be responses to those about how that's a prescriptivist way of thinking, and prescriptivism is linguistically incorrect. Descriptivism is the only correct way of talking about language. Language is always changing, and words have no inherent meaning.

While in this context, the prescriptivists are usually completely wrong, I can't completely agree with descriptivists.

It's true that linguistics is descriptive. As a science, it has to be. The goal of linguistics is to study language to learn about how it works, and you can't learn about how something works by telling it to work differently. Kepler didn't discover the laws of planetary motion by insisting that they ought to orbit the sun in perfect circles.

But the scientific study of language is not the only way to interact with it. It's not even the most common way. The most common way of using language is the way we're using it right now - to communicate. Reading, writing, speaking, listening. And when you actually use a language, not just to study, but to communicate, you can't avoid being at least a little bit prescriptivist.

If you're trying to use words to communicate, you have to ascribe meaning to them. And if the meanings you ascribe to your words are different than the meanings the people you're trying to communicate with do, then you'll have a very hard time communicating. If you want to communicate with a large group of people, you have to get them to all use the same meanings for the same words. Words don't have inherent meaning, but it's a very useful fiction.



Tuesday, February 18, 2014

Ken Ham and Evidence

A couple weeks ago Bill Nye and Ken Ham had a debate about creationism. Of course, nearly every point Ham made was factually inaccurate. But beyond having the simple facts wrong, Ham also had a fundamental misunderstanding about the nature of evidence.

This was highlighted most clearly in Ham's answer to the question "What could change your mind?". His answer was, summarized, "Nothing". Now, this answer in and of itself is a serious strike against Ham's rationality. The point of changing your mind is to make your beliefs more accurate. If you don't even admit the possibility of changing your mind, you're saying that your beliefs cannot possibly be wrong, which is, well, arrogant to say the least.

But it's worse than just that. Ham also said that the Bible makes testable predictions. Alone, that's not a bad thing, quite the opposite. But when combined with his statement that nothing could change his mind, it shows that he doesn't understand the point of predictions. The point of predictions is to provide evidence, but the thing is, that evidence can go either way.

If you make a prediction and perform a test, and the results of the test match the prediction, then that is evidence that supports your beliefs. On the other hand, if you make a prediction, and perform a test, and the results don't match the prediction, then that is evidence that opposes your beliefs. If there is no such outcome that would go against your prediction, then it's not a prediction at all.

For example, suppose I held a rock, and based on my beliefs about the material it's made of, and the laws of physics, I predicted that when I let it go, it would fall down. Then, if I dropped it, and it fell down, that would be evidence in support of my beliefs. But, if I dropped it, and it didn't fall down, either falling up, or hovering in place, or anything else, that would be evidence opposing my beliefs. If I had predicted that when I let it go, either it would fall down, or it wouldn't, then I haven't actually made a prediction. I haven't, in any way, specified what the result of a test would be, which means no outcome can oppose my beliefs, but no outcome can support them either.

If Ham thinks the Bible really does make predictions, then those predictions failing to come true should change his mind. If nothing could change his mind, then his predictions can't actually provide evidence.

Monday, January 20, 2014

Folk Morality

Folk science is pre-scientific ideas about how the world works. For example, a common idea in folk physics is that an object in motion requires a constant force to stay in motion, and if the force stops being applied, the object will soon come to a halt.

Now, folk science is not always wrong. It actually tends to be very good at predicting what happens in everyday circumstances. If you're pushing a cart, the carts stops moving when you stop pushing. It's when you leave everyday circumstances that folk science fails.

I think the same idea applies to morality. Folk morality is what people generally use when making moral decisions. It doesn't have any kind of rigor or theory behind it, but in everyday circumstances, it works alright. Don't lie, don't steal, don't kill.

The biggest problem with this idea is that folk science is based on things that can be directly observed. Folk morality doesn't seem to be. As a result, it's much more prone to differ between cultures and eras. For example, two hundred years ago, slavery was common and accepted, but it isn't today.