Home > wafo > kdetools > mkernelrnd.m

mkernelrnd

PURPOSE ^

Random numbers from the Multivariate Kernel Function.

SYNOPSIS ^

R=mkernelrnd(kernel,N,D)

DESCRIPTION ^

  MKERNELRND Random numbers from the Multivariate Kernel Function. 
    
  CALL:  R = mkernelrnd(kernel,N,D); 
  
    R      = random samples from kernel, size N X D 
    kernel = 'epa1'          - product of 1D Epanechnikov kernel.  
             'gaussian'      - Gaussian kernel 
   N,D     = size of random sample 
   Note that only the first 4 letters of the kernel name is needed. 
  
  See also  kde, kdefun, kdebin

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

001 function R=mkernelrnd(kernel,N,D) 
002 % MKERNELRND Random numbers from the Multivariate Kernel Function. 
003 %   
004 % CALL:  R = mkernelrnd(kernel,N,D); 
005 % 
006 %   R      = random samples from kernel, size N X D 
007 %   kernel = 'epa1'          - product of 1D Epanechnikov kernel.  
008 %            'gaussian'      - Gaussian kernel 
009 %  N,D     = size of random sample 
010 %  Note that only the first 4 letters of the kernel name is needed. 
011 % 
012 % See also  kde, kdefun, kdebin 
013    
014 %  Reference:   
015 %  B. W. Silverman (1986)  
016 % 'Density estimation for statistics and data analysis'   
017 %  Chapman and Hall, pp. 143  
018 %   
019 %  Wand, M. P. and Jones, M. C. (1995)  
020 % 'Density estimation for statistics and data analysis'   
021 %  Chapman and Hall,  
022  
023 %Tested on: matlab 5.3 
024 % History: 
025 % revised pab  sep2005 
026 % replaced reference to kdefft with kdebin 
027 % revised pab Dec 2003 
028 %  -removed    
029 % Revised by gl 13.07.2000 
030 %    changed call to wnormrnd 
031 % By pab 01.12.1999 
032  
033 % TODO % Add more kernels   
034 %            'epanechnikov'  - Epanechnikov kernel.  
035 %            'biweight'      - Bi-weight kernel. 
036 %            'biw1'          - product of 1D Bi-weight kernel. 
037 %            'triweight'     - Tri-weight kernel.   
038 %            'triangular'    - Triangular kernel. 
039 %            'rectangular'   - Rectangular kernel.  
040 %            'laplace'       - Laplace kernel. 
041 %            'logistic'      - Logistic kernel.  
042 switch lower(kernel(1:4)) 
043 case 'epa1', % 1D product kernel 
044    V1=-1+2*rand(N,D);V2=-1+2*rand(N,D);R=-1+2*rand(N,D); 
045    k=find(abs(R)>=abs(V2) & abs(R) >= abs(V1)); 
046    if any(k) 
047     R(k)=V2(k); 
048    end   
049 case {'gaus', 'norm'} 
050    R=wnormrnd(0,1,N,D); 
051 otherwise , error('Not known or not implemented') 
052 end 
053

Mathematical Statistics
Centre for Mathematical Sciences
Lund University with Lund Institute of Technology

Comments or corrections to the WAFO group


Generated on Thu 06-Oct-2005 02:21:16 for WAFO by m2html © 2003