两片正态(或分裂正态)分布的密度 [英] Density of a Two-Piece Normal (or Split Normal) Distribution
问题描述
两件式正态分布是否具有密度函数:
Is there a density function for the two-piece Normal distribution:
吗?我以为我会在编写一个代码之前先检查一下。我已经检查了分发任务视图。此处未列出。我查看了一些可能的软件包,但无济于事。
on CRAN? Thought I would check before I code one. I have checked the distribution task view. It is not listed there. I have looked in a couple of likely packages, but to no avail.
更新:我添加了 dsplitnorm
, psplitnorm
, qsplitnorm
和 rsplitnorm
函数对 fanplot 包。
Update: I have added dsplitnorm
, psplitnorm
, qsplitnorm
and rsplitnorm
functions to the fanplot package.
推荐答案
如果您选择构建自己的发行版,则可能对 distr 感兴趣。它(以及相关的软件包 distrEx , distrSim , distrTEst , distrTeach 和 distrDoc )已被编写出来,以提供一个统一的界面,用于从现有分布中构建新的分布。 (我在 distrDoc 包随附的精美小插图的帮助下构造了这个示例,可以通过键入 vignette( distr)
。)
If you choose to construct your own version of the distribution, you might be interested in distr. It (and the related packages distrEx, distrSim, distrTEst, distrTeach and distrDoc) have been written to provide a unified interface for constructing new distributions from existing ones. (I constructed this example with the help of the wonderful vignette that accompanies the distrDoc package and which can be gotten by typing vignette("distr")
.)
这实现了分割正态分布,可能与您所追求的不完全相同。不过,使用 distr 工具集,对其进行调整以适应您的实际需求并不难。
This implements the split normal distribution, which may not be exactly what you are after. Using the distr toolset, though, it shouldn't be too hard to adjust this to fit your exact needs.
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")
这篇关于两片正态(或分裂正态)分布的密度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!