Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      C++ named requirements:RandomNumberDistribution(since C++11)

      From cppreference.com
      <cpp‎ |named req
       
       
      C++ named requirements
       

      ARandomNumberDistribution is a function object returning random numbers according to aprobability density functionp(x) or adiscrete probability distributionP(xi).

      [edit]Requirements

      The typeD satisfiesRandomNumberDistribution if

      Given

      • T, the type named byD::result_type
      • P, the type named byD::param_type, which
      • satisfiesCopyConstructible
      • satisfiesCopyAssignable
      • satisfiesEqualityComparable
      • has a constructor taking identical arguments as each of the constructors ofD that take arguments corresponding to the distribution parameters
      • has a member function with the identical name, type, and semantics, as every member function ofD that returns a parameter of the distribution
      • declares a member typedefusing distribution_type= D;

      The following expressions must be valid and have their specified effects

      ExpressionTypeNotesComplexity
      D::result_typeTAnarithmetic typeCompile-time
      D::param_typePCompile-time
      D()Creates a distribution indistinguishable from any other default-constructedDConstant
      D(p)Creates a distribution indistinguishable fromD constructed directly from the values used to constructpSame asp's construction
      d.reset()voidResets the internal state of the distribution. The next call tooperator() ond will not depend on values produced by any engine prior toreset()Constant
      x.param()PReturnsp such thatD(p).param()== pNo worse thanD(p)
      d.param(p)voidPostcondition:d.param()== pNo worse thanD(p)
      d(g)TThe sequence of numbers returned by successive invocations of this call with the sameg are randomly distributed according to the distribution parametrized byd.param()Amortized constant number of invocations ofg
      d(g,p)TThe sequence of numbers returned by successive invocations of this call with the sameg are randomly distributed according to the distribution parametrized bypAmortized constant number of invocations ofg
      x.min()TThe greatest lower bound on the values potentially returned byx’soperator(), as determined by the current values ofx’s parametersConstant
      x.max()TThe least upper bound on the values potentially returned byx’soperator(), as determined by the current values ofx’s parametersConstant
      x == yboolEstablishes an equivalence relation. Returnstrue ifx.param()== y.param() and future infinite sequences of values that would be generated by repeated invocations ofx(g1) andy(g2) would be equal as long asg1== g2Constant
      x != ybool!(x == y)Constant
      os << xReference to the type ofosWrites a textual representation of the distribution parameters and internal state toos. The formatting flags and fill character ofos are unchanged
      is >> dReference to the type ofisRestores the distribution parameters and internal state with data read fromis. The formatting flags ofis are unchanged. The data must have been written using a stream with the same locale,CharT andTraits stream template parameters, otherwise the behavior is undefined. If bad input is encountered,is.setstate(std::ios::failbit) is called, which may throwstd::ios_base::failure.d is unchanged in that case

      [edit]Notes

      The parameters of a distribution object may be changed either permanently, by usingd.param(p) or just for the duration of a single operator() call, by usingd(g,p).

      Calls to const member functions of the distribution andos<< d do not affect the sequence of numbers produced by repeatedd(g).

      [edit]Standard library

      The following standard library components satisfyRandomNumberDistribution

      produces integer values evenly distributed across a range
      (class template)[edit]
      produces real values evenly distributed across a range
      (class template)[edit]
      producesbool values on aBernoulli distribution
      (class)[edit]
      produces integer values on aBinomial distribution
      (class template)
      produces integer values on aNegative binomial distribution
      (class template)
      produces integer values on aGeometric distribution
      (class template)
      produces integer values on aPoisson distribution
      (class template)
      produces real values on anExponential distribution
      (class template)
      produces real values on aGamma distribution
      (class template)
      produces real values on aWeibull distribution
      (class template)
      produces real values on anExtreme value distribution
      (class template)
      produces real values on aStandard normal (Gaussian) distribution
      (class template)
      produces real values on aLognormal distribution
      (class template)
      produces real values on aChi-squared distribution
      (class template)
      produces real values on aCauchy distribution
      (class template)
      produces real values on aFisher's F-distribution
      (class template)
      produces real values on aStudent's t-distribution
      (class template)
      produces integer values on a discrete distribution
      (class template)
      produces real values distributed on constant subintervals
      (class template)
      produces real values distributed on defined subintervals
      (class template)
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/named_req/RandomNumberDistribution&oldid=182481"

      [8]ページ先頭

      ©2009-2025 Movatter.jp