Sunday, March 09, 2014

The One Hour Challenge

                Hello again. It has been awhile. I have been good. I hope you are all doing well. Speaking of it being awhile I decided to try something I am calling The One Hour Challenge. I often start projects that I never finish, so I decided to give myself one hour to try something and then post the results however far I got. What I have tried to do is create a game using Microsoft Excel. I thought it would be a fun way to practice using Excel. It would be a bit of stretch to call what I have so far a game, but I think with a lot (lot, lot, lot) of work it would be possible to actually create a game that was fun. I didn’t really expect to get far (seriously it would probably take about a minute or two to “play” it) and the “game” ends kinda abruptly, but I am actually pretty happy with how it turned out. I may or may not continue to work on it. I think I will probably do more challenges like this in the future. Anyway here is the link to my website where you can download “The Game”. See you probably much sooner than last time.


http://frostyelf.com/downloads

Monday, July 08, 2013

Who is the Biggest Loser Inducer


                So, I am going to talk about the Biggest Loser now (I really need to learn how to write intros). In the Biggest Loser contestants work under the direction of a trainer trying to lose as much weight as possible. In the first couple seasons the trainers are Jillian Michaels and Bob Harper. I was curious as to which of them was more effective at getting people to lose weight, so I turned to my old friend regression analysis. If you are unfamiliar with regression analysis I explained it in a previous post and, of course, there is a Wikipedia entry, though it does get a bit complicated.
                Caveats and Addendums: Once again I would like to remind you I am an amateur. Do not take anything I say too seriously. If you manage to get on the Biggest Loser, I claim no responsibility for any lost prize money, though if you want to share any prize money I will not object. In fact this whole thing was probably done wrong (see the end of this post for why).
                I know that for the first two seasons Bob and Jillian are the only two trainers and that the contestants stay with their trainer throughout the entire season. I was going to use data from the first two seasons, but this whole thing took a lot longer than I expected (you’d think I would have learned to expect that by now). I mainly choose to do this because I thought it would be easy. So basically I am lazy and only used data from the first season which I got from Wikipedia. Have I mentioned regression analysis is hard?
                As I explained in my first post, a regression has a dependent variable and independent variables that are supposed to explain it. In this case I choose to have the weight lost each week to be the dependent. I used height, which trainer, gender, and weight the previous week for the independent variables. If you read my previous post you might be wondering how I can include the trainer as a variable. Quite simply actually, for categorical variables such as this you simply create a binary variable, meaning it is either a zero or a one. In this case I used Jillian as a variable, so if a person had Jillian there Jillian variable would be a one, and if they had Bob it would be a zero. Then the coefficient represents what the change is when the variable is “true” i.e. how many more/less pounds one would expect to lose with Jillian as the trainer.
 I was surprised to see the R squared was only .04 and the adjusted R squared was actually negative. R squared is a statistic that shows how well the regression equation predicts the dependent variable. So a .04 means that your “predictions” would be 4% more accurate than just assuming it was the average. Basically all my hard work was totally useless.
                I decided that what week it was might be an important factor as well e.g. I have heard people usually do worse on the second week. I can’t just throw in what week it is as a variable since if you recall the variable is multiplied by a coefficient in the regression equation. What would it mean if the coefficient were .8 and the weeks go from 1-10? So like with the trainer I created ten binary variables, one for each week. When I type out the equation I got I won’t include these since they aren't what I am testing for and that would be a lot to type out. Now the adjusted R squared is .12 meaning it explains 12% of the variance in weight lost. This still isn't great, but it is better than it may seem. R squareds are often low and we aren't interested in making predictions anyway. Anyhow here are the results:
Change in weight = -6.23 -1.54(Jillian) -1.26(Male) -.25(inches)
                Apparently Jillian is the better trainer according to my results. We would expect her to get people to lose about 1.5 more pounds per week. That is too bad since I like Bob more, but one should not be trying to reach a certain result.

Oh one further addendum: I realized while typing up this post that there is a time component to this data which changes things for regression. I don’t actually know how to do a regression with a time component, so my whole method for trying to solve this is probably totally not even legitimate. I have already spent way too much time on this, so I am not going to try to figure it out now, but perhaps sometime (relatively) soon I will try to do one with time correctly. Actually now that I think about I think creating variables for the weeks might resolve that issue. I will update if I figure it out.

Side Note #1: Thanks for visiting my blog.

