STD::PIECEWISE_LINEAR_DISTRIBUTION(3)
β¨ NAME β¨
std::piecewise_linear_distribution< _RealType > β a piecewise_linear_distribution random number distribution. That's the whole vibe, bestie π
This little icon lives in the Library Functions Manual, and it's genuinely one of the cutest corners of <random>. Let's get into it π
πΈ SYNOPSIS πΈ
first things first, you gotta pull the header in:
#include <random>
π Classes π
struct param_type
π Public Types π
typedef _RealType result_type
π Public Member Functions π
the constructors, okay, there are four of them and they all hit different:
template<typename _InputIteratorB, typename _InputIteratorW> piecewise_linear_distribution (_InputIteratorB __bfirst, _InputIteratorB __bend, _InputIteratorW __wbegin)piecewise_linear_distribution (const param_type &__p)template<typename _Func> piecewise_linear_distribution (initializer_list< _RealType > __bl, _Func __fw)template<typename _Func> piecewise_linear_distribution (size_t __nw, _RealType __xmin, _RealType __xmax, _Func __fw)
and then the __generate crew (double underscore, yes, they're internal-ish, no we're not gatekeeping):
template<typename _ForwardIterator, typename _UniformRandomNumberGenerator> void __generate (_ForwardIterator __f, _ForwardIterator __t, _UniformRandomNumberGenerator &__urng)template<typename _ForwardIterator, typename _UniformRandomNumberGenerator> void __generate (_ForwardIterator __f, _ForwardIterator __t, _UniformRandomNumberGenerator &__urng, const param_type &__p)template<typename _UniformRandomNumberGenerator> void __generate (result_type *__f, result_type *__t, _UniformRandomNumberGenerator &__urng, const param_type &__p)
the actual member functions:
std::vector< double > densities () constβ returns a vector of the probability densities of the distribution β¨std::vector< _RealType > intervals () constβ returns the intervals of the distribution β¨result_type max () constβ returns the least upper bound value of the distributionresult_type min () constβ returns the greatest lower bound value of the distributiontemplate<typename _UniformRandomNumberGenerator> result_type operator() (_UniformRandomNumberGenerator &__urng)β generating functionstemplate<typename _UniformRandomNumberGenerator> result_type operator() (_UniformRandomNumberGenerator &__urng, const param_type &__p)param_type param () constβ returns the parameter set of the distributionvoid param (const param_type &__param)β sets the parameter set of the distributionvoid reset ()
π Friends π
template<typename _RealType1, typename _CharT, typename _Traits> std::basic_ostream< _CharT, _Traits > & operator<< (std::basic_ostream< _CharT, _Traits > &__os, const std::piecewise_linear_distribution< _RealType1 > &__x)β inserts apiecewise_linear_distributionrandom number distribution__xinto the output stream__osbool operator== (const piecewise_linear_distribution &__d1, const piecewise_linear_distribution &__d2)β returntrueif two piecewise linear distributions have the same parameterstemplate<typename _RealType1, typename _CharT, typename _Traits> std::basic_istream< _CharT, _Traits > & operator>> (std::basic_istream< _CharT, _Traits > &__is, std::piecewise_linear_distribution< _RealType1 > &__x)β extracts apiecewise_linear_distributionrandom number distribution__xfrom the input stream__is
π₯ Detailed Description π₯
template<typename _RealType = double>
class std::piecewise_linear_distribution< _RealType >"A
piecewise_linear_distribution random number distribution.
okay so the detailed description here got absolutely mangled by the doc generator, and I am not going to pretend I can un-mangle math that arrived like this π but here it is, exactly as the page shows it:
This distribution produces random numbers $ x, b_0 x < b_n ho_n) = distributed over each subinterval $ [b_i, b_{i+1}ho_0,c...,ing to the probability mass function $ p(x | b_0, ..., b_n, $, for $ b_i x < b_{i+1} $.
(that's the literal text on the page β the LaTeX fairies did NOT come through, bestie π)
Since: C++11 π«Ά
π Member Typedef Documentation π
template<typename _RealType = double>
typedef _RealType std::piecewise_linear_distribution< _RealType >::result_type
The type of the range of the distribution. it's giving "what comes out of this thing" β¨
π Member Function Documentation π
densities()
template<typename _RealType = double>
std::vector< double > std::piecewise_linear_distribution< _RealType >::densities () const
[inline] β return a vector of the probability densities of the distribution.
intervals()
template<typename _RealType = double>
std::vector< _RealType > std::piecewise_linear_distribution< _RealType >::intervals () const
[inline] β return the intervals of the distribution.
max()
template<typename _RealType = double>
result_type std::piecewise_linear_distribution< _RealType >::max () const
[inline] β returns the least upper bound value of the distribution.
min()
template<typename _RealType = double>
result_type std::piecewise_linear_distribution< _RealType >::min () const
[inline] β returns the greatest lower bound value of the distribution.
operator()
template<typename _RealType = double>
template<typename _UniformRandomNumberGenerator>
result_type std::piecewise_linear_distribution< _RealType >::operator()
(_UniformRandomNumberGenerator & __urng)
[inline] β generating functions.
Referenced by operator()().
param() (the getter)
template<typename _RealType = double>
param_type std::piecewise_linear_distribution< _RealType >::param () const
[inline] β returns the parameter set of the distribution.
param() (the setter)
template<typename _RealType = double>
void std::piecewise_linear_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_linear_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_linear_distribution< _RealType1 > & __x)
[friend] β inserts a piecewise_linear_distribution random number distribution __x into the output stream __os.
Parameters
__osβ an output stream.__xβ apiecewise_linear_distributionrandom number distribution.
Returns
- the output stream with the state of
__xinserted, or in an error state.
operator==
template<typename _RealType = double>
bool operator== (const piecewise_linear_distribution< _RealType > & __d1,
const piecewise_linear_distribution< _RealType > & __d2)
[friend] β return true if two piecewise linear distributions have the same parameters.
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_linear_distribution< _RealType1 > & __x)
[friend] β extracts a piecewise_linear_distribution random number distribution __x from the input stream __is.
Parameters
__isβ an input stream.__xβ apiecewise_linear_distributionrandom number generator engine.
Returns
- the input stream with
__xextracted, or in an error state.
π Author π
Generated automatically by Doxygen for libstdc++ from the source code. no human wrote this one, it's a robot doing its little robot thing π€β¨
and that's the page, bestie!! π this whole thing came out of libstdc++ and it's the std::piece..._RealType >(3) page β icon behavior, honestly. go forth and generate, ily π«Άπ
π¦ 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