2012-08-15 33 views
1

我試圖找到一個紅寶石的t分佈實現,所以我可以繪製一個具有一定的均值,標準差和自由度的圖。不完全確定,如果這是有道理的,任何幫助將不勝感激。紅寶石實現t分佈

+0

[發現這個有點谷歌foo](https://github.com/clbustos/distribution/blob/master/lib/distribution/t/ruby.rb) – Kyle 2012-08-15 03:32:45

+1

從來沒有使用過它,但我聽說R語言是對統計信息很有用,這裏有一個ruby界面:https://sites.google.com/a/ddahl.org/rinruby-users/ – DGM 2012-08-15 04:04:11

回答

1

我不得不第二個DGM關於使用R和Rinruby的評論。 Rinruby是太棒了,因爲你可以直接輸入R命令進入ruby :)你只需要確保你在你的系統上安裝了R之後再使用它。如果你想看到在行動t分佈(安裝R和Rinruby寶石後)只是以下內容粘貼到IRB:

require 'rinruby' 

R.eval <<EOF 
x <- seq(-4, 4, length=100) 
hx <- dnorm(x) 

degf <- c(1, 3, 8, 30) 
colors <- c("red", "blue", "darkgreen", "gold", "black") 
labels <- c("df=1", "df=3", "df=8", "df=30", "normal") 

plot(x, hx, type="l", lty=2, xlab="x value", 
    ylab="Density", main="Comparison of t Distributions") 

for (i in 1:4){ 
    lines(x, dt(x,degf[i]), lwd=2, col=colors[i]) 
} 

legend("topright", inset=.05, title="Distributions", 
    labels, lwd=2, lty=c(1, 1, 1, 1, 2), col=colors) 
EOF 

希望這可以幫助您開始。我應該注意到,我最近不需要做t分發,所以我無恥地從一些R文檔中偷走了R代碼。