2020-03-06 02:24:32 +01:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
|
|
|
from pylab import *
|
|
|
|
import sys
|
|
|
|
|
2020-03-07 18:48:27 +01:00
|
|
|
def line(x, y, **args):
|
|
|
|
'''line between two points x,y'''
|
|
|
|
plot([x[0], y[0]], [x[1], y[1]], **args)
|
|
|
|
|
2020-04-28 23:30:12 +02:00
|
|
|
rcParams['font.size'] = 12
|
2020-03-06 02:24:32 +01:00
|
|
|
w = loadtxt(sys.stdin, max_rows=2)
|
2020-03-07 18:48:27 +01:00
|
|
|
v = array([[0, -1], [1, 0]]) @ w
|
2020-03-06 02:24:32 +01:00
|
|
|
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()
|
2020-03-07 18:48:27 +01:00
|
|
|
subplot(aspect='equal')
|
2020-04-28 23:30:12 +02:00
|
|
|
scatter(*signal, edgecolor='xkcd:charcoal',
|
|
|
|
c='xkcd:dark yellow', label='signal')
|
|
|
|
scatter(*noise, edgecolor='xkcd:charcoal',
|
|
|
|
c='xkcd:pale purple', label='noise')
|
|
|
|
line(-20*w, 20*w, c='xkcd:midnight blue', label='projection')
|
|
|
|
line(w-10*v, w+10*v, c='xkcd:scarlet', label='cut')
|
2020-03-07 18:48:27 +01:00
|
|
|
xlim(-1.5, 8)
|
|
|
|
ylim(-1.5, 8)
|
2020-04-28 23:30:12 +02:00
|
|
|
legend()
|
|
|
|
tight_layout()
|
2020-03-06 02:24:32 +01:00
|
|
|
|
|
|
|
figure()
|
|
|
|
sig_proj = np.dot(w, signal)
|
|
|
|
noise_proj = np.dot(w, noise)
|
2020-04-28 23:30:12 +02:00
|
|
|
hist(sig_proj, color='xkcd:dark yellow', label='signal')
|
|
|
|
hist(noise_proj, color='xkcd:pale purple', label='noise')
|
|
|
|
axvline(cut, c='xkcd:scarlet')
|
|
|
|
legend()
|
|
|
|
tight_layout()
|
|
|
|
|
2020-03-06 02:24:32 +01:00
|
|
|
show()
|