Home > database >  Constructing a probability histogram for p(y)
Constructing a probability histogram for p(y)

Time:07-01

I am having some difficulty plotting the probability histogram for the table below

y 1 2 3 4

p(y) 0.4 0.3 0.2 0.1

I've tried the command: hist(p <- c(0.4, 0.3, 0.2, 0.1), y <- c(1, 2, 3, 4), main = "Frequency Histogram") but it didn't work. Is there a way for this to construct the probability histogram?

CodePudding user response:

p <- setNames(c(0.4, 0.3, 0.2, 0.1), 1:4); barplot(p)

Created on 2022-06-30 by the reprex package (v2.0.1)

  • Related