/********************* void WtCDSample Using the parameters contained in the array theta, obtain the network statistics for a sample of size samplesize. burnin is the initial number of Markov chain steps before sampling anything and interval is the number of MC steps between successive networks in the sample. Put all the sampled statistics into the networkstatistics array. *********************/ WtMCMCStatus WtCDSample(WtMHproposal *MHp, double *theta, double *networkstatistics, int samplesize, int *CDparams, Vertex *undotail, Vertex *undohead, double *undoweight, int fVerbose, WtNetwork *nwp, WtModel *m, double *extraworkspace){ /********************* networkstatistics are modified in groups of m->n_stats, and they reflect the CHANGE in the values of the statistics from the original (observed) network. Thus, when we begin, the initial values of the first group of m->n_stats networkstatistics should all be zero *********************/ /*for (j=0; j < m->n_stats; j++) */ /* networkstatistics[j] = 0.0; */ /* Rprintf("\n"); */ /* for (j=0; j < m->n_stats; j++){ */ /* Rprintf("j %d %f\n",j,networkstatistics[j]); */ /* } */ /* Rprintf("\n"); */ int staken=0; /* Now sample networks */ unsigned int i=0, sattempted=0; while(i<samplesize){ if(WtCDStep(MHp, theta, networkstatistics, CDparams, &staken, undotail, undohead, undoweight, fVerbose, nwp, m, extraworkspace)!=WtMCMC_OK) return WtMCMC_MH_FAILED; #ifdef Win32 if( ((100*i) % samplesize)==0 && samplesize > 500){ R_FlushConsole(); R_ProcessEvents(); } #endif networkstatistics += m->n_stats; i++; sattempted++; } if (fVerbose){ Rprintf("Sampler accepted %7.3f%% of %d proposed steps.\n", staken*100.0/(1.0*sattempted*CDparams[0]), sattempted*CDparams[0]); } return WtMCMC_OK; }
/********************* void WtMCMCSample Using the parameters contained in the array theta, obtain the network statistics for a sample of size samplesize. burnin is the initial number of Markov chain steps before sampling anything and interval is the number of MC steps between successive networks in the sample. Put all the sampled statistics into the networkstatistics array. *********************/ WtMCMCStatus WtCDSample(WtMHproposal *MHp, double *theta, double *networkstatistics, int samplesize, int nsteps, Vertex *undotail, Vertex *undohead, double *undoweight, int fVerbose, WtNetwork *nwp, WtModel *m) { int i, j; /********************* networkstatistics are modified in groups of m->n_stats, and they reflect the CHANGE in the values of the statistics from the original (observed) network. Thus, when we begin, the initial values of the first group of m->n_stats networkstatistics should all be zero *********************/ /*for (j=0; j < m->n_stats; j++) */ /* networkstatistics[j] = 0.0; */ /* Rprintf("\n"); */ /* for (j=0; j < m->n_stats; j++){ */ /* Rprintf("j %d %f\n",j,networkstatistics[j]); */ /* } */ /* Rprintf("\n"); */ /* Now sample networks */ for (i=0; i < samplesize; i++){ if(WtCDStep(MHp, theta, networkstatistics, nsteps, undotail, undohead, undoweight, fVerbose, nwp, m)!=WtMCMC_OK) return WtMCMC_MH_FAILED; #ifdef Win32 if( ((100*i) % samplesize)==0 && samplesize > 500){ R_FlushConsole(); R_ProcessEvents(); } #endif networkstatistics += m->n_stats; } return WtMCMC_OK; }