umz21/lab/generate_data6.py
2021-03-02 08:32:40 +01:00

18 lines
375 B
Python

#! /usr/bin/env python3
# -*- coding: utf-8 -*-
import numpy as np
import matplotlib.pyplot as plt
x = np.random.rand(20) * 200
d = np.random.normal(size=20) * 500
y = 0.1 * x**2 + 0.9 * x + 3 + d
np.set_printoptions(suppress=True, precision=3)
plt.scatter(x, y)
plt.show()
data = np.vstack((x, y)).T
print(data)
np.savetxt('data6.tsv', data, delimiter='\t', fmt='%.3f')