Measuring happiness

How do you measure happiness? Is there an objective and quantitative way to know if a person falls within “acceptable happiness parameters”? My answer might sound like it comes from one of those self-help books. Or Zen philosophy. Meh.

So let me tell you the story of how this question came up. I was invited to attend a small gathering of, hmm, philosophically-inclined people (let’s leave it at that). I arrived before the appointed time, and met up with a couple of people. One of them said he was thinking of a way to measure happiness. Naturally, we asked how. On hindsight, I think the “why” is probably more important.

The happiness measurement experiment

The guy (henceforth referred to as the “proposer”) said he would attach equipment that measured a person’s brain waves, heart rate, or some such. I can’t remember the exact details. I think it involved EEG (electroencephalography). Basically, you measure and record the physical signals of a person (henceforth referred to as the “subject”).

The subject would also have to follow a prepared diet, so as to keep the physical input/output of the body consistent. This was when I asked what if the subject tired of the diet. The proposer said there could be slight variations of the diet so as not to bore the subject’s palate, say the weekend fare was different from the weekday fare. This immediately sent red flags to my (programmer/scientific/whatever) senses. But I smiled and gave mild encouragement, as did the other person at the table. I just met this proposer guy, so it’s not really up to me to say anything negative.

For the purposes of this discussion, we’ll say that for an experiment to have merit, the experiment must be repeatable with consistent results. First off, it will be ideal if you have full 24 hour monitoring on the subject, for at least a few weeks. Or a couple of months if your subject is female (I’m not discriminating on gender! I’m just aware of the hormonal changes in a woman’s body, ok?).

Second, the activities of the subject cannot vary. At all. There’s no practical way of determining if a particular activity triggered happiness or induced sadness, if the subject is allowed to do all sorts of activities without any kind of regularity. If the day starts with exercise, then reading, then some writing, then sleep, then that’s how it has to be every day. If you give some leeway on a weekday/weekend difference, then you need to have 2 sets of measurements. And that’s assuming all those activities are performed at exactly (or nearly exactly) the same time. Exercising at 6am, or at 10am, or at 4pm, or at 8pm feels very different.

Grocery shopping is dangerous. (There, I’ve said it)

Frankly speaking, even grocery shopping is dangerous. The subject may be buying some bread. But passing through the meat aisle to get to the bread section might feel very different from passing through the sweets section. Heck, what if the subject meets a close friend? What if the subject meets a hated individual? Small events might trigger a physical signal, but not considered important for consideration. How does one know if those small signals aren’t significant?

Have you had one of those days where you just feel happy? For no apparent reason. Maybe there was a nice breeze in the morning. Your coffee was done just right. That paperwork you dreaded didn’t seem so bad. You fixed a couple of difficult bugs. At dinner, you found out that the nice waitress was getting married (depending on your circumstances, this might sadden you, but whatever…). The book you’ve been reading ended with a flourishing finish. You feel satisfied with your day.

Small events matter. They build up. And you don’t know if there’s causality. And if you don’t, then your measurements aren’t as meaningful.

And then there’s diet… The proposer was very ready to adapt the diet. I’m not so sure. What you put into your body has a direct consequence to your well being, particularly if you know what you’re eating. Change the diet, and you don’t know which foods might have contributed to the happiness measurements (or whether it’s simply because there’s a change that the subject felt happy). Don’t change the diet, and you don’t know whether it’s because the subject got bored of eating the same foods.

Can you keep to a diet?

I have first-hand experience. To keep my living expenses low, I’ve kept my diet fairly consistent. Everyday, with a few rare fails. I came up with a diet that I’m happy (heh) with, and which is affordable. And then I eat those same foods everyday. Those bodybuilders and people who successfully lose weight? They do the same thing. They come up with a diet they’re comfortable with, and they stick to it.

Just to give you an idea, my breakfast is cereal with milk. The brand of the cereal, or the type of cereal might change, but it’s usually cereal. My dinner, for the most of 1 year (as of this writing), had been 4 to 6 (depending on how hungry I was) slices of bread and peanut butter (or occasionally some other bread spreads). Lunch was up for grabs, but I usually eat noodles in soup.

I will tell you something right now. I could distinctly feel my body changing. Heck, I’m not afraid to tell you this. I, uh, smell different. Sometimes, I even feel I’m oozing oil through my pores. I think that’s to do with the (almost) daily consumption of peanut butter. It’s why I’ve, uh, modified the bread spreads, going so far as to even eat something more wholesome, like rice with some meat and vegetables. Ah, the things you do to keep your business costs low…

