Skip to content

Commit

Permalink
fix java initialization bug with subpop
Browse files Browse the repository at this point in the history
  • Loading branch information
richardli committed Apr 19, 2023
1 parent 4c6efb9 commit 9a2eb17
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
Binary file modified InSilicoVA/inst/java/Insilico.jar
Binary file not shown.
Binary file modified Insilico/out/artifacts/Insilico_jar/Insilico.jar
Binary file not shown.
8 changes: 4 additions & 4 deletions Insilico/src/sampler/InsilicoSampler2.java
Original file line number Diff line number Diff line change
Expand Up @@ -699,22 +699,22 @@ public static double[] Fit(int[] dimensions,
if(!isAdded){
// initialize values
for(int sub = 0; sub < N_sub; sub++){
mu_now[sub] = mu;
for(int c = 0; c < C; c++) mu_now[sub][c] = mu[c];
sigma2_now[sub] = sigma2;
theta_now[sub][0] = 1;
double expsum = Math.exp(1.0);
for(int c = 1; c < C; c++){
theta_now[sub][c] = Math.log(rand.nextDouble() * 100.0);
expsum += Math.exp(theta_now[sub][c]);
}
for(int c = 0; c < C; c++){
for(int c = 0; c < C; c++) {
p_now[sub][c] = Math.exp(theta_now[sub][c]) / expsum;
}
}
}else{
// if the chain is to continue from a previous one, initialize with the _now values imported
for(int sub = 0; sub < N_sub; sub++){
mu_now[sub] = mu_continue[sub];
for(int c = 0; c < C; c++) mu_now[sub][c] = mu_continue[sub][c];
sigma2_now[sub] = sigma2_continue[sub];
theta_now[sub] = theta_continue[sub];
// recalculate p from theta
Expand Down Expand Up @@ -843,7 +843,7 @@ public static double[] Fit(int[] dimensions,
mu_now[sub][c] = mu_mean;
}

// sample sigma2
// sample sigma2
double shape = (C-remove_causes[sub]-1.0)/2;
double rate2 = 0;
for(int c = 0 ; c < C; c++) rate2 += Math.pow(theta_now[sub][c] - mu_now[sub][c] *
Expand Down

0 comments on commit 9a2eb17

Please sign in to comment.