第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

將密度曲線擬合成R中的直方圖

將密度曲線擬合成R中的直方圖

慕森卡 2019-07-09 10:45:20
將密度曲線擬合成R中的直方圖R中是否有與直方圖擬合曲線的函數(shù)?假設(shè)你有下面的直方圖hist(c(rep(65, times=5), rep(25, times=5), rep(35, times=10), rep(45, times=4)))它看起來很正常,但它是傾斜的。我想要擬合一個(gè)正常的曲線,是傾斜的,圍繞這個(gè)直方圖。這個(gè)問題是相當(dāng)基本的,但我似乎無法在互聯(lián)網(wǎng)上找到R的答案。
查看完整描述

3 回答

?
一只萌萌小番薯

TA貢獻(xiàn)1795條經(jīng)驗(yàn) 獲得超7個(gè)贊

如果我正確理解了您的問題,那么您可能需要一個(gè)密度估計(jì)和直方圖:

X <- c(rep(65, times=5), rep(25, times=5), rep(35, times=10), rep(45, times=4))hist(X, prob=TRUE)            
# prob=TRUE for probabilities not countslines(density(X))            
 # add a density estimate with defaultslines(density(X, adjust=2), lty="dotted")   
 # add another "smoother" density

稍后編輯很長時(shí)間:

下面是一個(gè)稍微打扮一下的版本:

X <- c(rep(65, times=5), rep(25, times=5), rep(35, times=10), rep(45, times=4))hist(X, prob=TRUE, col="grey")
# prob=TRUE for probabilities not countslines(density(X), col="blue", lwd=2)
 # add a density estimate with defaultslines(density(X, adjust=2), lty="dotted", col="darkgreen", lwd=2)


查看完整回答
反對 回復(fù) 2019-07-09
?
慕后森

TA貢獻(xiàn)1802條經(jīng)驗(yàn) 獲得超5個(gè)贊

這樣的事情用ggplot 2很容易。

library(ggplot2)dataset <- data.frame(X = c(rep(65, times=5), rep(25, times=5), 
                            rep(35, times=10), rep(45, times=4)))ggplot(dataset, aes(x = X)) + 
  geom_histogram(aes(y = ..density..)) + 
  geom_density()

或者模仿Dirk的解的結(jié)果

ggplot(dataset, aes(x = X)) + 
  geom_histogram(aes(y = ..density..), binwidth = 5) + 
  geom_density()


查看完整回答
反對 回復(fù) 2019-07-09
?
慕沐林林

TA貢獻(xiàn)2016條經(jīng)驗(yàn) 獲得超9個(gè)贊

我就是這樣做的:

foo <- rnorm(100, mean=1, sd=2)hist(foo, prob=TRUE)curve(dnorm(x, mean=mean(foo), sd=sd(foo)), add=TRUE)

一個(gè)額外的練習(xí)就是用ggplot 2軟件包來做這件事.。


查看完整回答
反對 回復(fù) 2019-07-09
  • 3 回答
  • 0 關(guān)注
  • 1162 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號