analistica/ex-7/plot.py

27 lines
606 B
Python
Raw Normal View History

2020-03-06 02:24:32 +01:00
#!/usr/bin/env python
from pylab import *
import sys
w = loadtxt(sys.stdin, max_rows=2)
cut = float(input())
n, m, d = map(int, input().split())
data = loadtxt(sys.stdin).reshape(n + m, d)
signal, noise = data[:n].T, data[n:].T
figure()
scatter(*signal, c='xkcd:grey blue', label='signal')
scatter(*noise, c='xkcd:baby blue', label='noise')
scatter(*(cut * w/np.dot(w,w)), c='red')
arrow(*(-abs(w)), *4*abs(w))
legend()
figure()
sig_proj = np.dot(w, signal)
noise_proj = np.dot(w, noise)
hist(sig_proj, color='xkcd:grey blue')
hist(noise_proj, color='xkcd:baby blue')
axvline(cut, c='r')
show()