STD::PIECEWISE_CONSTANT_DISTRIBUTION(3)
π NAME π
std::piecewise_constant_distribution< _RealType > β a piecewise_constant_distribution random number distribution, bestie. That's the whole vibe. It's a template, it lives in the C++ standard library, and it hands you random numbers that are piecewise constant. Iconic behaviour, no notes. (This page ships in the Library Functions Manual, section 3, in case you were wondering where you wandered into. π§)
β¨ SYNOPSIS β¨
#include <random>
πΈ Classes
struct param_type
π¦ Public Types
typedef _RealType result_type
π Public Member Functions
- ```cpp template<typename _InputIteratorB, typename _InputIteratorW> piecewise_constant_distribution (_InputIteratorB __bfirst, _InputIteratorB __bend, _InputIteratorW __wbegin)
- ```cpp
piecewise_constant_distribution (const param_type &__p)
- ```cpp template<typename _Func> piecewise_constant_distribution (initializer_list< _RealType > __bl, _Func __fw)
- ```cpp
template<typename _Func> piecewise_constant_distribution (size_t __nw,
_RealType __xmin, _RealType __xmax, _Func __fw)
- ```cpp template<typename _ForwardIterator, typename _UniformRandomNumberGenerator> void __generate (_ForwardIterator __f, _ForwardIterator __t, _UniformRandomNumberGenerator &__urng)
- ```cpp
template<typename _ForwardIterator, typename
_UniformRandomNumberGenerator> void __generate (_ForwardIterator
__f, _ForwardIterator __t, _UniformRandomNumberGenerator &__urng,
const param_type &__p)
- ```cpp template<typename _UniformRandomNumberGenerator> void __generate (result_type *__f, result_type *__t, _UniformRandomNumberGenerator &__urng, const param_type &__p)
- **`std::vector< double > densities () const`** β returns a vector of the probability densities. so you can peek at the β¨mathβ¨ behind the curtain.
- **`std::vector< _RealType > intervals () const`** β returns a vector of the intervals. the actual buckets, laid out for you.
- **`result_type max () const`** β returns the least upper bound value of the distribution.
- **`result_type min () const`** β returns the greatest lower bound value of the distribution.
- ```cpp
template<typename _UniformRandomNumberGenerator> result_type operator()
(_UniformRandomNumberGenerator &__urng)
generating functions. this is the one that actually rolls the dice, babe.
- ```cpp template<typename _UniformRandomNumberGenerator> result_type operator() (_UniformRandomNumberGenerator &__urng, const param_type &__p)
- **`param_type param () const`** β returns the parameter set of the distribution. like, receipts for how it's currently configured.
- **`void param (const param_type &__param)`** β sets the parameter set of the distribution. you're the one in charge now.
- **`void reset ()`** β resets the distribution state. fresh start, main character energy.
## π«Ά Friends
- ```cpp
template<typename _RealType1, typename _CharT, typename _Traits>
std::basic_ostream< _CharT, _Traits > & operator<<
(std::basic_ostream< _CharT, _Traits > &__os, const
std::piecewise_constant_distribution< _RealType1 > &__x)
inserts a piecewise_constant_distribution random number distribution __x into the output stream __os.
- ```cpp bool operator== (const piecewise_constant_distribution &__d1, const piecewise_constant_distribution &__d2)
return `true` if two piecewise constant distributions have the same parameters.
- ```cpp
template<typename _RealType1, typename _CharT, typename _Traits>
std::basic_istream< _CharT, _Traits > & operator>>
(std::basic_istream< _CharT, _Traits > &__is,
std::piecewise_constant_distribution< _RealType1 > &__x)
extracts a piecewise_constant_distribution random number distribution __x from the input stream __is.
π« DETAILED DESCRIPTION π«
template<typename _RealType = double>
class std::piecewise_constant_distribution< _RealType >
"A piecewise_constant_distribution random number distribution.
Okay bestie, listen β the source page for this bit is genuinely scrambled. The math came out of the generator looking like a smoothie. I'm giving it to you verbatim, exactly as it's printed, because the rule is we keep every detail even when the detail is fighting for its life. π₯²
This distribution produces random numbers $ x, b_0 x < b_n $, ho_{n-1})
distributed over eaho_{i+1}t]rfor $ b_ii,xb<{b_{i+1}h$.0,r..., to the
probabho_iy mass +unction p(x | b_0, ..., b_n,
=
Since
C++11 β yes, it's giving modern standard. π
π MEMBER TYPEDEF DOCUMENTATION π
result_type
template<typename _RealType = double> typedef _RealType
std::piecewise_constant_distribution< _RealType >::result_type
The type of the range of the distribution. that's the thing every draw comes back as, periodt.
π MEMBER FUNCTION DOCUMENTATION π
densities
template<typename _RealType = double> std::vector< double >
std::piecewise_constant_distribution< _RealType >::densities () const
[inline]
Returns a vector of the probability densities. π₯
intervals
template<typename _RealType = double> std::vector< _RealType >
std::piecewise_constant_distribution< _RealType >::intervals () const
[inline]
Returns a vector of the intervals. π
max
template<typename _RealType = double> result_type
std::piecewise_constant_distribution< _RealType >::max () const [inline]
Returns the least upper bound value of the distribution. the ceiling of the whole situation.
min
template<typename _RealType = double> result_type
std::piecewise_constant_distribution< _RealType >::min () const [inline]
Returns the greatest lower bound value of the distribution. the floor, fr fr.
operator()
template<typename _RealType = double> template<typename
_UniformRandomNumberGenerator> result_type
std::piecewise_constant_distribution< _RealType >::operator()
(_UniformRandomNumberGenerator & __urng) [inline]
Generating functions.
Referenced by operator()(). (yes, it references itself, that's just how the docs do, we don't ask questions π)
param (getter)
template<typename _RealType = double> param_type
std::piecewise_constant_distribution< _RealType >::param () const
[inline]
Returns the parameter set of the distribution.
param (setter)
template<typename _RealType = double> void
std::piecewise_constant_distribution< _RealType >::param (const
param_type & __param) [inline]
Sets the parameter set of the distribution.
Parameters
__paramβ The new parameter set of the distribution.
reset
template<typename _RealType = double> void
std::piecewise_constant_distribution< _RealType >::reset () [inline]
Resets the distribution state.
π«Ά FRIENDS AND RELATED SYMBOL DOCUMENTATION π«Ά
operator<<
template<typename _RealType = double> template<typename _RealType1, typename
_CharT, typename _Traits> std::basic_ostream< _CharT, _Traits > &
operator<< (std::basic_ostream< _CharT, _Traits > & __os, const
std::piecewise_constant_distribution< _RealType1 > & __x) [friend]
Inserts a piecewise_constant_distribution random number distribution __x into the output stream __os.
Parameters
__osβ An output stream.__xβ Apiecewise_constant_distributionrandom number distribution.
Returns
The output stream with the state of __x inserted or in an error state. π
operator==
template<typename _RealType = double> bool operator== (const
piecewise_constant_distribution< _RealType > & __d1, const
piecewise_constant_distribution< _RealType > & __d2) [friend]
Return true if two piecewise constant distributions have the same parameters. twin check β¨
operator>>
template<typename _RealType = double> template<typename _RealType1, typename
_CharT, typename _Traits> std::basic_istream< _CharT, _Traits > &
operator>> (std::basic_istream< _CharT, _Traits > & __is,
std::piecewise_constant_distribution< _RealType1 > & __x) [friend]
Extracts a piecewise_constant_distribution random number distribution __x from the input stream __is.
Parameters
__isβ An input stream.__xβ Apiecewise_constant_distributionrandom number generator engine.
Returns
The input stream with __x extracted or in an error state. π
π AUTHOR π
Generated automatically by Doxygen for libstdc++ from the source code. not me getting auto-generated by a documentation tool π slay I guess.
Okay so that's the whole page, bestie. The footer says this is libstdc++, page std::piece..._RealType >(3) β and no, there's no date hanging out in the footer, it's just the library and the page name, so I'm not gonna make one up because we keep the facts exactly as they are. π Stay random, stay distributed. π¦β¨
π¦ where this page comes from
- arch rolling: gcc 16.2.1+r23+gd564253eb6c8-1 Β· GPL-3.0-or-later WITH GCC-exception-3.1 AND GFDL-1.3-or-later
- fedora 44: libstdc++-docs 16.0.1-0.10.fc44 Β· GPL-3.0-or-later AND LGPL-3.0-or-later AND (GPL-3.0-or-later WITH GCC-exception-3.1) AND (GPL-3.0-or-later WITH Texinfo-exception) AND (LGPL-2.1-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GNU-compiler-exception) AND BSL-1.0 AND GFDL-1.3-or-later AND Linux-man-pages-copyleft-2-para AND SunPro AND BSD-1-Clause AND BSD-2-Clause AND BSD-2-Clause-Views AND BSD-3-Clause AND BSD-4-Clause AND BSD-Source-Code AND Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 WITH LLVM-Exception) AND ZPL-2.1 AND ISC AND LicenseRef-Fedora-Public-Domain AND HP-1986 AND curl AND Martin-Birgmeier AND HPND-Markus-Kuhn AND dtoa AND SMLNJ AND AMD-newlib AND OAR AND HPND-merchantability-variant AND HPND-Intel
- fedora 44: libstdc++-docs 16.2.1-2.fc44
- fedora 44: libstdc++-docs 16.2.1-3.fc44 Β· GPL-3.0-or-later AND LGPL-3.0-or-later AND (GPL-3.0-or-later WITH GCC-exception-3.1) AND (GPL-3.0-or-later WITH Texinfo-exception) AND (LGPL-2.1-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GNU-compiler-exception) AND BSL-1.0 AND GFDL-1.3-or-later AND Linux-man-pages-copyleft-2-para AND SunPro AND BSD-1-Clause AND BSD-2-Clause AND BSD-2-Clause-Views AND BSD-3-Clause AND BSD-4-Clause AND BSD-Source-Code AND Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 WITH LLVM-Exception) AND ZPL-2.1 AND ISC AND LicenseRef-Fedora-Public-Domain AND HP-1986 AND curl AND Martin-Birgmeier AND HPND-Markus-Kuhn AND dtoa AND SMLNJ AND AMD-newlib AND OAR AND HPND-merchantability-variant AND HPND-Intel
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms