Displaying 2 results from an estimated 2 matches for "sum_prob".
2017 Aug 24
1
Problem in optimization of Gaussian Mixture model
...want to run it on n number of segments
latter*
and xnorm is simply calculating the dnorm
*xnorm*=function(param, opt = rep(NA, 2)){
if (any(!sapply(opt, is.na))) {
i = !sapply(opt, is.na)
# Fix non-NA values
param[i] <- opt[i]
}
xval= param[1]
seg <- param[2]
sum_prob=0
val=0
l=3
meanval=c(506.8644, 672.8448, 829.902)
sigmaval=c(61.02859, 9.149168, 74.84682)
coeffval(0.1241933, 0.6329082, 0.2428986)
for(n in 1 :l)
{
mu=meanval[seg,n]
sg=sigmaval[seg,n]
cval=coeffval[seg,n]
val=cval*(dnorm(xval,mu,sg))
#print(paste0("The...
2017 Aug 10
1
"Help On optim"
...represent the 2 segment*
*parametersDf #which I have posted above*
*xnorm= function(x)*
*{ *
* #observation= append(segment1, segment2)*
* mu.vector = parametersDf[1:l] *
* var.vector =parametersDf[(l+1):((2*l))]*
* coeff.vector=parametersDf[(2*l+1):(3*l)]*
* val_df=data.frame()*
* sum_prob=0*
* for (j in 1:l){*
*
val=(coeff.vector[i,j]*(dnorm(x,mu.vector[i,j],sqrt(var.vector[i,j]))))*
* sum_prob=sum_prob+val*
* } *
* return(sum_prob)*
*}*
*#segment1*
*val1=optim(parametersDf$mean_mc_1[1],** fn=xnorm,*
* method = "BFGS")*
*I am not getting righ...