简体   繁体   English

R中的密度分布

[英]Density distributions in R

An assignment has tasked us with creating a series of variables: normal1, normal2, normal3, chiSquared1 and 2, t, and F. They are defined as follows: 一项任务使我们不得不创建一系列变量:normal1,normal2,normal3,chiSquared1和2,t和F。它们的定义如下:

library(tibble)
Normal.Frame <- data_frame(normal1 = rnorm(5000, 0, 1), 
    normal2 = rnorm(5000, 0, 1), 
    normal3 = rnorm(5000, 0, 1), 
    chiSquared1 = normal1^2, 
    chiSquared2 = normal2^2, 
    F = sum(chiSquared1/chiSquared2), 
    t = sum(normal3/sqrt(chiSquared1 )))

We then have to make histograms of the distributions for normal1, chiSquared1 and 2, t, and F, which is simple enough for normal1 and the chiSquared variables, but when I try to plot F and t, the plot space is blank. 然后,我们必须对正态1,chiSquared1和2,t和F进行分布的直方图,这对于正态1和chiSquared变量足够简单,但是当我尝试绘制F和t时,绘制空间为空白。

Our lecturer recommended limiting the range of F to 0-10, and t to -5 to 5. To do this, I use: 我们的讲师建议将F的范围限制为0-10,将t的范围限制为-5到5。为此,我使用:

HistT <- hist(Normal.Frame$t, xlim = c(-5, 5))

HistF <- hist(Normal.Frame$F, xlim = c(0, 10))

Like I mentioned, this yields blank plots. 就像我提到的那样,这将产生空白图。

Your t and F are defined as sums; 您的t和F被定义为和。 they will be single values. 它们将是单个值。 If those values are outside your range, the histogram will be empty. 如果这些值超出您的范围,则直方图将为空。 If you remove the sum() function you should get the desired results. 如果删除sum()函数,则应获得期望的结果。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM