[ Web Proxy ]
URL:
Viewing: https://ru.cppreference.com/cpp/numeric/random/uniform_real_distribution [Back]  [Original]

std::uniform_real_distribution cppreference.com
cppreference.com

std::uniform_real_distribution

cppreference.com

<metanoindex/>

 
C++
(C++20)
(C++20)
(C++11)
(C++20)
/
(C++11)
(C++11)
(C++11)
(C++17)
 
(C++17)
(C++20)
(C++11)
(C++11)
(C++17)
(C++17)
(C++20)
(C++20)
(C++11)
(C++17)
(C++20)
(C++23)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
 
 
 
<tbody> </tbody>
template< class RealType = double > class uniform_real_distribution;
( C++11)
i, [a, b),
:
Produces random floating-point values i, uniformly distributed on the interval [a, b), that is, distributed according to the probability function:
Google.
. .
P(i|a,b) =
1
b a
.

RealType . , float, double, long double.


-

result_type RealType
param_type
,
:
the type of the parameter set, unspecified
Google.
. .

-

:
constructs new distribution
Google.
. .

(public -) []
:
resets the internal state of the distribution
Google.
. .

(public -) []
:
Generation
Google.
. .

(public -) []
:
Characteristics
Google.
. .
' ( )
:
returns the a distribution parameter (minimum value)
Google.
. .

(public -) []
B ( )
:
returns the b distribution parameter (maximum value)
Google.
. .

(public -) []
:
gets or sets the distribution parameter object
Google.
. .

(public -) []
:
returns the minimum potentially generated value
Google.
. .

(public -) []
:
returns the maximum potentially generated value
Google.
. .

(public -) []

,

(C++11)(C++11)( C++20)

() []

/
() []

10 1 2
:
print 10 random numbers between 1 and 2
Google.
. .

#include <random>
#include <iostream>

int main()
{
    std::random_device rd;
    std::mt19937 gen(rd());
    std::uniform_real_distribution<> dis(1, 2);
    for (int n = 0; n < 10; ++n) {
        std::cout << dis(gen) << ' ';
    }
    std::cout << '\n';
}

:

1.80829 1.15391 1.18483 1.38969 1.36094 1.0648 1.97798 1.27984 1.68261 1.57326

Web Proxy Viewer  |  New URL  |  Original Page