C7: transforming a truncated gaussian with regular and irregular spacing
C7: transforming a truncated gaussian with regular and irregular spacing
We first transform a regularly-spaced sampled Gaussian using the inverse transform.
%%% prelim
l1=@(xprime) 1./xprime; Ebase=-10.5:10.5; Tbase=-10:10;
Lt=length(Tbase); t=linspace(Ebase(1),Ebase(end),450);
load pfnfile
pt=out.p(t); mt=out.p(Tbase);
Tshift=Tbase+15; Eshift=Ebase+15; tshift=t+15;
%%% plot original Gaussian
figure(5); clf; hold on
plot(tshift,pt,'-','Color',.7*[1 1 1],'LineWidth',2.2)
plot(Eshift(1)*[1 1],[0 mt(1)],'k--','LineWidth',.75);
for n=1:(Lt),
try plot((Eshift(n+1))*[1 1],[0 max(mt(n:n+1))],'k--','LineWidth',.75); end
plot((Eshift(n:n+1)),mt(n)*[1 1],'k-','LineWidth',2.25);
plot((Tshift(n)),mt(n),'ko','MarkerFaceColor','k','MarkerSize',9); end
axis([3 27 0 .03]);
%%% plot transformed Gaussian
figure(6); clf; hold on
%mt=mt./max(mt);
%plot(l1(Tshift),mt,'ko','MarkerFaceColor','k','MarkerSize',7);
[PCout]=pTX(tshift,pt,l1); PCout(:,1)=PCout(:,1)/max(PCout(:,1));
plot(PCout(:,2),PCout(:,1),'-','Color',.7*[1 1 1],'LineWidth',4)
[PCout]=pTX(Tshift,mt,l1); PCout(:,1)=PCout(:,1)/max(PCout(:,1));
for n=1:(Lt),
plot(l1(Eshift(n:n+1)),PCout(end-n+1,1)*[1 1],'k-','LineWidth',2.25); end
plot(l1(Eshift(1))*[1 1],[0 mt(1)],'k--','LineWidth',.75);
for n=1:(Lt),
try plot(l1(Eshift(n+1))*[1 1],[0 max(PCout(end-[n:n+1]+1,1))],'k--','LineWidth',.75); end, end
axis([0.03 .24 0 1.05]);
Then we perform this transform with an irregularly-spaced sampling of the same Gaussian.
%%% prelim
t=[-10.5 10.5];
ts=linspace(t(1),t(2),450); tplot=ts+15;
Lt=11; dmean=diff(t)/Lt;
dEprime=rand(Lt-1,1)*dmean+dmean/2;
Eprime=[t(1); t(1)+cumsum(dEprime); t(2)]; Eplot=Eprime+15;
Xprime=[]; m=[]; for n=2:length(Eprime),
Xprime(n-1)=mean(Eprime(n-1:n));
m(n-1)=out.p(Xprime(n-1))*diff(Eprime(n-1:n)); end
Xplot=Xprime+15;
%%% plot original Gaussian
figure(5); clf; hold on
plot(Xplot,m,'ko','MarkerFaceColor','k','MarkerSize',11)
plot(tplot,out.p(ts),'-','Color',[.7 .7 .7],'LineWidth',2.6)
for n=1:length(Xprime),
plot(Xplot(n)*[1 1],[0 m(n)],'k-')
plot(Eprime(n:n+1)+15,out.p(Xprime(n))*[1 1],'k-','LineWidth',2.1); end
%%% transform
l1=@(xprime) 1./xprime; m=m/max(m);
pmx=pTX(Xplot,m,l1); pmx=pmx/max(pmx); pex=pTX(Eplot,out.p(Eprime),l1); pex(:,1)=pex(:,1)/max(pex(:,1));
%%% plot transformed Gaussian
figure(6); clf; hold on
PCout=pTX(tplot,out.p(ts),l1); PCout(:,1)=PCout(:,1)/max(PCout(:,1));
plot(PCout(:,2),PCout(:,1),'-','Color',[.7 .7 .7],'LineWidth',2.6)
PCout=pTX(Xplot,out.p(Xprime),l1); PCout(:,1)=PCout(:,1)/max(PCout(:,1));
for n=1:length(Xplot),
plot(l1(Xplot(n))*[1 1],[0 m(n)],'k-'); plot(l1(Xplot(n)),m(n),'ko','MarkerFaceColor','k','MarkerSize',11);
plot(l1(Eplot(n))*[1 1],[0 PCout(end-n+1,1)],'k:','LineWidth',.05);
plot(l1(Eplot(n+1))*[1 1],[0 PCout(end-n+1,1)],'k:','LineWidth',.05);
plot(l1(Eplot(n:n+1)),PCout(end-n+1,1)*[1 1],'k-','LineWidth',2.1); end
axis([0.03 .24 0 1.05]);