To compute kernel density estimate and plot for a given dataset using specified kernel types and parameters.


out = cmlmtKernelDensity(dataset, c0)
  • dataset (string) – Name of the GAUSS dataset.

  • c0 (struct) –

    Instance of cmlmtKernelDensityControl structure with detailed configuration.


    Kx1 string array, names of selected columns for density estimation.


    Kx1 vector specifying the type of kernel used for each parameter. Options include NORMAL (1), EPAN (2), BIWGT (3), TRIANG (4), RECTANG (5), and TNORMAL (6). A scalar value applies the same kernel to all parameters. Default: NORMAL.


    Scalar defining the number of points to compute for plots.


    Kx2 matrix specifying lower and upper endpoints of density for each parameter. A 1x2 matrix applies the same endpoints to all parameters. Defaults to the minimum and maximum of parameter values.


    Smoothing coefficients for the density estimation, applicable as a Kx1 vector, Nx1 vector, or NxK matrix. A scalar value applies the same coefficient across plots. Default: 0 (automatic calculation).


    Kx2 matrix or 1x2 matrix specifying lower and upper truncation limits for the TNORMAL kernel. Defaults to minimum and maximum values respectively.


out (struct) –

An instance of the cmlmtKernelDensityResults structure.


c0.NumPointsx1 vector, abscissae for the density plot.

c0.NumPointsx1 vector, ordinates for the density plot.

Smoothing coefficients used, returned as Kx1, NxK, or Nx1, based on input configuration.


library cmlmt;

// Specify the dataset
dataset = getGAUSSHome("pkgs/cmlmt/examples/cmlmttobit.dat");

// Initialize the control structure with default settings
struct cmlmtKernelDensityControl c0;
c0 = cmlmtKernelDensityControlCreate();

// Customize the control structure
c0.varNames = "Y";

// Use normal kernel
c0.Kernel = 1;

// Number of points
c0.NumPoints = 100;

// Endpoints
c0.EndPoints = {-3 3};

// Let the function compute the smoothing coefficient
c0.Smoothing = 0;

// Compute the kernel density estimate and plot
struct cmlmtKernelDensityResults out;
out = cmlmtKernelDensity(dataset, c0);


  • The function generates kernel density plots of the selected parameters using the specified configurations. This method is useful for visualizing the distribution of parameters or data points within a dataset.