Carl the Zealot

February 24, 2009

A priest, a rabbi, and a troll walk into a blog. Ouch.

Filed under: Free Thought, Private, Religion, Science — Carl Myers @ 4:49 am

My good friend, Steve, recently wrote a blog post about a discussion we had. I thought the comments were all very interesting, but I felt like some of the points I made weren’t getting across, and it was a ripe opportunity to make some more.

Fair warning, the following is what I believe. I am shedding society’s veil of tacit, compromising blind acceptance as well as the insane intellectual disconnect, the cloud through which I am time and time again amazed we are able to scientifically deduce anything. If this post makes you angry, I suggest considering what exactly you are angry about, and why you really believe it so strongly.

As Steve pointed out, religion has given humanity a lot – I have always been the first to agree with that, my problem with it is it’s stubborn refusal to go away, like a house guest that has overstayed it’s welcome. Religion is the crutch of humanity. We have outgrown it. It serves us no longer, you needn’t look far to find ample evidence for that.

Steve says, “When a person points their finger at another and declares them to be wrong because their beliefs conflict, then we are- to put it bluntly- fucked.” If someone told me “2+2=5 and nothing you say can convince me otherwise”, am I really supposed to pretend that is a perfectly correct statement? If you tried to introduce a constitutional amendment which dictated that “2+2=5…In GOD’s country at least”, am I supposed to be ok with that? How about if you want to replace my children’s math books with a new edition which is identical the old one in every way except for the chapter on addition, which has a “special exception for 2+2=5″, is that ok? Some things are just WRONG. And while I am fine if you want to sit at home in your rocking chair chanting over and over “2+2=5 because Jesus loves me”, that is YOUR prerogative. However, when it comes to my tax dollars, my public education, my support of science, and my will for humanity to follow the advancements it has already made with still more, I realize there is more riding on this issue. When people don’t just sit there in their rocking chairs chanting to themselves, but actually believe everyone who disagrees is wrong and they have to impose that belief on others, it concerns ME. It makes me think it is our duty as thinking, rational people to fight back – “believe what you want, but not in my government or my school” only works for so long when dealing with the sort of extremism we are seeing. Whether or not carrots are tasty is an objective thing, but some things are simply not objective, and religion has clouded where that line really ought to be for too long.

Now the beauty of science is, since it’s inception, the sum of all human knowledge has, like entropy, been ever-increasing. This means we can only become more sure about what we know, while facts can go from “unknown to known”, they can not generally go from “known to unknown” (we can discover something we thought was correct was actually incorrect, but we can’t say we “know less about it now”, in fact, we know more about it by knowing it is wrong).

This means each and every question one might ask about the world we live in has one or more theories posited by science, right now, which can be used to answer said question. Let me repeat that, there are “catch-all” heuristics for generating theories so that any question you can possibly ask, right now, already has one or more hypothesis which are scientific and testable, right now. The “god of the gaps” is a myth. Right now, if you asked me “Is there a God”, I can give you a scientific answer. The answer is “No, there doesn’t seem to be, there most certainly is not a personal god who interacts with the world directly”. Further evidence may in fact overturn that, but just like I don’t think there is a flying spaghetti monster, just because I can’t prove there isn’t, science dictates we accept there probably isn’t a god either, until evidence to the contrary arises. We get this hypothesis via Occam’s razor, and any “research” trying to prove the contrary had better be based on some evidence, not just one’s pathetic desire to invent some deity to help them feel more self-important and special in our unimaginably enormous universe.

My very long-winded point is, we are not “fucked” because someone tells someone else they are wrong. We are fucked when we let people claim things are wrong in unscientific ways. We are fucked when we get so many people so brainwashed by an unscientific idea, that even scientists must “dance around the truth” and “mince words carefully” so that they aren’t lynched or shot in their sleep (or at the very least, lose all their funding).

And, above all else, we are “fucked” when we let ourselves forget what it is, exactly, these “religious folks” actually believe. Science doesn’t tell you “if people disagree with your results, kill them”, or “it is your duty to science to educate as many people as possible, lest you burn in hell”. Science encourages people to discover, test, and retest things on their own, while still standing on the shoulders of giants. But the “opposition”, if you will allow me some simplifying generalizations here, is quite different. (If you prefer, replace “They” with “Some religious fundamentalists” in this passage) “They” think “we” are all going to hell. “They” think god DEMANDS they “save us”. “They” think their moral views are “right, absolute truth, word of god” and anyone that disagrees with them is damned. That is why “they” try to invade our schools, silence our brightest minds, poison our children’s education, brainwash the lumbering couch-potato masses (have you ever WATCHED a televangelist?), and the sheer number of them is appalling. These same people who benefit from science day in and day out, driving cars, eating processed food, watching TV and using computers, enjoying the finest medical care, insist science is wrong because “it ain’t in the bible”.

