コード例 #1
0
ファイル: inference_utility.cpp プロジェクト: newtonjoo/imp
InferenceStatistics::Data InferenceStatistics::get_data(
    const Subset &, AssignmentContainer *iss) const {
  Assignments ss =
      iss->get_assignments(IntRange(0, iss->get_number_of_assignments()));
  Data ret;
  ret.size = iss->get_number_of_assignments();
  Ints sample;
  for (int i = 0; i < ret.size; ++i) {
    if (sample.size() < sample_size) {
      sample.push_back(i);
    } else {
      double prob = static_cast<double>(sample_size) / i;
      if (select_(base::random_number_generator) < prob) {
        int replace = place_(base::random_number_generator);
        sample[replace] = i;
      }
    }
  }
  ret.sample.resize(sample.size());
  for (unsigned int i = 0; i < sample.size(); ++i) {
    ret.sample[i] = iss->get_assignment(sample[i]);
  }
  return ret;
}
コード例 #2
0
ファイル: fibonacciarray.hpp プロジェクト: jnory/YuNomi
 uint64_t operator[](uint64_t i) const {
     uint64_t start = i > 0? select_(i - 1) + 1: 0;
     uint64_t end = select_(i) + 1;
     uint64_t encoded = data_(start, end);
     return encoded;
 }