lundi 6 février 2017

Generating Sobol sequence in C++

I am using Sobol C++ library from this site - http://ift.tt/2jgmACZ to generate Sobol sequence. In particular I am trying test #8:

void test08 ( )


{
# define DIM_MAX 4

  int dim_num;

  int i;

  int j;

  double r[DIM_MAX];

  long long int seed;

  long long int seed_in;

  long long int seed_out;

  for ( dim_num = 2; dim_num <= DIM_MAX; dim_num++ )
  {

    seed = 0;
    cout << "  In    Out\n";
    cout << "\n";

    for ( i = 0; i <= 110; i++ )
    {
      seed_in = seed;
      i8_sobol ( dim_num, &seed, r );
      seed_out = seed;

      if ( i <= 11 || 95 <= i )
      {
        cout << setw(6) << seed_in << "  "
             << setw(6) << seed_out << "  ";
        for ( j = 0; j < dim_num; j++ )
        {
          cout << setw(14) << r[j] << "  ";
        }
        cout << "\n";
      }
      else if ( i == 12 )
      {
        cout << "....................\n";
      }
    }

  }

  return;
}

The output here is a sequence between 0 and 1.

MY MAIN QUESTION IS : Can somebody give me a hint how to generate sequence with other boundaries (e.g. -2, 6)???




Aucun commentaire:

Enregistrer un commentaire