thi = 3
def meyerw():
f = 4*cos(pi*x)/(1-4*x^2)
f += 8*cos(4*pi*x)/(1-16*x^2)
f += 24*x*sin(2*pi*x)/(1-16*x^2)/(1-4*x^2)
F = f(x = 2/3*(x+1/2) )/3/pi
return F
def pls_mew():
f = meyerw()
P = plot(f, -4,3, thickness= thi)
P.set_aspect_ratio(1)
P.fontsize(15)
P.save("./images/mewp.png")
def pl_gen(j,K):
f = meyerw()
P = point([(0,0)], size = 0)
for k in srange(-K,K+2):
ff = f( x= 2^j*x-k )*2^(j/2)
P += plot(ff, x, -4,3)
P.fontsize(15)
return P
def pla_gen():
for j in srange(-3,3):
P = pl_gen(j, 50)
fname = './images/memhgen'+str(abs(j))
if j<0: fname += 'm'
P.save(fname+'.png', figsize = [4,4])
def pls_mh():
mh = (1-x^2)*exp(-x^2/2)/sqrt(2*pi)
P = plot(mh, -8,8, thickness= 3)
P.set_aspect_ratio(10)
P.fontsize(15)
P.save("./images/mexh.png")
def plo_bh2(F, a,b):
h = (b-a)/350
L = []
ti = walltime()
f = 4*cos(pi*x)/(1-4*x^2)
f += 8*cos(4*pi*x)/(1-16*x^2)
f += 24*x*sin(2*pi*x)/(1-16*x^2)/(1-4*x^2)
for t in srange(a+1e-7, b+1e-7, h):
S = 0.0
for item in F:
S += (
item[2]*2^(item[0]/2)*f(x = 2/3*(2^item[0]*t-item[1]+1/2) ) ).n()
L.append( (t, (S/3/pi).n()) )
P = list_plot(L, plotjoined= True, color='red')
print '-----------'
print 'plottime =', walltime(ti)
print '-----------'
return P
def meymh(J,K, a, b, ff):
L = []
ncoef = 0
for j in srange(-J,J+1):
for k in srange(-K,K+2):
s =
numerical_integral(meyerw()*2^(-j/2)*ff(x = (x+k)/2^j), -oo,oo,
max_points=500)
r = s[0]
if abs(s[0])>s[1]:
L.append( (j,k,r) )
print j,k,'->', r, s
ncoef += 1
print '-----------'
print 'J =',J,' K =',K, ' ncoef =',ncoef
P = plo_bh2( L, a,b)
P += plot(ff, x, a,b, color='green')
P.set_aspect_ratio(9)
P.fontsize(15)
return P
def to_four():
ff = (1-x^2)*exp(-x^2/2)/sqrt(2*pi)
for jj in srange(5):
P = meymh( jj, 60 , -8,8, ff )
P.save('./images/memh0'+str(jj)+'15.png')
def to_fourl():
ff = (1-x^2)*exp(-x^2/2)/sqrt(2*pi)
for jj in srange(5):
P = meymh( jj, 1 , -8,8, ff )
P.save('./images/memh0'+str(jj)+'l.png')
###################################################
pls_mew()
pla_gen()
pls_mh()
to_four()
to_fourl()
|