Skip to content

Commit a832100

Browse files
authored
fix walkL tuning function
1 parent 24eac7d commit a832100

File tree

1 file changed

+30
-32
lines changed

1 file changed

+30
-32
lines changed

examples/correlation_matrices/sampler.cpp

+30-32
Original file line numberDiff line numberDiff line change
@@ -150,44 +150,42 @@ void correlation_matrix_uniform_sampling_MT(const unsigned int n, const unsigned
150150
}
151151

152152
template<typename WalkTypePolicy, typename PointType, typename RNGType, typename MT>
153-
void tune_walkL(const std::vector<unsigned int>& walkL_values, const std::vector<unsigned int>& dimensions, const unsigned int num_points,
153+
void tune_walkL(const unsigned int walkL, const std::vector<unsigned int>& dimensions, const unsigned int num_points,
154154
const unsigned int nburns, const unsigned int num_matrices){
155155
for (unsigned int n : dimensions) {
156156
std::list<MT> randCorMatrices;
157157

158-
for (unsigned int walkL : walkL_values) {
159-
std::chrono::steady_clock::time_point start, end;
160-
double time;
161-
start = std::chrono::steady_clock::now();
162-
163-
uniform_correlation_sampling_MT<WalkTypePolicy, PointType, RNGType>(n, randCorMatrices, walkL, num_points, 0);
164-
165-
end = std::chrono::steady_clock::now();
166-
time = std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count();
167-
std::cout << "Elapsed time : " << time << " (ms) for dimension: " << n << std::endl;
168-
169-
int d = n*(n-1)/2;
170-
MT samples(d, num_points);
171-
unsigned int jj = 0;
172-
for(auto& mat : randCorMatrices){
173-
samples.col(jj) = getCoefficientsFromMatrix<NT, MT>(mat);
174-
jj++;
175-
}
158+
std::chrono::steady_clock::time_point start, end;
159+
double time;
160+
start = std::chrono::steady_clock::now();
161+
162+
uniform_correlation_sampling_MT<WalkTypePolicy, PointType, RNGType>(n, randCorMatrices, walkL, num_points, 0);
163+
164+
end = std::chrono::steady_clock::now();
165+
time = std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count();
166+
std::cout << "Elapsed time : " << time << " (ms) for dimension: " << n << std::endl;
167+
168+
int d = n*(n-1)/2;
169+
MT samples(d, num_points);
170+
unsigned int jj = 0;
171+
for(auto& mat : randCorMatrices){
172+
samples.col(jj) = getCoefficientsFromMatrix<NT, MT>(mat);
173+
jj++;
174+
}
176175

177-
//calculate psrf
178-
VT psrf = univariate_psrf<NT, VT, MT>(samples);
179-
double max_psrf = psrf.maxCoeff();
180-
std::cout << "PSRF = " << max_psrf << std::endl;
176+
//calculate psrf
177+
VT psrf = univariate_psrf<NT, VT, MT>(samples);
178+
double max_psrf = psrf.maxCoeff();
179+
std::cout << "PSRF = " << max_psrf << std::endl;
181180

182-
//calculate ess
183-
unsigned int min_ess = 0;
184-
VT ess_vector = effective_sample_size<NT, VT, MT>(samples, min_ess);
185-
std::cout << "Effective Sample Size = " << min_ess << std::endl;
186-
std::cout << "Average Effective Sample Size = " << min_ess/num_matrices << std::endl;
187-
188-
// Clear the matrices for the next iteration
189-
randCorMatrices.clear();
190-
}
181+
//calculate ess
182+
unsigned int min_ess = 0;
183+
VT ess_vector = effective_sample_size<NT, VT, MT>(samples, min_ess);
184+
std::cout << "Effective Sample Size = " << min_ess << std::endl;
185+
std::cout << "Average Effective Sample Size = " << min_ess/num_matrices << std::endl;
186+
187+
// Clear the matrices for the next iteration
188+
randCorMatrices.clear();
191189
}
192190
}
193191

0 commit comments

Comments
 (0)