1
$\begingroup$

I am making a program to simulate evolution. In my program I have creatures whose properties are defined by an ordered set of 8 genes like this (each gene defines the probability of moving in one of the eight directions):

(3, 54, 2, 45, 2, 1, 1, 12) 

In the program, the creatures evolve by slight mutations in their genes over time. Each mutation changes the value of a randomly selected gene by $\pm 1$ or leaves it as it is.

Now I wanted to categorize the creatures into different species so I took the standard deviation of the genes of the first creature $\sigma_0$ (whose genes were randomly allocated). I defined relative deviation $\sigma_r$ of any creature by dividing its standard deviation $\sigma$ by $\sigma_0$ :

$\sigma_r = \frac{\sigma}{\sigma_0}$

Now I categorized the creatures based on their $\sigma_r$ value, for example if $\sigma_r$ lied between 0-1 then called all those creatures as of one type, or one 'species'.

This method works somewhat but it is not accurate, for example if two creatures have the following gene sets :

(1, 1, 3, 4, 15, 20, 21, 3) and (3, 21, 20, 15, 4, 3, 1, 1) 

then according to my method they will be put under the same category as they have exactly same $\sigma$ but in reality they will behave completely different.

So is their any way by which I can accurately categorize them ?

$\endgroup$

1 Answer 1

1
$\begingroup$

Use the sum of squared differences. The resulting metric will be 0 if and only if all genes are the same between two individuals. And it will be larger the more genes differ (and by a larger magnitude).

Genes of individual $i$ are represented by a vector $r_i\in\mathbb{R}^N$ of length $N$. For example, $r_i=(1,4,6,4..)$.

To compute the sum of squared differences between individual $i$ and $j\neq i$, you first take the difference $r_i-r_j$, which takes the difference by element. Then you square each element. Finally you sum up all of these squares.

In vector notation, what you do is $(r_i-r_j)\cdot (r_i-r_j)'$.

$\endgroup$

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.