Well WHY ISN’T IT IN THE BIBLE? Couldn’t god have saved an awful lot of lives by telling us the germ theory of disease, or how to treat unclean water to make it potable? Oh, yeah, it must not be part of god’s “plan”. God didn’t do any of that, science did, and the intellectual disconnect it requires for people to enjoy all these modern conveniences while simultaneously saying things like “In the beginning god created… That’s enough for me!”. Clearly it’s not enough for you! If that’s enough for you, maybe you should move back to the Middle East, get some fucking camels and sheep and shit, and live like the biblical people used to. Hope you enjoyed your midlife crisis at 18, because you’d be lucky to make it past 36.

If our country was not already so broken by the seemingly unsurmountable foothold religion has on our society, any scientist that wasn’t themselves deluded would have no choice but to say, without bias, “there is no credible evidence there is a god, therefore, we are best served by assuming there is not a god until such evidence presents itself.” I believe agnostics are simply scientists “too afraid or uncommitted” to admit this, even to themselves. Fortunately for Steve, I don’t believe one’s lack of commitment is sending them straight to hell, or requires me to save their eternal soul, which I hope, Steve will consider to be one of this “firebrand atheist”’s redeeming qualities =)

Of course, there are people who don’t believe their faith has anything to do with science. These days MOST people fall into this category. They are happy to admit the universe is 14 billion years old, the earth is 4 billion years old, and the “7 days of creation” was clearly a “metaphor” or something like that. The bible was the word of god, “as interpreted by the man of the time”, so it’s no wonder we didn’t understand some things Take Pi, for example – the bible says it is exactly 3. Since we hadn’t discovered fractions or decimals yet, I guess god figured it was “close enough”. But how can we believe in a god, and simultaneously believe he, in all his perfection, could only manage to get his message “close enough”? That is a pretty hefty intellectual disconnect right there.

Nonetheless, these people are glad humans have discovered science, and used the brains “god gave them” to create all these advancements, “just as god must have surely intended”. There’s just one problem – they are using confirmation bias. “A tendency to search for or interpret new information in a way that confirms one’s preconceptions and avoid information and interpretations which contradict prior beliefs”. If people did not already believe in god, nothing today, with our current level of understanding, would be anywhere near convincing enough to warrant such a fanciful explanation as god. But since people already believed that, they are just ignorantly incorporating it into their existing beliefs.

In the end, when you consider these people, they are just as uncommitted as the agnostics who say “why, surely, we can never know!” If you are reasonably confident there is no flying spaghetti monster, and you are reasonably confident that 5 million dollars isn’t going to appear under your pillow even if you pray with all your might, then you are deluded if you also think we can’t be reasonably confident that “there probably isn’t a god”, and surely not a personal god as so many faiths dictate.

August 24, 2008

The Space Elevator

Filed under: Future, Physics, Science — Tags: , , — Carl Myers @ 12:35 am

I have absorbed several accounts of the viability of the “space elevator” from Scientific American and various programs on the Discovery Channel, but I have remained as skeptical as I am eager for this advance. I decided to run the numbers myself, completely unassisted, to see how viable it seems to me. After about 20 minutes of “math fun”, I came across the Wikipedia article which basically had it all solved out for me. Check it out: Space Elevator. I highly recommend reading it, and definitely not reading the bullshit I was going to write before I found it =)

May 30, 2008

Genetic Algorithms From Scratch: Harvesting the fruits of not-so-natural selection

Filed under: Code, Free Thought, Open Source, Science — Carl Myers @ 8:44 pm

There are people in this world who “don’t believe in evolution”. There are also people in this world who don’t “believe” the earth is round, or more than 6000 years old. In case any of you were wondering, I consider those two things to be equally well-proven by the evidence I have personally seen (that it to say – very well proven). There are some who would argue “have you personally seen this evidence? have you personally seen those experiments? Did you verify them yourself?”. Of course, that is a ridiculous and slippery slope. I’ve never seen my own heart, but I believe it’s there, dutifully pumping blood through my veins and arteries. Likewise, if some huge fraction of the scientific community accepts some result, I do as well, until evidence to the contrary is brought up.

