In [ ]:
%pylab

In [ ]:
f = lambda x: 5 * sin(6 * x) + 3 * sin(2 * x) + 7
x = linspace(0, 10, 1000)
y = f(x)

plot(x,y)

In [11]:
cos(1 / 3 * pi)


Out[11]:
0.50000000000000011

In [14]:
NUM_POINTS = int(1e5)
rect_width = 10
rect_height = 14

rand_x = lambda: random.uniform(0, rect_width)
rand_y = lambda: random.uniform(0, rect_height)

points = [(rand_x(), rand_y()) for i in range(NUM_POINTS)]
points_under = filter(lambda point: point[1] <= f(point[0]), points)
points_above = list(set(points) - set(points_under))
# print(list(points_under), list(points_above))

# Separate x's and y's to pass to scatter function.
under_x, under_y = zip(*points_under)
over_x, over_y = zip(*points_above)

fig = plt.figure()
fig.set_size_inches(12, 8)
_ = scatter(under_x, under_y, s=1, color='red')
_ = scatter(over_x, over_y, s=1, color='green')


-----------------------------------------------------------
ValueError                Traceback (most recent call last)
<ipython-input-14-eb34cee97028> in <module>()
     12 
     13 # Separate x's and y's to pass to scatter function.
---> 14 under_x, under_y = zip(*points_under)
     15 over_x, over_y = zip(*points_above)
     16 

ValueError: not enough values to unpack (expected 2, got 0)

In [ ]: