Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here.

exponential_distribution::exponential_distribution

Constructs the distribution.

exponential_distribution(const result_type& lambda0 = result_type(1));

lambda0

The lambda distribution parameter.

Precondition: 0.0 <= lambda0

The constructor constructs an object whose stored value stored_lambda holds the value lambda0.

 

// std_tr1__random__exponential_distribution_construct.cpp 
// compile with: /EHsc 
#include <random> 
#include <iostream> 
 
typedef std::tr1::ranlux64_base_01 Myeng; 
typedef std::tr1::exponential_distribution<double> Mydist; 
int main() 
    { 
    Myeng eng; 
    Mydist dist(1.5); 
    Mydist::input_type engval = eng(); 
    Mydist::result_type distval = dist(eng); 
 
    distval = distval;  // to quiet "unused" warnings 
    engval = engval; 
 
    std::cout << "lambda == " << dist.lambda() << std::endl; 
 
    dist.reset(); // discard any cached values 
    std::cout << "a random value == " << dist(eng) << std::endl; 
    std::cout << "a random value == " << dist(eng) << std::endl; 
    std::cout << "a random value == " << dist(eng) << std::endl; 
 
    return (0); 
    } 
 
lambda == 1.5 a random value == 0.223809 a random value == 0.168898 a random value == 0.176395

Header: <random>

Namespace: std::tr1

Community Additions

ADD
Show:
© 2015 Microsoft