• Post Reply Bookmark Topic Watch Topic
  • New Topic

Next step to building an equation/correlation between variables?  RSS feed

 
Marius Semeon
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I built a super simple simulation program to model genetic drift of a starting population of heterozygotes (A1/A2). You can change the variables starting population and number of matings/generations the simulation it runs for. It then outputs the allelic frequencies of A1 and A2 at the end. It's fun to play with the variables and see how quickly one allele is driven to extinction by completely random mating, but I would like to then use this data to build some kind of correlation for the average amount drift occurs depending on starting population size and number of generations. My knowledge of probability and mathematics in general is very limited unfortunately so I don't have a clue how to go about it.
Thought it would be too long to paste the code here so here is a link to it on pastebin if your interested (i'm new to coding so it's probably very poorly designed but it works).

Cheers for any advice/help
 
Campbell Ritchie
Marshal
Posts: 56578
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is probably better to post code here because many people are reluctant to click links.
I hope you started by working out what the algorithm was.
 
Marius Semeon
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ah ok didn't realise that. I'll post it bellow, but I actually think I need to familiarise myself more with probability theory before being able to continue

 
Norm Radder
Rancher
Posts: 2240
28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One problem I see in the posted code is the use of the == operator to compare String values.  You need to use the equals() method to compare the contents of String object.
 
Campbell Ritchie
Marshal
Posts: 56578
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would suggest you use an enum for gender rather than a char.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!