# -*- coding: utf-8 -*-
"""
Created on Fri Sep  9 09:59:13 2022

@author: Chris
Lab7_Q6
"""


import numpy as np
import matplotlib.pyplot as plt
from scipy.stats import qmc

    
def region(x,y):
    return x**2+y**2<1**2

a,b = -1,1

#generate uniform distribution
N = 256
p = a+(b-a)*np.random.uniform(size=[N,2])

#generate Sobol sequence
M = 8
sampler = qmc.Sobol(d=2) # set up the sequence
p = a+(b-a)*sampler.random_base2(M) #generate 2^M points


#p = a + (b-a)*qmc.Sobol(d=2, scramble=False)

xp, yp = p[:,0],p[:,1]

plt.plot(xp,yp,'x')
plt.gca().set_aspect('equal', adjustable='box')

xr = xp*region(xp,yp)
yr = yp*region(xp,yp)

#plt.plot(xr,yr,'or')
