Created
January 29, 2010 15:08
-
-
Save artagnon/289780 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
normalize <- function (m) { | |
result <- m | |
for (r in 1:dim (m)[1]) { | |
avg <- mean (m [r,], na.rm=TRUE) | |
variance <- var (m [r,], na.rm=TRUE) | |
result [r,] <- result [r,] - avg | |
result [r,] <- result [r,] / sqrt (variance) | |
} | |
return (result) | |
} | |
main <- function(normalizep) { | |
data <- read.table("data.res", header=TRUE) | |
x <- data$x | |
if (normalizep) | |
data.norm <- normalize (t(data[2:dim(data)[2]])) | |
else | |
data.norm <- t(data[2:dim(data)[2]]) | |
iter.num <- c (1:dim(data.norm)[1]) | |
iter.pch <- c ('x', 'o', '^', '*', '~') | |
matplot(x, t(data.norm), col=iter.num, pch=iter.pch, xlab="Scattering angle (°)", ylab="Scatter intensity (µV) (normalized)") | |
for (i in iter.num) { | |
y <- data.norm[i,] | |
y.gauss <- glm.fit(x, y, family=gaussian()) | |
lines(spline(x, y.gauss$y), col=i) | |
} | |
} | |
main(1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment