Skip to content

Commit 0550780

Browse files
committed
minor cleanup
1 parent 3c5b6fc commit 0550780

3 files changed

Lines changed: 6 additions & 6 deletions

File tree

C/mcmc_fun/MHMCMC/MCMC_FUN/STEP_AFDEMCMC.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ double STEP_AFDEMCMC(double *PARS, double *pars_new, PARAMETER_INFO PI, int C, i
1111
/* Step 1. Find random sample (reference chain) other than current chain */
1212
C1=C;
1313
while (C1==C){
14-
C1 = ceil((double)random() * NC / ((double)RAND_MAX)) - 1;
14+
C1 = floor((double)random() * NC / ((double)RAND_MAX + 1.0));
1515
}
1616

1717
// /* Step 2. Allocate memory for normalized parameter vectors */

C/mcmc_fun/MHMCMC/MCMC_FUN/STEP_DEMCMC.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ int withinlim=1;
2727

2828
/*first: pick c1 and c2, make sure that (a) they are between 1 and NC, and (b) they are not C*/
2929
c1=C;c2=C;
30-
while (c1==C | c2==C | c1==c2){
31-
c1=ceil((double)random()*NC/((double)RAND_MAX))-1;
32-
c2=ceil((double)random()*NC/((double)RAND_MAX))-1;}
30+
while (c1==C || c2==C || c1==c2){
31+
c1=floor((double)random() * NC / ((double)RAND_MAX + 1.0));
32+
c2=floor((double)random() * NC / ((double)RAND_MAX + 1.0));}
3333
mstep=0;
3434
/*SAMPLING PARAMETERS*/
3535
for (n=0;n<PI.npars;n++){
@@ -42,7 +42,7 @@ mstep=0;
4242

4343

4444
npar[n]=npar[n]+step[n];
45-
if (npar[n]<0 | npar[n]>1){withinlim=0;}
45+
if (npar[n]<0 || npar[n]>1){withinlim=0;}
4646

4747
}
4848

C/mcmc_fun/MHMCMC/MCMC_FUN/WRITE_DEMCMC_RESULTS.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ int WRITE_DEMCMC_RESTART(double *PARS,PARAMETER_INFO PI,MCMC_OPTIONS MCO, int IT
9090
FAILONERROR(nc_def_dim(ncid,"Sample",NC_UNLIMITED,&sampleDimID));
9191
FAILONERROR(nc_def_var(ncid,"Parameters",NC_DOUBLE,2,(const int[]){sampleDimID,paramDimID},&parsVarID));
9292
//Note: it's a bit odd this is an int, and not a uint or long. Likely does not matter though.
93-
FAILONERROR(nc_put_att_int(ncid,parsVarID,"N",NC_INT,sizeof(int),&ITER));
93+
FAILONERROR(nc_put_att_int(ncid,parsVarID,"N",NC_INT,1,&ITER));
9494

9595

9696
//TODO: store N and rng seed ------------------------------------------------------

0 commit comments

Comments
 (0)