std::piecewise_constant_distribution
Da cppreference.com.
![]() |
Questa pagina è stata tradotta in modo automatico dalla versione in ineglese della wiki usando Google Translate.
La traduzione potrebbe contenere errori e termini strani. Muovi il puntatore sopra al testo per vedere la versione originale. Puoi aiutarci a correggere gli gli errori. Per ulteriori istruzioni clicca qui. |
Elemento definito nell'header <random>
|
||
template< class RealType = double > class piecewise_constant_distribution; |
(dal C++11) | |
std::piecewise_constant_distribution
produce casuali numeri a virgola mobile, che sono distribuiti in modo uniforme all'interno di ciascuna delle [bi, b
i+1) diversi sottointervalli, ciascuno con la propria w
i peso. L'insieme dei confini intervallo e l'insieme di pesi sono i parametri di questa distribuzione.
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 densità di probabilità per ogni b
i≤x<b
i+1 è None
. dove S è la somma di tutti i pesi.
i≤x<b
i+1 è 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.
[modifica] Membri tipi
Membro 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
|
il tipo di set di parametri, non specificato
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. |
[modifica] Membri funzioni
costruisce nuova distribuzione 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. (metodo pubblico) | |
ripristina lo stato interno della distribuzione 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. (metodo pubblico) | |
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 il successivo numero casuale nella distribuzione Original: generates the next random number in the distribution The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (metodo pubblico) | |
Original: Characteristics The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. | |
ottiene l'elenco dei confini intervallo 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. (metodo pubblico) | |
ottiene l'elenco delle densità di probabilità 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. (metodo pubblico) | |
ottiene o imposta l'oggetto parametro di distribuzione 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. (metodo pubblico) | |
restituisce il valore minimo potenzialmente generato 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. (metodo pubblico) | |
restituisce il valore massimo potenzialmente generato 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. (metodo pubblico) |
[modifica] Non membri funzioni
confronta due oggetti di distribuzione Original: compares two distribution objects The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (funzione) | |
esegue flusso di ingresso e di uscita sul pseudo-casuale distribuzione numerica Original: performs stream input and output on pseudo-random number distribution The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (funzione) |
[modifica] Esempio
#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'; } }
Output:
0 ************************************************** 10 ********** 11 ********* 12 ********* 13 ********** 14 *********