std::uniform_real_distribution
De cppreference.com
![]() | Esta página se ha traducido por ordenador/computador/computadora de la versión en inglés de la Wiki usando Google Translate. La traducción puede contener errores y palabras aparatosas/incorrectas. Planea sobre el texto para ver la versión original. Puedes ayudar a corregir los errores y mejorar la traducción. Para instrucciones haz clic aquí. |
Definido en el archivo de encabezado <random> | ||
template<class RealType =double> class uniform_real_distribution; | (desde C++11) | |
Produce aleatorio de punto flotante i valores, distribuida uniformemente en el intervalo de
[a, b)
, es decir, distribuidos de acuerdo con la función de probabilidad:Original:
Produces random floating-point values i, uniformly distributed on the interval
[a, b)
, that is, distributed according to the probability function:The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
- P(i|a,b) =
.1 b − a
[editar]Tipos de miembros
Miembro de tipo Original: Member type The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. | Definition |
result_type | RealType |
param_type | el tipo del conjunto de parámetros, sin especificar Original: the type of the parameter set, unspecified The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
[editar]Las funciones miembro
construye nueva distribución Original: constructs new distribution The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (función miembro pública) | |
restablece el estado interno de la distribución Original: resets the internal state of the distribution The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (función miembro pública) | |
Original: Generation The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. | |
genera el siguiente número aleatorio en la distribución (función miembro pública) | |
Original: Characteristics The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. | |
devuelve el a parámetro de distribución (valor mínimo) Original: returns the a distribution parameter (minimum value) The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (función miembro pública) | |
devuelve el b parámetro de distribución (valor máximo) Original: returns the b distribution parameter (maximum value) The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (función miembro pública) | |
obtiene o establece el objeto de parámetro de distribución Original: gets or sets the distribution parameter object The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (función miembro pública) | |
devuelve el valor mínimo potencialmente generado Original: returns the minimum potentially generated value The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (función miembro pública) | |
devuelve el valor máximo potencialmente generado Original: returns the maximum potentially generated value The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (función miembro pública) |
[editar]Terceros funciones
compara dos objetos de distribución (función) | |
realiza flujo de entrada y salida en la distribución de números pseudo-aleatorios (función) |
[editar]Ejemplo
imprimir 10 números aleatorios entre 1 y 2
Original:
print 10 random numbers between 1 and 2
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
Ejecuta este código
#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';}
Salida:
1.80829 1.15391 1.18483 1.38969 1.36094 1.0648 1.97798 1.27984 1.68261 1.57326