rand

Functions

int main(int argc, char *argv[])

rand [ option ]

  • -l int

    • output length \((1 \le L)\)

  • -m int

    • output order \((0 \le L - 1)\)

  • -s int

    • random seed

  • -a double

    • lower bound \((a < b)\)

  • -b double

    • upper bound \((b > a)\)

  • stdout

    • double-type random values

The output of this command is

\[ \begin{array}{ccccc} \epsilon(0), & \epsilon(1), & \ldots, & \epsilon(L - 1) \end{array} \]
where
\[ \epsilon(l) \sim \mathcal{U}(a, b). \]
If the output length \(L\) is not given, an infinite random value sequence is generated.

In the below example, uniform distributed random values of length 100 are generated:

rand -l 100 > data.rnd
Parameters:
  • argc[in] Number of arguments.

  • argv[in] Argument vector.

Returns:

0 on success, 1 on failure.

See also

mseq nrand

class UniformDistributedRandomValueGeneration : public sptk::RandomGenerationInterface

Generate random number based on uniform distribution.

Public Functions

explicit UniformDistributedRandomValueGeneration(int seed, double lower_bound = 0.0, double upper_bound = 1.0)
Parameters:
  • seed[in] Random seed.

  • lower_bound[in] Lower bound of random number.

  • upper_bound[in] Upper bound of random number.

virtual void Reset() override

Reset internal state.

virtual bool Get(double *output) override

Get random number.

Parameters:

output[out] Random number.

Returns:

True on success, false on failure.

inline int GetSeed() const
Returns:

Random seed.

inline bool IsValid() const
Returns:

True if this object is valid.