I'm trying to solve a equation and find the value for x
from it. I'm using the following code:
mu1 = 0
mu2 = 1
sigma1 = 0.5
sigma2 = 0.6
prior1 = 0.3
prior2 = 0.7
boundary = function(x) {
return(( 1 / sqrt(2 * pi * sigma1)) * exp(-0.5 * ((x - mu1) / sigma1)^2)*prior1) -
((1 / sqrt(2 * pi * sigma2)) * exp(-0.5 * ((x - mu2) / sigma2)^2)*prior2)
}
uniroot(boundary, c(-1e+05, 1e+07))
This does not give me correct answers. I'm pretty new to R and am not sure exactly how uniroot
works.
- Is there a better way to solve this equation?
- Are there any packages available to solve this (similar to MATLAB's
solve()
function)?