I have the following code, where we need to solve for mu and sigma, when we have mut and sdt. Can you suggest how to use a solve function in R to do that? I am new to R and am not sure how to go from defining the functions, to solving for them.
Thanks truncated <- function(x) { mu=x[1]; sigma=x[2]; f <- function(x) (1/(sigma*sqrt(2*pi)))*exp(-(x-mu)^2/(2*sigma^2)); pdf.fun <- function(x) x*f(x); sd.fun <- function(x) (x)^2*f(x); st=integrate(sd.fun,lower=-Inf,upper=1)$value; a=integrate(pdf.fun,lower=-Inf,upper=1)$value; a1=integrate(f,lower=-Inf,upper=1)$value; mut <- a/a1; sdt <- sqrt((st/a1)-(a/a1)^2); } -- View this message in context: http://www.nabble.com/Truncated-normal-distribution-tp14348951p14361967.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ 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.