Skip to content

linearRand produces incorrect results. #1386

@Irrgh

Description

@Irrgh

According to the API Documentation:

Generate random numbers in the interval [Min, Max], according a linear distribution

  • Min Minimum value included in the sampling
  • Max Maximum value included in the sampling
  • genType Value type. Currently supported: float or double scalars.
#include<glm/gtc/random.hpp>

double observedMin = 1000.0;
double observedMax = -1000.0;


for (int i = 0; i < 1000000; i++) {

    double rand = glm::linearRand(-1000.0, 1000.0);

    observedMax = std::max(observedMax, rand);
    observedMin = std::min(observedMin, rand);
}

printf("max=%.7f, min=%.7f", observedMax, observedMin);

Executing this (c++ 17, glm-1.0.1, msvc140) gives the following results which are not correct and do not match Documentation:

max=992.1559811, min=-999.9977357

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions