Introduction to Theory of Evolution in Python
The process of inheritance involves the transmission of characteristics from one generation to another in the form of genes. These genes actually have DNA which is the coded information about the characteristics. Due to inheritance, evolution takes place from one species to another. So we can conclude that evolution is a random process as it does not happen at one go but involves millions of years to happen. For example, it took millions of years to evolve from amoeba to Homosapien(human beings).
The randomness attached to this process of evolution can be simulated. We will simulate this model in a very different way. Actually we can simulate and see, how evolution happened. In fact, there is a model of the ‘Genetic algorithm‘ in which it learns how the amoeba has evolved to Homosapien’s. So to understand the concept, here we will not use this algorithm because it will become much complicated to understand for beginners.
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning - Basic Level Course
So to understand the concept of evolution, we will take a very large binary number containing only zeroes then we will convert all the zeroes to ones randomly using the random library. You will be shocked to get the result that after some time all the zeroes will be converted to ones.
The time taken to convert every zero to ones will be based on the
- length of the string
- The probability with which we convert zeroes to ones
Below is the implementation. Let’s suppose the process of evolution takes 500 times.
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1]