So yeah, the proposer didn’t even have the discipline to keep to any kind of schedule for the subject. And frankly speaking, the only way to get extremely good consistent results that are meaningful, will be to keep the subject in a prison-like environment. Everything should be as regularly followed as possible, such as activities and diet. Only then can you say with a certain amount of confidence that, yes, that 5 minutes of meditation had a measurable effect, since that was the only day when the subject meditated (and the 2 days before and after had no measurable signals of happiness).

The biggest problem with human experimentation

Even if you managed to keep all the variables consistent, and find a willing participant to follow along, there’s one huge enemy. Boredom.

Hey, I’m quite indifferent to food. As long as it’s fairly palatable, I only care that it’s nutritious. I can eat that regularly, everyday if need be. During my primary school days (for a couple of years), my dinner was practically always barbequed pork rice (or char siew fan, if you understand Cantonese). I guess my indifference to food started then.

Even so, I have my limits, it seems. A steady dinner diet of just bread and peanut butter wore me down. (And I’m also getting tired of people telling me how thin I look. Apparently, my face has thinned, my eyes have sunken in, and my bicep muscles have slightly wasted away, rendering the years of my weights training moot. I’m eating, ok, I’m eating! Sheesh…)

We are humans. The complexity of our minds is too great to fully comprehend, let alone the connection of the mind with the body. How do you really measure happiness? How do you find out which variables affect your mood?

There are too many things to consider. Your particular circumstance. Your education. Your group of friends. The time period when you’re living in (people living 100 years ago probably feel happy just to have bread to eat, while you’re only happy if you get to eat steak #firstworldproblems).

So my answer, after you’ve read all that, is this: The criteria for your happiness is determined by you. Don’t let other people determine what criteria you should meet before you can feel happy.

How to tell if an egg is hard-boiled or raw

Do you know how to differentiate a hard-boiled egg from a raw egg? Watch the fascinating demonstration below:

There are 3 simple steps to test your egg:

  • Spin the egg
  • Stop the egg
  • Watch the egg

A hard-boiled egg will stop spinning after you stop it. A raw egg continues to spin even after you stop it. That’s because the egg yolk inside the raw egg is still spinning and swirling inside the raw egg’s shell.

Videography back story

So I recorded the actual demonstration a day earlier than the face-to-face video. I had to make sure the experiment worked first. Hey, I had to boil 2 eggs! The stove and I aren’t exactly close friends. Huh, why 2 eggs? Well, 1 egg was for backup, in case the original hard-boiled egg didn’t work out.

This meant I had 3 eggs to eat. Wait, where did the 3rd egg come from? Well, I scrambled the raw egg contents into some noodles. No food wasting, ok? So 2 hard-boiled eggs, and 1 scrambled egg with noodles. I do not want to see another egg in the immediate future…

That actual demonstration video was recorded on my digital camera, which is a little dated according to current standards. I can only get a 640 by 480 resolution, which is a far cry from the 1280 by 720 HD resolution I needed. Buuut, you use what you can get…

Answers to philosophical questions must be reasoned

My friend wrote a short guide on what makes a question philosophical. The 3 conditions for a question to pass the philosophical test are interesting.

Has not been answered by science

The obvious reason is that, if it’s answered by science, there’s no point in answering it (philosophically).

For example, “Can penguins fly?” is answered by science. It’s “no”. Their bodies aren’t made for flying. Although…

More than one possible answer

If there’s only one answer, there’s no point in answering it.

For example, “Is 1+1 = 2?” has the answer “yes”. There’s no other answer.

Unless you’re talking about base 2…

Cannot be answered by conducting an experiment

“Can common salt be produced by mixing two liquids together?” can be answered with experiments. After laborious testing, you find that if you mix sodium hydroxide and hydrochloric acid, you get sodium chloride (and water), or more commonly known as salt.

If a question can be answered with experiments, then there’s no point arguing about it. Just do the experiment to test the answer.

So I conclude…

that my friend doesn’t like science. *smile*

No, it’s that when a question can only be answered by reasoning it through, then it’s considered a philosophical question.

Rotate backwards to stay level

It was a university programming assignment. I was to write an OpenGL program to render a Ferris wheel. The requirements were simple. There had to be 7 spokes emanating from the centre, each at an equal angle from each other. At the end of each spoke, there was to be a carriage. No outer rim was required. All 7 spokes and 7 carriages were to be simple cuboids. The wheel was to turn slowly. Colour aesthetics up to the individual.

I’ve already had lessons on simple rotation and translation operations in OpenGL. Ambient colouring, materials and shading were also taught. And simple cuboids were like basic rendering stuff.

The hard part that my fellow students found was in keeping the carriages level, while rotating the Ferris wheel.

My professor, being the evil mind that he was, chose 7 spokes, so the angle between each spoke was “weird” (no nice number). Believe it or not, that confused a heck of a lot of students… Rendering the spokes were easy. Render a long cuboid with one end at the origin, and rotate multiples of 360/7 degrees. The carriages on the other hand, needed some work…

A simple way of orienting the Ferris wheel is to align it with the XY plane, with the centre of the wheel at the origin. There are then 2 methods to render the carriages. The first is to calculate the XY coordinates of centres of all the carriages, and simply translate them there. Yes, there will be sines and cosines in the calculation. I’ll leave it to you as an exercise. If you were able to follow the article on bilinear interpolation in image rotation, you can do this.

The second method is to just use the rendering engine’s in-built functions. For example, you render a vertical spoke with one end at the origin, and the other end along the positive Y-axis. Then you render a carriage at the latter end of the spoke.

Then what do you do? Render the 2nd spoke-carriage combination exactly the same as the 1st, but rotate the whole thing 360/7 degrees clockwise. Here’s where the problem comes. Since the carriage is “tied” to the spoke, the rotation operation affects the carriage as well.

To keep the carriage level, you have to undo the rotation operation. How do you do that? Rotate the carriage in the other direction with the same angle.

Let’s leave the spokes out of the picture. To render a carriage in the correct position, at the correct angle, this is the series of steps to take (assuming the carriage is at the origin):

  • Rotate -i * (360/7) degrees (anti-clockwise)
  • Translate len units in positive Y direction
  • Rotate i * (360/7) degrees (clockwise)

where i is the number of multiples required, and len is the length of the spoke.

If you’re following this with OpenGL or DirectX, take care. That series of steps have to be reversed, because the 2 rendering engines apply the transformations in reverse order.

Hmm… that was a long story…

The one about chicken heads

Did you know chickens have this ability to keep their heads stable, even if their bodies are moving? Check this video out.

I believe chickens use a similar principle as discussed in the Ferris wheel. For example, if a chicken’s body was moved forwards (in the direction of its head), to keep its head in the same position, it has to move its head backwards.

A fluttering thought

To stay the same in the face of change, one must replicate and execute the change in the opposite manner.

Sort of like Newton’s First and Third Laws combined.

I was just thinking, in the face of changes in these times, staying the same is actually more tiring than going with the flow. I mean, you expend the exact same amount of effort to stay the same, and you have to expend more to improve (on business, on technology and so on). That doesn’t quite make sense…

It’s a cliche, I know, but the only constant in life is change. Expect it. Embrace it. Besides, staying the same is boring at some level…

A simple experiment

To convince yourself of the “backwards” principle discussed in the rendering of a Ferris wheel, try the following.

  • Stand up straight, face and body forwards
  • Turn your body, from the shoulders down, clockwise
  • You must keep your head still facing the same direction as at the start

Did you have to turn your head anti-clockwise to keep facing the same original direction?

Be careful when timing one-liners

Be careful when differences between your timing tests are one-liners, and these one-liners are the entirety of your timing code. This applies to small chunks of code too. I’m actually extending a remark I said while discussing multiplications, additions and bit shifts:

This allows you to increase the percentage of identical parts between the tests, and thus highlight the difference in only the calculation method

The small code chunks you’re testing are sensitive to timing, meaning their timing results are likely to fluctuate. Instead of testing the code chunks in isolation, surround them in code used in a typical situation. Why should you do this?

Suppose you’re testing 2 methods. In isolation, method A took 2 seconds. Method B took 5 seconds. Wow! Hands down, method A is faster than method B.

Then when you use method A in production, you find no real speed benefit. Why?

Because in a typical use situation, the surrounding code together with method A takes 60 seconds. A 3 second savings isn’t much. In reality, it doesn’t matter which method you use. Practically speaking, they took the same amount of time.

This was what I meant by increasing the percentage of identical parts.

A physics experiment: timing falling balls

Suppose you want to time how fast a ball falls from a specific height to reach the ground. You start with experiment A (shown in picture), with a low height.

Timing falling balls

Then you try starting from a higher height, say 3 times higher, in experiment B. You take your measurements and do the relevant calculations. Taking into account the different heights, you divide the timings in experiment B by 3 to normalise them with those of experiment A. And you find they differ quite a bit. Why?

Because you forgot to take into account that when you start and stop a timer, your reaction time comes into play.

Your reaction time took a larger percentage in the total time taken in experiment A because the ball hits the ground fairly fast. In experiment B, the time taken to hit the ground is longer, so your reaction time takes a smaller percentage.

So what’s the larger “percentage of identical parts” in experiment B? Air, or more height.*

* assuming wind and air eddies don’t foul up the experiment