r - 两片正态(或 split 正态)分布的密度

标签 r statistics distribution cran

两件式正态分布是否有密度函数:

enter image description here

在 CRAN 上?以为我会在编写代码之前检查一下。我已经检查了分发任务 View 。它没有在那里列出。我查看了几个可能的包,但无济于事。

更新:我添加了 dsplitnorm , psplitnorm , qsplitnormrsplitnorm函数到 fanplot包裹。

最佳答案

如果您选择构建您自己的发行版本,您可能会对 感兴趣。地区 .它(以及相关的软件包 distrEx , distrSim , distrTEst , distrTeach Doc)已写入 distr为从现有发行版构建新发行版提供统一的界面。 (我在 distrDoc 软件包附带的精彩插图的帮助下构建了这个示例,可以通过键入 vignette("distr") 获得。)

这实现了 split normal distribution ,这可能不是您所追求的。使用 地区 工具集,但是,调整它以适应您的确切需求应该不会太难。

library(distr)

## Construct the distribution object.
## Here, it's a split normal distribution with mode=0, and lower- and
## upper-half standard deviations of 1 and 2, respectively.
splitNorm <- UnivarMixingDistribution(Truncate(Norm(0,2), upper=0), 
                                      Truncate(Norm(0,1), lower=0), 
                                      mixCoeff=c(0.5, 0.5))
## Construct its density function ...
dsplitNorm <- d(splitNorm)
## ... and a function for sampling random variates from it
rsplitNorm <- r(splitNorm)

## Compare the density it returns to that from rnorm()
dsplitNorm(-1)
# [1] 0.1760327    
dnorm(-1, sd=2)
# [1] 0.1760327    

## Sample and plot a million random variates from the distribution
x <- rsplitNorm(1e6)         
hist(x, breaks=100, col="grey")

## Plot the distribution's continuous density
plot(splitNorm, to.draw.arg="d") 

enter image description here

enter image description here

关于r - 两片正态(或 split 正态)分布的密度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16064639/

相关文章:

用列表中的 NA 替换连续的重复值

r - 如何根据面板数据的客户 ID 使用 R 中的中值插补为所有列填充缺失值?

ios - Xcode 4/iOS如何为另一家公司在App Store中分发应用程序?

python - 从任意多元函数中高效采样

iphone - 推送通知不适用于分发

r - 如何按 R 中的分组列求和?

r - 扩展 R 中的内存大小限制

algorithm - 如何保持动态直方图?

python - Python中两个比例之间差异的置信区间

python - 显示多个汇总统计表