Mercurial > repos > nitrozyna > dm1_genotypying
comparison generate_data.py @ 4:d3dbf9e8a0e2 draft
Uploaded
author | nitrozyna |
---|---|
date | Tue, 16 Jan 2018 15:15:20 -0500 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
3:a1cb5223ac36 | 4:d3dbf9e8a0e2 |
---|---|
1 from __future__ import print_function | |
2 import math | |
3 import random | |
4 # that's our x data, i.e. reference | |
5 x = range(1, 101) | |
6 | |
7 # generate a gaussian | |
8 def gaussian(x, amp, cen, wid): | |
9 return amp * math.exp(-(x - cen) ** 2 / wid) | |
10 | |
11 read1 = 18 | |
12 read2 = 66 | |
13 | |
14 # that's our y data, i.e. reads | |
15 y = [int(round(gaussian(i, 20000, read1, 0.5) + gaussian(i, 20000, read2, 0.5) + random.gauss(200, 90))) for i in x] | |
16 | |
17 # that's our data printed in pairs (x_i, y_i) | |
18 with open("input.txt", "w") as f: | |
19 for pair in zip(x, y): | |
20 for p in pair: | |
21 print(p, end="\t", file=f) | |
22 print(file=f) | |
23 | |
24 # you have to set this manually to weed out all the noise. Every bit of noise should be below it. |