Return to menu
Can Enough Spelling Mistakes Produce a Coherent Sentence?By: Mike GashlerIn silly attempts to refute the theory of evolution, Creationists keep posting claims on social media that mistakes are always deleterious, and can only degrade things. Let's test this, shall we? Here is a quick little Python script I threw together to roughly simulate something like Darwinian evolution: import random letters = ' abcdefghijklmnopqrstuvwxyz' target = 'spelling mistakes can write a coherent sentence' population = [ ' ' * len(target) for _ in range(50) ] print(f'population size={len(population)}, chromosome length={len(target)}') def fitness(s:str) -> int: score = 0 for i in range(len(target)): if s[i] == target[i]: score += 1 return score for time in range(2 ** 22 + 1): # Do a tournament between two random individuals a = random.randrange(len(population)) b = random.randrange(len(population)) if random.uniform(0, 1) < 0.1: # Kill off a random individual c = a else: # Kill the less-fit individual fitness_a = fitness(population[a]) fitness_b = fitness(population[b]) c = a if fitness_a < fitness_b else b # Replace the dead individual with a new baby crossover_point = random.randrange(len(target)) a = random.randrange(len(population)) b = random.randrange(len(population)) population[c] = population[a][:crossover_point] + population[b][crossover_point:] # Randomly mutate the new baby position = random.randrange(len(target)) mistake = letters[random.randrange(len(letters))] population[c] = population[c][:position] + mistake + population[c][position + 1:] # Display a random member of the population on at a logarithmic time scale if time & (time - 1) == 0: print(f'time={time:8d}, sample= {population[random.randrange(len(population))]}') As you can see, that is not a lot of code. So don't be scared. You can understad this. And here is the output it generates: population size=50, chromosome length=47 time= 0, sample= time= 1, sample= time= 2, sample= time= 4, sample= time= 8, sample= time= 16, sample= k time= 32, sample= time= 64, sample= g time= 128, sample= o time= 256, sample= zn i q g x h time= 512, sample= e na fi h cg o ume j time= 1024, sample= c ey na fi q cg le u qo ument a z h time= 2048, sample= u e nk fist n ecg le q fo ument dp t q time= 4096, sample= et eng uis akes caq w le a co ument entua e time= 8192, sample= spelling sdsbakes caw wri z a cow rent sentewje time= 16384, sample= spelling riyrakes can write a cohernnt sentxnce time= 32768, sample= spelling mistakes can wriqe a coheoent santence time= 65536, sample= spelling mi taked can write ascocerent sentence time= 131072, sample= spelling mittakes zan write a coherent sentence time= 262144, sample= spellins mistakes cqn wrqte a cokeafxt sejtenoe time= 524288, sample= speulint mistakeskcan writp a coherent semtence time= 1048576, sample= spelking mistakes oab writi l coherent sentence time= 2097152, sample= spelling mistakes cayfwbite a coherent siftenca time= 4194304, sample= sqelyixg mistakes can write a cohqrent sentence If you want to test this for yourself, here are some steps:
Of course, my script is not nearly as complex as nature. My script uses much smaller populations. It lacks the parallelism of nature. And I only ran it for a few minutes. So nature is not nearly as limited as this silly little script. Also, my script had a very specific goal. That is, I measured fitness by comparing against a very specific string of letters. Nature is not like that. There are lots of niches where diverse creatures can thrive. So we would expect there to be lots more diversity in populations that occur in nature. And besides, my script didn't even perfectly achieve its goal within the brief time it took to execute. Furthermore, I used a set of 27 characters. Nature uses only 4. (...or 64, if you consider codons rather than nucleotides.) And I used a set chromosome length of 47. Nature seems to work with all sorts of chromosome lengths, most significantly longer than 47 nucleotides. Also, nature certainly isn't as rigorous as my script about maintaining a stable population size by birthing exactly one creature every time one creature dies. Nature is way more loosey-goosey about how things work. So if you don't like the theory of evolution, please feel free to latch on to whichever of these differences seems significant to you. But frankly, I struggle to understand what people think is so incomprehensible about the theory of evolution. It's not a very complicated process. Perhaps, a lot of people who don't understand it just don't want to understand it. ...or maybe they just don't know how to code in Python. Maybe the world just needs to learn to code.
|