A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://cplusplus.com/reference/random/binomial_distribution/param/ below:

public member function

<random>

std::binomial_distribution::param (1)
param_type param() const;
(2)
void param (const param_type& parm);

Distribution parameters

The first version (1) returns an object with the parameters currently associated with the distribution object.
The second version (2) associates the parameters in object parm to the distribution object.

A binomial_distribution is defined by two parameters: an upper bound (t), and a probability (p). An object of type param_type carries this information, but it is meant to be used only to construct or specify the parameters for a binomial_distribution object, not to inspect the individual parameters.

To inspect the individual parameters associated to the distribution object you can use: binomial_distribution::t and binomial_distribution::p.



Parameters
parm
An object representing the distribution's parameters, obtained by a call to member function param.
param_type is a member type.

Return value
An object representing the distribution's parameters.
param_type is a member type.

Example
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
// binomial_distribution::param
#include <iostream>
#include <random>

int main()
{
  std::default_random_engine generator;
  std::binomial_distribution<int> d1(100,0.5);
  std::binomial_distribution<int> d2(d1.param());

  // print two independent values:
  std::cout << d1(generator) << std::endl;
  std::cout << d2(generator) << std::endl;

  return 0;
}

Possible output:


Complexity No worse than the complexity of param_type's constructor.

See also
binomial_distribution::(constructor)
Construct binomial distribution (public member function)
binomial_distribution::reset
Reset distribution (public member function)

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4