
.. oe:namespace:: OESystem
.. meta::
   :keywords: OERandom, Random


.. _OESystem_OERandom:

.. oe:class:: OERandom

   .. oe:api::

      class OERandom

   This class represents `OERandom`.

   The :ref:`OERandom <OESystem_OERandom>` class provides a portable pseudo-random number generator.

   .. oe:method:: Constructors

      .. oe:api::

         OERandom(bool timeseed = false)

      The 'timeseed' argument to the
      :ref:`OERandom <OESystem_OERandom>` constructor indicates whether the pseudo
      random number generator should initialize (or seed) its sequence from
      the system clock.

   .. oe:method:: GetSeed

      .. oe:api::

         unsigned int GetSeed() const

      Return the current state of the random number generator so that
      a new :ref:`OERandom <OESystem_OERandom>` object can be created and
      restarted from the given state. To restart a
      :ref:`OERandom <OESystem_OERandom>` object at a given location, pass
      this seed into :oe:meth:`OESystem::OERandom::Seed`.

      .. warning::

         The datatype of this method will likely change in a future
         release when a better random number generator will be
         implemented.


   .. oe:method:: NextFloat

      .. oe:api::

         float NextFloat()

      Returns the next pseudo-random floating point value in the range
      ``[0.0, 1.0)``. To convert this value into an integer range, for
      example ``10`` discrete values, use ``int i =
      (int)floor(10.0*r.NextFloat())``, which should return values in
      the range ``0`` to ``9`` inclusive.

   .. oe:method:: NextInt

      .. oe:api::

         int NextInt()

      Return the next random integer in this sequence of random
      numbers. The returned integer will never be negative.

   .. oe:method:: Seed

      .. oe:api::

         void Seed(unsigned int seed)

      Sets the pseudo random number generator seed to a given
      value. The :ref:`OERandom <OESystem_OERandom>` class uses a
      deterministic linear congruential class of pseudo random number
      generator (PRNG). Setting the seed to a specific value, causes
      the sequence of subsequent
      :oe:meth:`OESystem::OERandom::NextFloat` values to be identical
      on all platforms. This may be useful for testing stochastic
      algorithms on different architectures/operating systems.

   .. oe:method:: TimeSeed

      .. oe:api::

         void TimeSeed()

      Seeds this random number generator based upon the number of
      seconds since January 1, 1970, Coordinated Universal Time.