Why this line of reasoning now? Where is Carl going with this? Well, it all started a few years ago, when I read an amazing article in Scientific American magazine, in the January 2003 issue. The article was called “Evolving Inventions”, and it was about creating software and hardware using genetic algorithms. It made me think “It’s hard enough to doubt evolution, genetics, and natural selection, when we find old bones and genetic markers and other highly-specialized evidence in a wide range of very specialized fields… but it’d be neigh impossible to doubt if you could see it work before your eyes.” The thing is, by definition, natural selection of humans (and most living things besides tiny bacteria) operates on geological scales, beyond the human imagination in most respects. But this article had the solution – Use a genetic algorithm to create complex things – hardware or software algorithms – from the simple, or even nothing. Surely, after seeing that before their eyes, nobody could doubt. Not to mention, icing on the cake, genetic algorithms proved to do a very good job of designing algorithms, according to the article. How potentially useful!

I learned several facts about “genetic algorithms” from this article. Here are the essential bits:

  • The three critical parts of evolution are mutation, sexual recombination, and selection – optimally all three must be present.
  • The most important genetic operation is sexual reproduction, or crossover,
    which mates pairs of the better organisms to sire offspring composed of genetic
    material from the two parents.
  • In addition to sexual reproduction, genetic programming copies about 9% of the “fittest” individuals in a population unaltered into the next generation, which generally ensures that the best organisms in each
    generation are at least as fit as those of the previous generation.
  • About 1 percent of the members of a new population undergo mutation

With that list of requirements, I felt ready to start thinking about my own implementation for running evolutionary experiments in programming. One phrase I really liked which the article used was “Think of it as a creative search through the space of all possible [objects].” In our case, we will be working on perl snippets that “do something”. So, we are trying to perform a very “creative” search through the space of all possible chunks of Perl code – a large space indeed. What we need to do to make this project useful is to abstract many of the specifics away.

What will we call the “object” we are selecting on? For convenience, I am going to call it a “fragment”. Additionally, I am going to say this fragment is a string of code which we can evaluate. The fragment can accept an object (in Perl, a hashref) which can have zero, one or more arguments in it. Additionally, the program can return a hashref with zero, one, or more arguments. Here is an example fragment which ignores its inputs and returns an output of the string “Hello, World!\n”.

my $fragment = 'my $output = "Hello, World!\n"; return { output => $output };';
my $code = sub { eval $fragment };
my $inputs = {};
my $results = $code->($inputs);
printf("Results: " . Data::Dumper($results) . "\n\n\n");

Here is an example of a fragment which takes the argument “input” and returns the result “input^2″:

my $fragment = 'my $input = shift->{'input'}; return { 'output' => $input * $input };'

With the “API” somewhat clearly defined now, we come to our three critical parts. How do we “implement” mutation, sexual recombination, and selection? First, let’s consider mutation. Obviously, mutation could mean doubling a line – having a statement execute twice – or removing a line. Mutation could mean making a copy of a variable, or changing an arithmetic expression to be slightly different. Mutation in the real world could mean the organism dies with 100% probability, which in this case would be represented by a syntax error. Since there is little point in keeping around a program with a syntax error, another mutation is unlikely to fix that error, we should make sure mutations always produce a fragment which “compiles”. Runtime errors are probably ok, they will just be selected against heavily.

The real problem posed by mutation is how do we exercise new constructs not represented in our original programs? For example, if we were selecting for a fragment which took two arguments,

{ 'a' => [int], 'b' => [int]}

, and returned the result

{ output => [a ^b] }

, but we started with the hello world program, we’d have a pretty long way to go. We’d somehow have to get the line

"my $a = $_->{'a'};"

, and a similar one for b. We’d somehow have to get the line

"my $result = $a ** $b;"

, but the ‘**’ (binary exponentiation operator) almost never shows up in practice. For now, my solution will be to implement a module which generates random mutations. mutations will affect a random line in the fragment, will have a chance of containing one or more variables mentioned on a previous line with probability proportional to it’s distance away in lines, will have a chance of defining a new variable, will have a chance of containing an arithmetic expression, will have a chance of calling a built-in keyword (shift, pop, push, first, reverse, splice, etc…) with reasonable arguments, will have a chance of creating a loop around the next N lines where N is randomly chosen such that the probability distribution of N is approximately 1/x (big N is less likely). The probabilities of everything in this module should be easy to tweak, and I’m sure I will tweak them. The following parameters should be configurable, at least, along with my “guess” for what the initial value will be:

  • Probability of any mutation happening – 0.01

If a mutation occurs:

  • Probability of a line being repeated – 0.15
  • Probability of a line being removed – 0.15
  • Probability of inserting a random generated line – 0.70

If a random line is generated:

  • Probability a built-in is called – 0.10
  • Probability a new variable is defined – 0.10
  • Probability of a new loop being added over the next N lines – 0.10
  • Probability one or more existing variables are referenced – 0.70

If previous variables are referenced:

  • Probability a variable is incremented or decremented – 0.10
  • Probability a variable is assigned to – 0.10
  • Probability an arithmetic expression is assigned to – 0.10

