Kyle Lahnakoski

Just One More Layer of Indirection
(Trying to achieve stable orbit with sufficient architecture)

Archive for the ‘Math’ Category

Gamma Correction

Thursday, February 25th, 2010

I have long desired an awesome colour wheel from which to select the colours for my palette.  I am not looking for a beautiful human-selected palette; I am looking for a purely mathematically based palette that looks great too.  I have noticed that the yellows and browns, in software palettes, are a tiny slice of any mechanically generated palette.

Let’s begin with my problem.  I am trying to transition from green to yellow by adding red:

The problem

I can not be certain what you see, but I see green, green, green, green, maybe lighter green, and then a transition to yellow.  This is a poor start to making a good colour wheel.  It seemed to me that the high-intensity green was overwhelming the small amounts of red.  I wanted some way to boost the low reds so I would get a better range of lime greens.  I knew intensity was a “logarithmic” scale, and I was hoping compensating for the “logarithmic error” would help with this problem.

I was wandering the web when I found Eric Brasseur needed to compensate for gamma error in picture scaling.   Could his solution be what I was looking for?

This time I used dithering to mix my colours and make the transition from green to yellow.  If I can see past the graininess of the colour swabs, I can see if this transition was better.

The test

I definitely get more yellows, and the uniform green has been removed.

Using Eric Brasseur’s gamma error correction to blend colours, I get:

The solution

Excellent!

I should point out that this is not actually Eric’s gamma correction, just that he was the one that brought it to my attention. Apparently, the gamma curve for consumer monitors is well defined. See Wikipedia on the sRGB standard

Now the three all together:

The solution - together

From top to bottom we have the gamma corrected blend, the dither blend, and the original “linear” blend.

The following has blends of eqi-intensity.  Bright yellow, as shown in the above palettes, has double the brightness of the green, so it is not a very good test for gamma error correction, and does not belong here.

Comparison RGB

Click on image to view at full size. The reduced size shown blends the dithering improperly.

Again, from top to bottom, we have the gamma corrected blend, the dither blend, and the original “linear” blend.

If you do not see the top row and middle row as the same, you should calibrate the gamma of your monitor.  I find these two images much better for calibrating gamma than the black-and-white lines (or RGB lines) used in most other gamma calibration images.

Finally, a mathematically based colour wheel:

Colour Wheel

Equal Temperament is a Poor Approximation

Wednesday, August 19th, 2009

I may soon be determined to replace WordPress: It loves to add formatting to my html, making my posts unreadable. Until the day comes that I can get off my lazy butt to do something about it, I will just add a link:

Equal Temperament is a Poor Approximation

The Chart is NOT Wrong!

Thursday, February 19th, 2009

If you beleive area more important than diameter, then the chart is wrong. But, I will argue that choosing the area metric over the diameter metric is wrong. Here is the controversial chart:

I hope we can all agree on a couple of the things this chart does right. First it is visually appealing, and second, it also shows each bank independently. A bar chart would be a poor choice because it must be given an artificial ordering on the horizontal axis, which may detract from the statement this chart is trying to make.

Almost all of us humans (including the math geeks) are unable to translate comparative area graph to a numerical ratio with any accuracy. Let’s use JP Morgan as our reference: How many little green circles fit into the big blue one it occupies? Did you just cheat and square the ratio shown on the graph? Did you visually count the number of green circles that would squeeze into the blue area? Was it hard? Did you get a ratio of 1:4, or more accurately 4:15 (1:3.75)? Now compare the diameters: You probably concluded “around 1/2″ with little mental effort.

JP Morgan was the easiest one, how about the extremes, like Citigroup. How many tiny green circles fit? 100? 200? 300? How about the more accurate picture of JP Morgan to the right here?

If I was to compare the diameters, I would guess 9:10 ratio. Which is very close to 147:165. Oh, did I say this was more accurate? Well, it turns out the blue crescent takes up 20% of the total area.

I am willing to bet most people, when asked to read the proportions indicated in these charts, will compare the diameters of the circles because it is easiest to do. The diameter is what people see. The people do not see area.

One final chart to make my point. Is the little green man half the size?

Following the (unsaid) convention on how to read a chart, the “Market Cap” chart is correct: Comparative diameters is the correct portrayal.

Re: Finishing The Game

Thursday, January 8th, 2009

Jeff Atwood has a post on probability.

Let’s say, hypothetically speaking, you met someone who told you they had two children, and one of them is a girl. What are the odds that person has a boy and a girl?

Thus, the odds of this person having a boy and a girl is 2/3 or 66%.

There was a lot of response, even from a blogger I read: Vorlath:

So Jeff is wrong to say: “Most people answer 50%. Unfortunately, this isn’t correct.”

The odds of the person having a boy and a girl are 66%. Jeff’s reasoning is correct, but too simple to reveal the reason clearly. I had to think about it too.

The way to get the right answer in these types of probability questions is to make sure your mental model is built in the correct procedural order. It is natural for us humans to choose the simplest model that appears to match the problem, and then extrapolate to an answer.

In the case of the person with one daughter: We naively start with a family consisting of one daughter, and fill in the missing child with a 50%/50% choice. We conclude the chance of the other child being a boy is then 50%.

Let’s look at the construction again:

1) Person has one daughter
2) Person generates a second child by random

But this is not what happens. What really happens is:

1) Person gives birth to two children
2) Person indicates one is a girl

We must look at the probabilities based on the proper order of operations. in this second case. Which is what Jeff does when he inspects all four child combinations.

One a related note, a comment Mark Bradly:

This is easy to disprove.

Jeff says if the parent you meet says “Girl” there’s a 66% chance the other child is a boy.

What’s sauce for the goose is sauce for the gander.

In Jeff’s parallel universe blog the parent responded “Boy” instead. And again Jeff said that the answer is 66%.

So no matter what answer is given the odds are 66% of having mixed sex children… which clear contradicts the FACT that the odds of having mixed sex children is 50%.

66% = 50% is a contradiction. Clearly, the premise is wrong.

This Mark’s parallel universes only consist of 3/4 of the whole. Taking this into account, 3/4 * 2/3 = 1/2 as expected.

kyle@arcavia.com