std::piecewise_constant_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 piecewise_constant_distribution; |
(desde C++11) | |
std::piecewise_constant_distribution
produce al azar números de punto flotante, que están distribuidos uniformemente dentro de cada uno de los subintervalos [bi, b
i+1) varios, cada uno con su propio peso w
i. El conjunto de límites de intervalo y el conjunto de ponderaciones son los parámetros de esta distribución .
Original:
std::piecewise_constant_distribution
produces random floating-point numbers, which are uniformly distributed within each of the several subintervals [bi, b
i+1), each with its own weight w
i. The set of interval boundaries and the set of weights are the parameters of this distribution.
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.
La densidad de probabilidad para cualquier b
i≤x<b
i+1 es None
. donde S es la suma de todos los pesos .
i≤x<b
i+1 es None
w k |
S (b i+1 - b i) |
Original:
The probability density for any b
i≤x<b
i+1 is None
. where S is the sum of all weights.
i≤x<b
i+1 is None
w k |
S (b i+1 - b i) |
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.
[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. | |
obtiene la lista de límites del intervalo Original: obtains the list of interval boundaries 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 la lista de las densidades de probabilidad Original: obtains the list of probability densities 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
Ejecuta este código
#include <iostream> #include <string> #include <map> #include <random> int main() { std::random_device rd; std::mt19937 gen(rd()); // 50% of the time, generate a random number between 0 and 1 // 50% of the time, generate a random number between 10 and 15 std::vector<double> i{0, 1, 10, 15}; std::vector<double> w{ 1, 0, 1}; std::piecewise_constant_distribution<> d(i.begin(), i.end(), w.begin()); std::map<int, int> hist; for(int n=0; n<10000; ++n) { ++hist[d(gen)]; } for(auto p : hist) { std::cout << p.first << ' ' << std::string(p.second/100, '*') << '\n'; } }
Salida:
0 ************************************************** 10 ********** 11 ********* 12 ********* 13 ********** 14 *********