Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Constructing a probability histogram for p(y)

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

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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?

>Solution :

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)

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading