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 distribution
  • result_type min () const β€” returns the greatest lower bound value of the distribution
  • template<typename _UniformRandomNumberGenerator> result_type operator() (_UniformRandomNumberGenerator &__urng) β€” generating functions
  • template<typename _UniformRandomNumberGenerator> result_type operator() (_UniformRandomNumberGenerator &__urng, const param_type &__p)
  • param_type param () const β€” returns the parameter set of the distribution
  • void param (const param_type &__param) β€” sets the parameter set of the distribution
  • void 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 a piecewise_linear_distribution random number distribution __x into the output stream __os
  • bool operator== (const piecewise_linear_distribution &__d1, const piecewise_linear_distribution &__d2) β€” return true if two piecewise linear distributions have the same parameters
  • 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) β€” extracts a piecewise_linear_distribution random number distribution __x from 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.


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 β€” a piecewise_linear_distribution random 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_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 β€” a piecewise_linear_distribution random 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. 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