Side Note #2: I was hoping to have this post be on a website I have bought, but I have not set it up yet. And after dealing with issues with PSPP, the program I use, I do not feel like trying to figure it out. I suppose that is why I do these things, to learn how to deal with all the difficulties that inevitably arise. Anyway I will probably be launching the website sometime (relatively) soon.

Side Note #3: I consider this whole blog/future website thing to be a very long term project, so don’t be surprised if the quality and frequency of posts aren't always consistent.

Side Note #4: I try to strike a fine balance of not being to academicky, being informative, somewhat random, yet coherent, accessible and accurate. If you think I am failing at any or all of these or have any suggestions please let me know. Constructive criticism is always appreciated. The other kind, not so much.

Side Note # 5: Puppies!



(Credit: Flickr user Kiwi NZ)

Wednesday, October 17, 2012

I am Biased and so are You


               Have you, or someone you know, ever bought a car and then you seemed to see the same kind of car everywhere? This is very similar to confirmation bias. You see the car more because you recognize it and notice when you see it. Our senses pick up far more information than we can possibly process and consciously recognize. The average person probably sees dozens of cars a day. Confirmation bias means that you notice the things that confirm your beliefs and are less likely to notice things that contradict them, or you may just think that they are rare exceptions.  I think that sexism and most other discriminatory beliefs are largely due to confirmation bias.

(Source: xkcd)

                I also think nearly everyone (certainly including myself) is constantly and strongly influenced by confirmation bias and other biases.  Sometimes I wonder if I should even trust myself. Honestly I don’t think I should, but I don’t really have much choice now do I. This belief emphasized by things like this and this(particularly fascinating) makes me question whether we can ever really be sure we know the truth.  This idea bothers me a lot. It is for some reason important to me to think that logical reasoning, evidence, and a good debate can lead to the truth. I still think those things are important and will on average lead to something closer to the truth than any other method, but I am no longer convinced that they necessarily will. I am likely to express my opinion on things once in a while, so I think, given my beliefs, that I should explain a little about myself and what biases I may have.
                My name is Ethan (not sure how that would be relevant, but you never know. Maybe I am more likely to like the store Ethan-Allen?). I grew up in central Minnesota, United States of America. I think in some ways my view are fairly typical of an American (I am pro freedom and democracy and things like that). I am currently in college working towards a bachelor’s degree in economics. I think economics has influenced me a lot. I often view things in terms of costs and benefits to an individual and society. I was Lutheran for most of my life. Around 16 I started doubting Christianity and around when I was 19 I started considering myself atheist (and I still do). I think I am very liberal in nearly every since of the word except for the political left wing sense. I am generally for more freedoms, embracing change, and letting people live the life styles that they want to. I am pretty geeky(if you haven’t noticed you soon will). That is all I can really think of.
                So, as you view my blog realize that I am not claiming to be an expert in anything or that I am always right. Try to keep my biases in mind and maybe yours as well.

Thursday, September 06, 2012

Travelling Through Space and Time


Hello Everybody! Let’s do a science! You may have heard that traveling near the speed of light causes time to “slow down” relative to those that are traveling at slower speeds. If you are like me, you have probably wondered how strong this effect is for different velocities. Well my new (and old) friends you are in luck. I have created an excel file, which you download here that automatically calculates this effect, called time dilation, for fractions of the speed of light. Don’t want to download it, or don’t trust me to not give you a virus, well you are still in luck, because time dilation and the possibility of manned space travel to other stars is what this post is about. First here is a chart of the time dilation effect for certain percentages of the speed of light.

Caveats and addendums: I am not a physicist. I don’t even know that much about physics. This project is part of my attempt to change that. It is certainly possible I made a mistake. If you spot one, please leave a comment. If you attempt to travel to another star system based on this post you are an idiot, and I am not responsible for any loss of finances, limbs, or life that may occur.

As you can see you need to attain a significant fraction of the speed of light for time dilation to really matter. Just how hard is it to reach these kinds of velocities? Well let’s put things in to perspective. The fastest velocity ever achieved by a human made object was attained by Helios 2, a satellite that studied the sun. Helios 2 attained a velocity, relative to the sun, of 157,078 miles per hour or 70,220 meters per second. The speed of light is 299,792,458 meters per second. Helios 2 achieved (70220/299792458) about 0.023% of the speed of light. To be fair I don’t think most space mission directors (or whatever they are called) consider maximizing velocity a priority. Space on a rocket is limited. It is better to save that space for more scientific instruments, rather than fuel. However if we want to travel to other star systems velocity is going to be extremely important. Our closest stellar neighbor, Alpha Centauri, is 4.4 light years away. To be clear light years are a measure of distance not time, no matter what Andy says. I think Dr. Sheldon Cooper said it best when he said
“I would not say that. No-one would say that, a light year is a unit of distance, not time… You see people hear the word year and they think duration. Foot-pound has the same problem, that’s a unit of work, not of weight.”

