0

I have created a histogram by reading binary data in R from a file. I am trying to generate a normal Gaussian curve fit to the histogram values but I am only able to generate a curve varying with the peak value of histogram at each point. I am sorry if this is a very basic question but I am just new to R. I have also tried to generate it with the help of other answers but was not successful. I have written the following code:

a <- file('binarydata','rb')
f <- readBin(a, double(), n=1000, size=4, endian='little')
h <- hist(f, breaks=10, plot=FALSE)
h$counts=h$counts/sum(h$counts)
plot(h, xlim=c(1,100), ylim(0,1))
lines(density(f), col="black")
Rok
  • 3
  • 5

1 Answers1

0

lines(density(rnorm(1000,mean=mean(f),sd = sd(f))),col=1,lwd=3)

Nightwriter
  • 514
  • 5
  • 11