加载中…
个人资料
  • 博客等级:
  • 博客积分:
  • 博客访问:
  • 关注人气:
  • 获赠金笔:0支
  • 赠出金笔:0支
  • 荣誉徽章:
正文 字体大小:

rnorm()

(2018-09-10 22:31:40)
分类: Analytics

> x = rnorm(100)

> y = factor(rep(1:10,10))

> simple.densityplot(x ~ y)


rnorm.X generates multivariate normal random variates in the space X.

1 > x<-rnorm(100)       #产生100个服从正态分布的随机数


1 > x<-rnorm(100,3,4      #产生100个均值是3,标准差为4的随机数

正态分布函数中的纵坐标y表示什么


分布的比例,横坐标表示状态值
比如考试成绩的正态分布图,横坐标就是成绩,棕坐标就是这个分数段的人大概比例是多少
f(x) is the density function of the random variable X.

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 and standard deviation equal to 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 length(n) > 1, the length is taken to be the number required.

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 P[X ≤ x] otherwise, P[X > x].



> simple.densityplot(x ~ y)
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

d

0

阅读 收藏 喜欢 打印举报/Report
前一篇:强与弱
  

新浪BLOG意见反馈留言板 欢迎批评指正

新浪简介 | About Sina | 广告服务 | 联系我们 | 招聘信息 | 网站律师 | SINA English | 产品答疑

新浪公司 版权所有