From: Matt J on 2 Apr 2010 17:28 "Royi Avital" <RoyiREMOVEAvital(a)yahoo.com> wrote in message <hp5los$hfv$1(a)fred.mathworks.com>... > Because it holds only for this example. > Not always the LSF would be a 1D Gaussian function. ============ No. The code I gave you will smoothly (to 1st order) extrapolate a tail that is monotonically decreasing, and non-negative for any function LSF. The tail is exponential, but that is irrelevant. It fulfills all the requirements that you stated. The only assumption of the code is that the samples of LSF are decreasing at the boundary of its domain, but that is the only situation where your requirements can be satisfied, anyway. > For the other idea, If you pay attention that's exactly what I did using SLM. > Yet the result I got has changed the PSF at points which coincident with the LSF. ========= No, from what you described in your post,you applied SLM to the 2D data set PSF, not the 1D data set LSF, as I was suggesting. Here was the line of code, where you passed both r and PSF to slmengine SLMExtPSF = slmengine(r, PSF , 'Decreasing', 'on', 'leftminvalue', 0, 'rightminvalue', 0); Also, a problem in your use of SLM is that you are inputting the entire data set for all r to the fitting routine. Conversely, in the approach I gave you, I exclude data for r<7 from the fit. Only the boundary values of LSF are used. Here is my code again, rewritten in terms of LSF to clarify some of the things in previous posts. You can see that it only uses LSF(end) and LSF(end-1). To extrapolate over negative r, you would pass fliplr(LSF(:).') to the routine function LSFExt=ExtrapLSF(LSF,Rmax) %LSF - input LSF %Rmax - maximum radius in number of samples (default=ceil(r0*sqrt(2))) % where r0 is the maximum radius of given LSF samples. r0=length(LSF); if nargin<2, Rmax=ceil(r0*sqrt(2)); end slope=LSF(end)-LSF(end-1); endval=LSF(end); %fit a tail of the form k*exp(-a*r) a=-slope/endval; k=endval/exp(-a*r0); Tail=@(r) k.*exp(-a.*r) LSFExt=[LSF, Tail(r0+1:Rmax)];
From: Bruno Luong on 3 Apr 2010 05:22 "Matt J " <mattjacREMOVE(a)THISieee.spam> wrote in message <hp5nh4$evu$1(a)fred.mathworks.com>... > > > No. The code I gave you will smoothly (to 1st order) extrapolate a tail that is monotonically decreasing, and non-negative for any function LSF. Note quite smooth Matt. As I understand, you replace the point-wise derivative with a finite difference. This is still an approximation and the interpolation/extrapolation is arguably differentiable (to me it's simply not). The hermit interpolation by padding 0 far-way enough can do better than that (true first order differentiable, and monotonic forced by the data). Bruno
From: Matt J on 3 Apr 2010 08:28
"Bruno Luong" <b.luong(a)fogale.findmycountry> wrote in message <hp71c0$jot$1(a)fred.mathworks.com>... > Note quite smooth Matt. As I understand, you replace the point-wise derivative with a finite difference. This is still an approximation and the interpolation/extrapolation is arguably differentiable (to me it's simply not). > > The hermit interpolation by padding 0 far-way enough can do better than that (true first order differentiable, and monotonic forced by the data). ======= That's true, Bruno, but the OP only asked for it to be "somewhat smooth". Also, if an analytical form is available for LSF (I've been asking the OP repeatedly if it is), my code can easily be modified to use the analytical derivative, in which case it would be truly differentiable. |