File:Kernel density estimation, comparison between rule of thumb and solve-the-equation bandwidth.png
Kernel_density_estimation,_comparison_between_rule_of_thumb_and_solve-the-equation_bandwidth.png (733 × 561 pixels, file size: 28 KB, MIME type: image/png)
Captions
Summary[edit]
DescriptionKernel density estimation, comparison between rule of thumb and solve-the-equation bandwidth.png |
This file has no description, and may be lacking other information.
Please provide a meaningful description of this file. |
Date | |
Source |
This diagram was created with MATLAB. |
Author | Kernel estimator |
This graph image could be re-created using vector graphics as an SVG file. This has several advantages; see Commons:Media for cleanup for more information. If an SVG form of this image is available, please upload it and afterwards replace this template with
{{vector version available|new image name}} .
It is recommended to name the SVG file “Kernel density estimation, comparison between rule of thumb and solve-the-equation bandwidth.svg”—then the template Vector version available (or Vva) does not need the new image name parameter. |
The Matlab script for this example uses kde.m and is given below.
% Data
randn('seed',1) % Used for reproducibility
data = [randn(100,1)-10; randn(100,1)+10]; % Two Normals mixed
% True
phi = @(x) exp(-.5*x.^2)/sqrt(2*pi); % Normal Density
tpdf = @(x) phi(x+10)/2+phi(x-10)/2; % True Density
% Kernel
h = std(data)*(4/3/numel(data))^(1/5); % Bandwidth estimated by Silverman's Rule of Thumb
kernel = @(x) mean(phi((x-data)/h)/h); % Kernel Density
kpdf = @(x) arrayfun(kernel,x); % Elementwise application
% Plot
figure(2), clf, hold on
x = linspace(-25,+25,1000); % Linear Space
plot(x,tpdf(x)) % Plot True Density
plot(x,kpdf(x)) % Plot Kernel Density with Silverman's Rule of Thumb
kde(data) % Plot Kernel Density with Solve-the-Equation Bandwidth
#The same code with R language
#` Data
set.seed(1) #Used for reproducibility
data = c(rnorm(100,-10,1),rnorm(100,10,1)) #Two Normals mixed
#` True
phi = function(x) exp(-.5*x^2)/sqrt(2*pi) #Normal Density
tpdf = function(x) phi(x+10)/2+phi(x-10)/2 #True Density
#` Kernel
h = sd(data)*(4/3/length(data))^(1/5) #Bandwidth estimated by Silverman's Rule of Thumb
Kernel2 = function(x) mean(phi((x-data)/h)/h) #Kernel Density
kpdf = function(x) sapply(x,Kernel2) #Elementwise application
#` Plot
x=seq(-25,25,length=1000) #Linear Space
plot(x,tpdf(x),type="l",ylim=c(0,0.23),col="red") #Plot True Density
par(new=T)
plot(x,kpdf(x),type="l",ylim=c(0,0.23),xlab="",ylab="",axes=F) #Plot Kernel Density with Silverman's Rule of Thumb
Licensing[edit]
This file is made available under the Creative Commons CC0 1.0 Universal Public Domain Dedication. | |
The person who associated a work with this deed has dedicated the work to the public domain by waiving all of their rights to the work worldwide under copyright law, including all related and neighboring rights, to the extent allowed by law. You can copy, modify, distribute and perform the work, even for commercial purposes, all without asking permission.
http://creativecommons.org/publicdomain/zero/1.0/deed.enCC0Creative Commons Zero, Public Domain Dedicationfalsefalse |
Original upload log[edit]
Transferred from en.wikipedia to Commons using For the Common Good.
Date/Time | Dimensions | User | Comment |
---|---|---|---|
15:47, 19 April 2016 | 733 × 561 (28,809 bytes) | w:en:Kernel estimator (talk | contribs) | author: kernel estimator source: created by kernel estimator using the Matlab code on Wikipedia URL: N/A |
File history
Click on a date/time to view the file as it appeared at that time.
Date/Time | Thumbnail | Dimensions | User | Comment | |
---|---|---|---|---|---|
current | 20:39, 26 October 2018 | 733 × 561 (28 KB) | Jumpow (talk | contribs) | Transferred from en.wikipedia: see original upload log above |
You cannot overwrite this file.
File usage on Commons
The following page uses this file:
- File:Wikipedia kde.png (file redirect)
File usage on other wikis
The following other wikis use this file:
- Usage on en.wikipedia.org
- Usage on es.wikipedia.org
- Usage on ru.wikipedia.org
Metadata
This file contains additional information such as Exif metadata which may have been added by the digital camera, scanner, or software program used to create or digitize it. If the file has been modified from its original state, some details such as the timestamp may not fully reflect those of the original file. The timestamp is only as accurate as the clock in the camera, and it may be completely wrong.
Horizontal resolution | 37.8 dpc |
---|---|
Vertical resolution | 37.8 dpc |
File change date and time | 13:05, 15 April 2016 |
Software used | |
Date and time of digitizing |
|