forked from kr-colab/discoal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathalleleTrajTest.c
47 lines (39 loc) · 1.04 KB
/
alleleTrajTest.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include "alleleTraj.h"
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include "ranlib.h"
#include <unistd.h>
#include <fcntl.h>
unsigned long devrand(void);
#define MAXTRAJ 10000000
void createTrajectory(int N,double alpha,double dt, double *currentTrajectory);
int main (int argc, const char * argv[]) {
double freq, t, dt, N, alpha, s;
int i,j;
double sum = 0;
long seed1, seed2;
double *currentTraj;
seed1 = (long) (devrand() % 2147483399);
seed2 = (long) (devrand() % 2147483399);
setall(seed1, seed2 );
currentTraj = malloc(sizeof(double) * MAXTRAJ);
N = 20000;
dt = 1.0 / (400.0 * N);
s = 0.0002;
alpha = 2*N*s;
createTrajectory(N,alpha,dt,currentTraj);
i=0;
while(currentTraj[i] > (1.0/(2*N))){
printf("%lf\n",currentTraj[i++]);
}
printf("%d\n",i);
}
void createTrajectory(int N,double alpha,double dt, double *currentTrajectory){
float freq = ((2*N) - 1.0) / (2*N) ;
int i=0;
while(freq > (1.0/(2*N))){
freq = 1.0 - genicSelectionStochasticForwards(dt, (1.0 - freq), alpha);
currentTrajectory[i++]= freq;
}
}