Hello,

I have a data set of about 300.000 measurements made by an STM which should
apporximately fix a normal (Gaussian) distribution.
I have imported the data in R and used plot(density()) to get a nice plot of
the distribution which in fact looks like a real Gaussian.
However, the integral over the surface is not equal to one (I know since
some of the plots extend to numbers greater then 1). Is there a way to
normalize the data so the density function will actualy yield the
probability of x (a height in my case)?
This is my code so far:

#Input path
path <- "G:\\C\\Data txt\\1au300.txt"

#Dataverwerking
data <- read.table(path, header=TRUE)
rows <- length(data$height)
height <- data$height[1:rows]
dens <-density(height)

mean <- mean(height)
sd <- sd(height)
min <- min(hnorm)
max <- max(hnorm)

#Plot
par(new=FALSE)
curve(dnorm(x,m=mean,sd=sd),from=min,to=max, xlab="", ylab="", col="white",
lwd=2)
points(dens, type="h", col="grey" )
par(new=TRUE)
curve(dnorm(x,m=mean,sd=sd),from=min,to=max, xlab="Height (nm)",
ylab="Density", lwd=2, col="darkred")


Thanks

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to