R 語言中的 density() 函數用於計算核密度估計。
用法: density(x)
參數:
x:數字向量
範例1:
# R program to illustrate
# density function
# Generating 10 numbers randomly
x <- stats::rnorm(10)
# Getting 10 random number
x
# Calling density() function
d <- density(x)
# Getting kernel density estimates
d
輸出:
[1] -0.89243190 -0.76257379 1.17066825 0.09418077 1.08321504 -0.41264708 [7] 0.39009942 0.69991113 -0.82339069 -0.68621705 Call: density.default(x = x) Data:x (10 obs.); Bandwidth 'bw' = 0.4594 x y Min. :-2.2706 Min. :0.001546 1st Qu.:-1.0657 1st Qu.:0.047506 Median:0.1391 Median:0.243764 Mean :0.1391 Mean :0.207189 3rd Qu.:1.3440 3rd Qu.:0.312477 Max. :2.5488 Max. :0.434704
範例2:
# R program to illustrate
# density function
# Generating number 1 to 10
x <- seq(1, 10)
x
# Calling density() function
d <- density(x)
# Getting kernel density estimates
d
輸出:
[1] 1 2 3 4 5 6 7 8 9 10 Call: density.default(x = x) Data:x (10 obs.); Bandwidth 'bw' = 1.719 x y Min. :-4.1579 Min. :0.0003034 1st Qu.:0.6711 1st Qu.:0.0092711 Median:5.5000 Median:0.0538486 Mean :5.5000 Mean :0.0517052 3rd Qu.:10.3289 3rd Qu.:0.0936045 Max. :15.1579 Max. :0.0997741
相關用法
- R語言 dunif()用法及代碼示例
- R語言 rf()用法及代碼示例
- R語言 dchisq()用法及代碼示例
- R語言 pchisq()用法及代碼示例
- R語言 dcauchy()用法及代碼示例
- R語言 pcauchy()用法及代碼示例
- R語言 rchisq()用法及代碼示例
- R語言 plogis()用法及代碼示例
- R語言 dlogis()用法及代碼示例
- R語言 rlnorm()用法及代碼示例
- R語言 plnorm()用法及代碼示例
- R語言 rcauchy()用法及代碼示例
- R語言 qchisq()用法及代碼示例
- R語言 dlnorm()用法及代碼示例
- R語言 rlogis()用法及代碼示例
- R語言 dnbinom()用法及代碼示例
- R語言 pnbinom()用法及代碼示例
- R語言 dpois()用法及代碼示例
- R語言 rnbinom()用法及代碼示例
注:本文由純淨天空篩選整理自Kanchan_Ray大神的英文原創作品 Getting Kernel Density Estimates in R Programming – density() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。