A light year is the distance light travels in a year or about 5.9 trillion miles.

I am going to be using some very large numbers so I will use scientific notation. In scientific notation you take a number times 10 to a certain power. The power that 10 is raised to determines how many decimal point you move to the right, for instance 5.67*10^4 = 56,700. 5,500,000 is equal to 5.5*10^6. If we were to send a spacecraft to Alpha Centauri at a velocity of 70220 meters per second relative to the Earth, it would take the spacecraft more than 19,000 years to reach the star (actually stars, it is a trinary star system). The problem with travelling near the speed of light is it requires a huge amount of energy. As well as the fact that the more mass you need to propel, the more energy that is required. To propel the mass of Helios 2, 370 kilograms, to Alpha Centauri in 50 years would require a minimum of 1.2*10^17 Joules or the equivalent of a 1000 megawatt (which is large by today’s standards) nuclear power plant running for 4.28 years. Keep in mind that none of these calculations take into account the time it would take to accelerate to the desired velocity. They also do not take into account the energy needed to slow down upon reaching the destination. If you actually wanted to stop at your target, it would take twice the energy. That’s why flyby missions are so much easier then orbit attaining missions.
What if you wanted to send humans on a mission of 50 years? Let’s say you wanted to send a mission of four people. A low estimate for the amount of food required for one human for one year is 500 kilograms. A low estimate of the average mass of a human is 50 kilograms. Let’s say they would require a space craft at least the mass of the space shuttles, about 60,000 kilograms. In total then we would have 500kg*4 people* 50 years+50kg*4 + 60,000kg= 160,200 kilograms. To send this mass on a  one way 50 year mission to Alpha Centauri at 8.76% of the speed of light would require a minimum of 5.6*10^19 joules or the energy from a 1000 MW nuclear power plant running for 1,852 years. If they wanted to reach 50% of the speed of light they would need 2.2*10^21 joules or 74,283 years of 1000MW nuclear power plant output. I think I have already made my point, but just for fun let’s look at what it would take to move the entire population of Earth to Alpha Centauri in 50 years. Mr. Munroe at what if xkcd looked at what it would take to get every person off the planet. He estimates that the total mass of all humans is 400 million (I assume metric) tons. Once we were all off world it would take about 1.2*10^26 joules or 4 billion years of 1000MW power plant energy to propel us to Alpha Centauri.
                I actually do think that humans will eventually travel to and maybe even colonize other star systems. I could see us building a spacecraft that could support a small population for multiple generations more or less indefinitely. However barring some huge technological breakthrough which is always possible, but should not be assumed or counted on, humans will not be travelling to another star system for a very, very long time.


Update:
I forgot to thank Yahoo Answers user debydete for telling me the equation for the energy needed to propel a given mass to a certain velocity. Thank you good sir(mam?).

Also it was recently discovered the Alpha Centauri B has a planet orbiting it, so there may actually be a good reason to someday send a mission there. Though a manned mission may not be necessary as the planet is definitely not inhabitable. The Bad Astronomer has more details.

Friday, August 31, 2012

