rnorm()
(2018-09-10 22:31:40)| 分类: Analytics |
> x = rnorm(100)
> y = factor(rep(1:10,10))
> simple.densityplot(x ~ y)
rnorm.X 1 > x<-rnorm(100) #产生100个服从正态分布的随机数
1 > x<-rnorm(100,3,4)#产生100个均值是3,标准差为4的随机数
f(x)指的是: 概率问题中的密度函数。
坐标系中的一段x 区间,对y轴对应的f(x)求积分,即得到区间 概率。
也就是曲线与x轴围成的面积啦!
通常用 F(x)表示
概率值,就是上述的面积,当x取得定义域内所有值的时候,F(x)=1.
而F(x)'=f(x).
在R中,概率函数形如①:
其中第一个字母表示其所指分布的某一方面:
d = 密度函数(density)
p = 分布函数(distribution function)
q = 分位数函数(quantile function)
r = 生成随机数(随机偏差)
The Normal Distribution
Description
Density, distribution function, quantile function and random
generation for the normal distribution with mean equal
to mean sd.
Usage
dnorm(x, mean = 0, sd = 1, log = FALSE) pnorm(q, mean = 0, sd = 1, lower.tail = TRUE, log.p = FALSE) qnorm(p, mean = 0, sd = 1, lower.tail = TRUE, log.p = FALSE) rnorm(n, mean = 0, sd = 1)
Arguments
x, q |
vector of quantiles. |
p |
vector of probabilities. |
n |
number of
observations. If |
mean |
vector of means. |
sd |
vector of standard deviations. |
log, log.p |
logical; if TRUE, probabilities p are given as log(p). |
lower.tail |
logical; if TRUE
(default), probabilities are |
| simple.densityplot {UsingR} | R Documentation |
Plots densities of data
Description
Allows one to compare empirical densities of different
distributions in a simple manner. The density is used as graphs
with multiple histograms are too crowded. The usage is similar to
side-by-side boxplots.(Boxplots,
Usage
simple.densityplot(x, ...)
Arguments
x |
x may be a sequence of data vectors (eg. x,y,z), a data frame with numeric column vectors or a model formula |
... |
You can pass in a
bandwidth argument such as bw="SJ". See density for details. A
legend will be placed for you automatically. To overide the
positioning set do.legend="manual". To skip the legend, set
do.legend=FALSE. |
Value
Makes a plot

加载中…