27 lines
650 B
Python
27 lines
650 B
Python
#!/usr/bin/python3
|
|
# -*- coding:utf-8 -*-
|
|
|
|
|
|
import csv
|
|
import math
|
|
import random
|
|
import sys
|
|
|
|
|
|
def create_bayes_nasty_data(filename):
|
|
with open(filename, 'w') as f:
|
|
writer = csv.writer(
|
|
f, delimiter=('\t' if filename.endswith('.tsv') else ','))
|
|
for i in range(100):
|
|
x = random.uniform(-1.0, 1.0)
|
|
y = random.uniform(-1.0, 1.0)
|
|
p = abs(x-y) / abs(x+y)
|
|
# for i in range(2):
|
|
# p = -2 * p**3 + 3 * p**2
|
|
v = 1 if random.random() > p else 0
|
|
writer.writerow([v, x, y])
|
|
|
|
|
|
if __name__ == '__main__':
|
|
create_bayes_nasty_data(sys.argv[1])
|