On Consciousness



               Over at The Sweatervest Chronicles Mr. Blanchard discusses a conversation he had with a biology/philosophy student about the nature of consciousness . The biology/philosophy student thinks that consciousness is “a combination of biology and experience, spirituality, instinct, etc.” Mr. Blanchard seems to believe that experiences play a role, but that ultimately experiences and all of the other factors that affect consciousness are all some kind of chemistry. Mr. Blanchard asks “What do you think?” This is something that I have thought about a lot. My short answer is that Mr. Blanchard is absolutely right. Your consciousness is just the result of chemical reactions. When you feel a soft blanket the nerves in your skin send an electrical signal to your brain and the electro chemical reactions cause your brain to interpret those signals as softness. I think the natural, and more interesting, follow up questions are “If consciousness is just chemistry do we have free will? Is consciousness even real or just some sort of illusion?”


                I will answer the second question first. Of course it is real. What would it even mean for it to be an illusion? If consciousness is an illusion, who is being illuded? If I were to define consciousness, it would somehow involve what humans feel or experience. If consciousness is something different than what we thought it was, we need to change the definition.

                Do we have free will though? I think the answer is yes. I think there are two closely related reasons people believe this perspective on consciousness eliminates the possibility of free will. The first is that by understanding how the brain works that somehow makes it seems like you don’t really decide things it’s just a function of x, y, and z. The second is that it is potentially possible to predict what someone would do. Hypothetically if you knew exactly how all of the atoms in someone’s body (and really you would need to know the exact distribution of all mater and energy (and dark energy and what not) in the universe) and you had a perfect understanding of the laws of nature and you had access to some sort of super duper computer with oodles of processing power you could predict everything that person would do (on the quantum level things are supposedly random, so I don’t know if that changes anything).

                I will address the first reason first. Any sort of consciousness is necessarily going to work through some sort of process. I don’t understand how any consciousness in any possible universe could exist that didn’t work through a system or set of rules or whatever of some kind. Maybe you would argue that I am right and therefore it is not even theoretically possible for a free willed consciousness to exist in any sort of universe. If that’s your perspective I don’t really have a counter argument, and I will kinda address that towards the end.

                As to the second reason, I don’t think the predictability of consciousness necessarily means that it lacks free will. If I said to you “you have two options. I can give you a thousand dollars or I can punch you in the face” I think I can be confident of what you would choose. My being able to predict what you would choose does not mean you did not have a choice. You could halve chosen to be punched in the face, but you didn’t and never were going to which brings me to my second point. The future is by definition fixed. The future is what it is and always has been, and it will be until it happens. If circumstances change so that what you thought was going to happen won’t, the future hasn’t changed your expectations have changed. The future is by definition what will happen. What you will do is by definition in the future and therefore already fixed in a certain sense. Again I think you could argue that therefore consciousness in this universe or any other conceivable universe does not have free will since it is already determined in some sense. And again in that case I can’t say I necessarily disagree which I shall address in the next paragraph.

                I don’t really think it is possible to definitively determine whether or not there is free will. I guess I mostly just think it is the most useful way of looking at it. I feel like in a certain sense the only way to truly, truly describe anything is to talk about the physics of it, the exact protons, neutrons, electrons etc. and their relative position in the universe that make it up. I feel like everything else is really just an ultimately futile, though still useful, attempt to understand and make sense of the universe.  I think this is partly why some people tend to reject the idea that consciousness is just chemistry. It makes life seem meaningless or pointless. It makes the universe seem empty and just filled with random stuff. I don’t feel this way at all. One of the reasons is pictures like this.

(Credit:Wikipedia)
                I think the first time I saw an image like this my thought process went something like this. “This is a cool looking picture what are all of those big blotches? They can’t be stars.” Then I realize that some of them clearly have a spiral shape and think “Wow those are galaxies! What are all those lights behind them? Those are all galaxies too!” Then I realized I was looking at a picture of hundreds, maybe thousands of galaxies each with hundreds of billions of stars.

                There are creatures in this universe (and your one of them) that have the ability and the desire to study and understand the universe. That can build a telescope with a 2.4 meter mirror. Put that telescope on a big rocket. Launch that telescope into an orbit around Earth. Point it out towards the universe, realize that it is broken. Put humans in a shuttle on a rocket. Launch those humans up to the telescope to fix it. Point the telescope out to the universe again and take amazing picture like the one above; creatures that can study and understand themselves and how they came to be. Creatures that have the intelligence to ask questions like “What is consciousness?”  “Do we have free will?” No matter how you look at it, that is amazing.









 All glory to the hypnotoad!



Monday, August 13, 2012

The First Post of a Totally Awesome Blog



Do Lower Birthrates Lead to Longer Lives?

Hint: Yes, No, Maybe, I don’t know, Can You Repeat the Question?

          Hello and welcome to my blog. Why am I starting a blog? Excellent question hypothetical reader. I sometimes like to do little projects. This blog is mainly so that I have a reason not to half-ass said projects. Also I like economics, science, math, a good debate, among other things and would like to share my interests. I hope that people will enjoy my blog and maybe learn something, but mostly it is just a way for me to motivate myself and organize my thoughts. Anyways enough with introspective explanations and on to what this post is about.

             Do births per woman affect life expectancy? Another excellent and kinda random question hypothetical reader, weirdo (Yeah this is kinda silly, maybe even lame, but I couldn’t think of a good intro and this is my blog damn it!). Funny you should ask that just the other day(I have been slowly working on this for like two months so it was actually a while ago) I saw this excellent video by Hans Rosling showing statistics about health care for different countries (Watch it! It is very interesting and well presented).