Any time a random expression is needed:

  • Probability expression is ‘1′ – 0.20
  • Probability expression is ‘0′ – 0.20
  • Probability expression is ‘undef’ – 0.20
  • Probability expression is a previously mentioned variable – 0.20
  • Probability expression is [expr1] [op] [expr2] where op is a random binary operator and expr1 and expr2 are randomly generated expressions – 0.10
  • Probability expression is [expr1] [op] or [op] [expr1] where op is a random unary operator and expr1 is a randomly generated expression – 0.05
  • Probability expression is [expr1] [op] [expr2] [op] [expr3] where [op] is a random trinary operator and expr1, expr2, expr3 are randomly generated expressions – 0.05

Ok, now that nasty mutation is out of the way, we have our next difficult task to design: Sexual Recombination. In humans, every human has two genes, and each offspring gets one of the two from each parent, making for only 4 combinations on each gene. The problem is, the basic unit of programming in Perl is the statement, but there is no clear way to make statements in two programs “line up” in a way that will make sense. If an offspring gets a line which references a variable from parent A, but not the line which declares such a variable, bam, syntax error – stillborn fragment. How do we combine two fragments in a meaningful way?

I’m afraid the simplest way is to “do it a lot” with small chunks, and hope the correct things randomly get selected over time. For example, instead of combining two programs into one program made up of equal parts of the two parents, the “best” parent will be copied, then a random chunk of the “second best” parent will be added to the copy, and the copy may or may not have a similar sized chunk of it removed to “make room”. For example:

my $fragmentA = 'my $args = shift; my $a = $args->{\'first\'}; my $b = $args->{\'second\'}; my $result = $a + $b; return { \'result\' => $result };';
my $fragmentB = 'my $args = shift; my $a = 5; my $b = $args->{\'first\'} + $a; return { \'first\' => $b, \'second\' => $a };';

Here you can see program A is a simple program which returns the sum of arguments “first” and “second”. Program B is a simple program which takes one argument and returns (”5+first”, 5). Now imagine they were combined, and statement 4 of program B was randomly put into program A before the last statement:

my $fragmentA = 'my $args = shift; my $a = $args->{\'first\'}; my $b = $args->{\'second\'}; my $result = $a + $b; return { \'first\' => $b, \'second\' => $a }; return { \'result\' => $result };';

The last statement is now ignored and the function of this fragment has totally changed. It now reverses the arguments passed to it – it is a simple swap() function! The chances of any random sexual combination like that happening “just right” is pretty small, so we will have to make sure this is tried a LARGE number of times.

For those keeping score, we now have “not-even-psuedo-code” solutions, as I like to call them, for two of our big three problems. The remaining problem is selection – how do I “select” fragments of code – how do I compare one to another? Each algorithm I am trying to develop is going to have to have certain tests to “guide” the selection index towards what we want – but there are some general aspects of a fragment which are universal too.

  • Like all good code – shorter is better. For two fragments which otherwise perform identically, but for which one fragment is shorter than the other in code length, the shorter one should win – but for two fragments where one significantly outperforms the other, the less efficient/correct one should always loose out, no matter how short it is.
  • If you try to evaluate code with a syntax error, it dies the same way a runtime error dies. It’d be nice to make a syntax error a “worse problem”, something we select against more strongly than code which sometimes gets runtime errors, but generally either of these conditions are something to select against.
  • Obviously, another “external test” we can do is track runtime. An algorithm which runs more quickly is preferred to one which is slow. As with length, correctness is far more important than runtime, but correctness and other factors being equal, faster runtime should win.
  • Simpler code is also better code – all other things being equal, code with fewer deeply nested scopes, fewer branch/goto statements, or fewer statements, should be preferred.
  • If an easy way can be found to detect memory footprint, smaller footprint should be selected for as well.

Obviously, besides external generic metrics to select against, we need some problem-specific metrics.

  • If the fragment is supposed to use arguments to accomplish its task, then the initial programs should read in the arguments and any program which doesn’t use/read all of the arguments should be selected against.
  • If the fragment is supposed to return certain results, then the initial programs should return undefined, but vivified arguments for those results, and any program which doesn’t return a hash with those arguments at least vivified should be selected against.
  • Any fragment which returns the correct “type” of data should be selected for. (I.E. a number where you expect a number)
  • Any fragment which returns something “close” to the correct answer should be selected for – for each expected output there should be some way to compare answers to expected and a weighted score should be possible which improves as the fragments return closer to the correct results.

Well, I mostly wanted to get my ideas written down before I started trying to implement this mess. Hopefully this post accomplishes that and organized my thoughts a bit. Now, to the implementation grind! =)

Powered by WordPress