def plot_rect_images(f, xlo, dx, xhi, ylo, dy, yhi, do_horiz=1, do_vert=1, do_input=0, do_output=1): xs = kerlutil.mfrange(xlo, dx, xhi) ys = kerlutil.mfrange(ylo, dy, yhi) for rep in [0, 1]: for x in xs: x1 = x x2 = x + dx for y in ys: y1 = y y2 = y + dy if (do_input and (rep == 0)): print x1, y1, x2, y1 print x1, y1, x1, y2 elif (do_output and (rep == 1)): [u11, v11] = xy2uv(f, x1, y1) [u12, v12] = xy2uv(f, x1, y2) [u21, v21] = xy2uv(f, x2, y1) [u22, v22] = xy2uv(f, x2, y2) print u11, v11, u12, v12 print u11, v11, u21, v21
def plot_circ_images(f, rlo, dr, rhi, tlo, dt, thi, center=0+0j, do_horiz=1, do_vert=1, do_input=0, do_output=1): rs = kerlutil.mfrange(rlo,dr,rhi) ts = kerlutil.mfrange(tlo,dt,thi) for rep in [0, 1]: for r in rs: r1 = r r2 = r+dr for t in ts: t1 = t t2 = t+dt [x11, y11] = rt2xy(r1, t1, center) [x12, y12] = rt2xy(r1, t2, center) [x21, y21] = rt2xy(r2, t1, center) [x22, y22] = rt2xy(r2, t2, center) if (do_input and (rep == 0)): print x11, y11, x21, y21 print x11, y11, x12, y12 elif (do_output and (rep == 1)): [u11, v11] = xy2uv(f, x11, y11) [u12, v12] = xy2uv(f, x12, y12) [u21, v21] = xy2uv(f, x21, y21) [u22, v22] = xy2uv(f, x22, y22) print u11, v11, u12, v12 print u11, v11, u21, v21
def do_2D(): T = 10.0 dt = 0.01 ts = kerlutil.mfrange(0, dt, T) nt = len(ts) # Brownian motion. # Run this first to find out what B(T) turns out to be. Bts = [] for t in ts: Bt = B2(t, dt) Bts.append(Bt) BT = Bts[-1] # Brownian bridge: R(t) = B(t) - (t/T) B(T). Rts = [] for i in range(0, nt): t = ts[i] Bt = Bts[i] Rt = [ Bt[0] - (t/T) * BT[0], Bt[1] - (t/T) * BT[1] ] Rts.append(Rt) for i in range(0, nt): t = ts[i] Bt = Bts[i] Rt = Rts[i] #print "%11.6f %11.6f %11.6f" % (t, Bt[0], Bt[1]) print "%11.6f %11.6f %11.6f" % (t, Rt[0], Rt[1])
def do_2D(): T = 10.0 dt = 0.01 ts = kerlutil.mfrange(0, dt, T) nt = len(ts) # Brownian motion. # Run this first to find out what B(T) turns out to be. Bts = [] for t in ts: Bt = B2(t, dt) Bts.append(Bt) BT = Bts[-1] # Brownian bridge: R(t) = B(t) - (t/T) B(T). Rts = [] for i in range(0, nt): t = ts[i] Bt = Bts[i] Rt = [Bt[0] - (t / T) * BT[0], Bt[1] - (t / T) * BT[1]] Rts.append(Rt) for i in range(0, nt): t = ts[i] Bt = Bts[i] Rt = Rts[i] #print "%11.6f %11.6f %11.6f" % (t, Bt[0], Bt[1]) print "%11.6f %11.6f %11.6f" % (t, Rt[0], Rt[1])
def plot_circ_images(f, rlo, dr, rhi, tlo, dt, thi, center=0 + 0j, do_horiz=1, do_vert=1, do_input=0, do_output=1): rs = kerlutil.mfrange(rlo, dr, rhi) ts = kerlutil.mfrange(tlo, dt, thi) for rep in [0, 1]: for r in rs: r1 = r r2 = r + dr for t in ts: t1 = t t2 = t + dt [x11, y11] = rt2xy(r1, t1, center) [x12, y12] = rt2xy(r1, t2, center) [x21, y21] = rt2xy(r2, t1, center) [x22, y22] = rt2xy(r2, t2, center) if (do_input and (rep == 0)): print x11, y11, x21, y21 print x11, y11, x12, y12 elif (do_output and (rep == 1)): [u11, v11] = xy2uv(f, x11, y11) [u12, v12] = xy2uv(f, x12, y12) [u21, v21] = xy2uv(f, x21, y21) [u22, v22] = xy2uv(f, x22, y22) print u11, v11, u12, v12 print u11, v11, u21, v21
def plot_rect_images(f, xlo, dx, xhi, ylo, dy, yhi, do_horiz=1, do_vert=1, do_input=0, do_output=1): xs = kerlutil.mfrange(xlo,dx,xhi) ys = kerlutil.mfrange(ylo,dy,yhi) for rep in [0, 1]: for x in xs: x1 = x x2 = x+dx for y in ys: y1 = y y2 = y+dy if (do_input and (rep == 0)): print x1, y1, x2, y1 print x1, y1, x1, y2 elif (do_output and (rep == 1)): [u11, v11] = xy2uv(f, x1, y1) [u12, v12] = xy2uv(f, x1, y2) [u21, v21] = xy2uv(f, x2, y1) [u22, v22] = xy2uv(f, x2, y2) print u11, v11, u12, v12 print u11, v11, u21, v21
from __future__ import division # 1/2 = 0.5, not 0. import betapdf_m import kerlutil import sys alpha = 2.0 beta = 3.0 nx = 500 # ---------------------------------------------------------------- # Parse the command line. Syntax: not -nx 400 but nx=400. # This is crude (it's not syntax-error tolerant) but it's an easy-to-code # hack. It works in any language with an eval/exec (e.g. Python, Perl). argc = len(sys.argv) for argi in range(1, argc): if (sys.argv[argi] == "-h") or (sys.argv[argi] == "--help"): print >> sys.stderr, "Usage: %s [nx=...] [alpha=...] [beta=...]" % (sys.argv[0]) sys.exit(1) exec (sys.argv[argi]) # ---------------------------------------------------------------- dx = 1.0 / nx denom = betapdf_m.betapdfdenom(alpha, beta) for x in kerlutil.mfrange(dx, dx, 1.0): if x >= 1.0: break # print "%.10f %.10f" % (x, betapdf_m.betapdf(x, alpha, beta)) print "%.10f %.10f" % (x, betapdf_m.betapdfaux(x, alpha, beta, denom))
from __future__ import division # 1/2 = 0.5, not 0. import betapdf_m import kerlutil import sys alpha = 2.0 beta = 3.0 nx = 500 # ---------------------------------------------------------------- # Parse the command line. Syntax: not -nx 400 but nx=400. # This is crude (it's not syntax-error tolerant) but it's an easy-to-code # hack. It works in any language with an eval/exec (e.g. Python, Perl). argc = len(sys.argv) for argi in range(1, argc): if ((sys.argv[argi] == '-h') or (sys.argv[argi] == '--help')): print >> sys.stderr, "Usage: %s [nx=...] [alpha=...] [beta=...]" \ % (sys.argv[0]) sys.exit(1) exec(sys.argv[argi]) # ---------------------------------------------------------------- dx = 1.0 / nx denom = betapdf_m.betapdfdenom(alpha, beta) for x in kerlutil.mfrange(dx, dx, 1.0): if (x >= 1.0): break #print "%.10f %.10f" % (x, betapdf_m.betapdf(x, alpha, beta)) print "%.10f %.10f" % (x, betapdf_m.betapdfaux(x, alpha, beta, denom))
#!/usr/bin/python -Wall from __future__ import division from kerlutil import mfrange from cmath import sqrt ab_s = mfrange(-3.0, 0.02, 3.0) for a in ab_s: for b in ab_s: # z^2 - a z - b D = a**2 + 4*b sqrt_D = sqrt(D) root1 = (a + sqrt_D) * 0.5 root2 = (a - sqrt_D) * 0.5 if abs(root1) < 1.0 and abs(root2) < 1.0: print a, b
#!/usr/bin/python -Wall from __future__ import division from kerlutil import mfrange from cmath import sqrt ab_s = mfrange(-3.0, 0.02, 3.0) for a in ab_s: for b in ab_s: # z^2 - a z - b D = a**2 + 4 * b sqrt_D = sqrt(D) root1 = (a + sqrt_D) * 0.5 root2 = (a - sqrt_D) * 0.5 if abs(root1) < 1.0 and abs(root2) < 1.0: print a, b