Commit 87c27433 authored by sebastien's avatar sebastien
Browse files

v4 kernel_density_estimate.m: replaced calls to inline() by anonymous functions (much faster)


git-svn-id: https://www.dynare.org/svn/dynare/dynare_v4@1871 ac1d8469-bf42-47a9-8791-bf33cf982152
parent 974fb1ba
......@@ -39,19 +39,19 @@ end
%% Kernel specification.
if strcmpi(kernel_function,'gaussian')
kernel = inline('inv(sqrt(2*pi))*exp(-0.5*x.^2)');
kernel = @(x) inv(sqrt(2*pi))*exp(-0.5*x.^2);
elseif strcmpi(kernel_function,'uniform')
kernel = inline('0.5*(abs(x) <= 1)');
kernel = @(x) 0.5*(abs(x) <= 1);
elseif strcmpi(kernel_function,'triangle')
kernel = inline('(1-abs(x)).*(abs(x) <= 1)');
kernel = @(x) (1-abs(x)).*(abs(x) <= 1);
elseif strcmpi(kernel_function,'epanechnikov')
kernel = inline('0.75*(1-x.^2).*(abs(x) <= 1)');
kernel = @(x) 0.75*(1-x.^2).*(abs(x) <= 1);
elseif strcmpi(kernel_function,'quartic')
kernel = inline('0.9375*((1-x.^2).^2).*(abs(x) <= 1)');
kernel = @(x) 0.9375*((1-x.^2).^2).*(abs(x) <= 1);
elseif strcmpi(kernel_function,'triweight')
kernel = inline('1.09375*((1-x.^2).^3).*(abs(x) <= 1)');
kernel = @(x) 1.09375*((1-x.^2).^3).*(abs(x) <= 1);
elseif strcmpi(kernel_function,'cosinus')
kernel = inline('(pi/4)*cos((pi/2)*x).*(abs(x) <= 1)');
kernel = @(x) (pi/4)*cos((pi/2)*x).*(abs(x) <= 1);
end
%% Non parametric estimation (Gaussian kernel should be used (FFT)).
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment