You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: calcDensity.m
    path of file: ./repos/mtex/tools/statistic_tools
    
    the code of the file until where you have to start completion: function [f,bandwidth] = calcDensity(x,varargin)
% kernel density estimation from real valued data
%
% Syntax
%   f = calcDensity(x)
%   f = calcDensity(x,'range',[xmin;xmax])
%
%   f = calcDensity([x,y],'range',[xmin,ymin;xmax,ymax])
%   f = calcDensity([x,y,z],'range',[xmin,ymin,zmin;xmax,ymax,zmax])
%
% Input
%  x,y,z - random samples as n x 1 vectors
% 
% Output
%  f - density as <https://de.mathworks.com/help/matlab/ref/griddedinterpolant.html griddedinterpolant>
%
% See also

    
function [f,bandwidth] = calcDensity(x,varargin)
% kernel density estimation from real valued data
%
% Syntax
%   f = calcDensity(x)
%   f = calcDensity(x,'range',[xmin;xmax])
%
%   f = calcDensity([x,y],'range',[xmin,ymin;xmax,ymax])
%   f = calcDensity([x,y,z],'range',[xmin,ymin,zmin;xmax,ymax,zmax])
%
% Input
%  x,y,z - random samples as n x 1 vectors
% 
% Output
%  f - density as <https://de.mathworks.com/help/matlab/ref/griddedinterpolant.html griddedinterpolant>
%
% See also
% vector3d/calcDensity orientation/calcDensity

if check_option(varargin,'periodic')

  f = calcS1Density(x,varargin{:});
  return
end