One of the things that struck me was this graph showing life expectancy and births per woman.




             I thought this was very interesting, but I immediately questioned whether there was causation. There seem to be many things that are associated with births per woman that might explain the correlation. For instance as economies grow less people work in agriculture and there are more job opportunities for young women, so women generally have less children. I think there are also reasons why there might be causation. Families with fewer children might be able to dedicate more time, care and money on each child. The success of each child might also seem to be more important. I have heard of families only being able to afford to send one child to school and therefore sending the child they think is the most likely to succeed.

            What do you do when you have multiple theories that might explain a phenomenon? You turn to mathematics of course, in this case regression analysis. The great thing about regression is that it can help us understand how much of an effect a certain factor has independent of other factors. Regression can get complicated, but I think the basic idea is actually pretty simple. First you figure out which variable is the one that is being changed by other factors, in this case life expectancy. Then you figure out what variables are affecting it. The variable that is being changed is called the dependent variable and the others are called independent variables. Then you arrange the variables in an equation so that the independent is equal to a constant plus each variable multiplied by a coefficient, or multiplier.

Dependent = constant + (coefficient)*(indepent1) + (coefficient)*(independent2)

The coefficients are a measure of how strong of an effect the independent variables have on the dependent. For instance, if you wanted to know how education affects income, just looking at a graph of the two variables might lead to false conclusions if other variables have an effect as well. Perhaps you think parents’ income and age also have an effect. If you made a regression with those variables you might end up with something like this (numbers are made up).


(Thousands of dollars a year)
Income= 20 + .8(Years of Education) + .1(Parents’ income) + .05(age)


            This would indicate that an extra year of education leads to an $800 increase in income. If the coefficient was negative then an increase in the variable would cause a decrease in the dependent. The constant, 20, shows what the dependent, in this case income, would be if all the other variables were zero. Usually this does not make sense and is not important. In this case it would indicate newborn babies make 20 grand a year.

            We know that our dependent is going to be life expectancy and that one of the independents is births per woman, but what other factors affect life expectancy? I thought the main factor for life expectancy would be the quality of healthcare, so I got statistics from the World Bank on GPD per capita, health expenditure as a percent of GDP, and access to improved sanitation facilities. Before I talk about the results, I would like to emphasize that I am an amateur at best. Making a regression is easy, doing it the right way is really, really hard. I am doing it the easy way. To do the regression I used PSPP, a free version of SPSS, and got these results

Life Exp= 58.7 –(3.06)(Births) + (0)(GDP/Cap) –(.22)(Heal Exp)+ (.13)(Sanitation)

                This does not make sense. GDP has no effect on life expectancy and increased health spending shortens life spans. At first I was extremely confused. I tried doing a regression with just GDP/capita as the independent and it was still zero. I considered giving up on the whole thing. Then I realized a one dollar increase in GDP would have a miniscule effect on life expectancy. I redid the regression with GDP per capita divided by 1000 and things started to make more sense. Health expenditure still came out negative when sanitation was included. Maybe this is an indication that increases in healthcare spending are not used wisely. More likely there are certain tests you are supposed to do about the relationship between the variables that I don’t think I can do with PSPP. I am guessing something about how sanitation and health expenditures are related is messing everything up. I wish I could use a program that was actually designed to do regression like Eviews, but they cost hundreds of dollars, and if wishes were horses we would all be eating steak.  I decided that access to sanitation was a better indication of health and came up with the following sensible equation.

Life Exp=67.49 –(3.07)(Births) +(0.1)(GDP/Cap Thousands) +(0.13)Sanitation

                According to my results a decrease of one in the number of births per woman leads to an increase in life expectancy of 3 years. This is more than I thought it would be. I thought increases in GDP and healthcare were the main reason there was such a high correlation, although I would once again like to emphasize I do not have confidence in my own results. I do not think the percent of the population with access to improved sanitation facilities is a very good way of accounting for quality of healthcare. Many countries have 100% or very close. What is my conclusion? I don’t really have one. That wasn’t the really the point of this. The point was just to practice using regression and to look at an issue from a different perspective.