Beispiel #1
0
def serialHMapDistortion2D(s,alpha=0.1,Nsamp=1000):
  D = s.D
  Htrans = s.Htrans
  x = sampleSCrossSD(r0=1.0,r1=0.3,D=D-1,N=Nsamp)  
  tmpx = array(x)
  fig = figure()
  N = Htrans.N
  isqrtN = int(ceil(sqrt(N+1)))
  ax=fig.add_subplot(isqrtN,isqrtN,1)
  ax.scatter(*x.T[:2])
  for i,(h,A) in enumerate(zip(Htrans.H,Htrans.A)):
    tmpx = dot(A,h(tmpx).T).T
    ax=fig.add_subplot(isqrtN,isqrtN,i+2)
    ax.scatter(*tmpx.T[:2])
Beispiel #2
0
def plotHMapEffects(s,alpha=0.1,Nsamp=1000):
  D = s.D
  Htrans = s.Htrans
  cpairs = zip(
    (['r','b','k'][i%3] for i in count(0)),
    zip(xrange(D),[j%D for j in xrange(1,D+1)])
  )
  x = sampleSCrossSD(r0=1.0,r1=0.3,D=D-1,N=Nsamp)
  tmpx = array(x)
  for h,A in zip(Htrans.H,Htrans.A):
    f = h.f
    figure(figsize=(12,12))
    subplot(2,2,1)
    for c,(i,j) in cpairs:
      scatter(tmpx[:,i],tmpx[:,j],alpha=alpha,c=c)
    subplot(2,2,2)
    bt = h.computebtilde(tmpx)
    if bt.shape[1]==1:
      scatter(zeros(bt.shape[0]),bt[:,0],alpha=alpha)
      lnes = f.getEllipse()
      for l in lnes:
        hlines(l,-1,1)
      subplot(2,2,3)
      a = applyAffine(h.ga,tmpx[:,:h.split])
      if a.shape[1]>2:
        scatter(a[:,0],a[:,1],alpha=alpha)
      else:
        scatter(zeros_like(a[:,0]),a[:,0],alpha=alpha)
    else:
      scatter(*bt.T,alpha=alpha)
      plot(*f.getEllipse())
      subplot(2,2,3)
      a = applyAffine(h.ga,tmpx[:,:h.split])
      scatter(zeros(a.shape[0]),a[:,0],alpha=alpha)
    subplot(2,2,4)
    tmpx = h(tmpx)
    for c,(i,j) in cpairs:
      scatter(tmpx[:,i],tmpx[:,j],alpha=alpha,c=c)
    tmpx = dot(A,tmpx.T).T