다음을 통해 공유


geometric_distribution::geometric_distribution

분포를 생성합니다.

geometric_distribution(RealType p0 = RealType(0.5));
explicit geometric_distribution(const param_type& par0);

매개 변수

  • p0
    P 분포의 매개 변수입니다.

  • par0
    매개 변수 패키지 배포를 구성 하는 데 사용 합니다.

설명

전제 조건:0.0 < p0 && p0 < 1.0

첫 번째 생성자는 개체를 저장된 값 생성 stored_p 의 값은 p0.

두 번째 생성자는 개체를 매개 변수로 저장 된 초기화 구문 par0.

예제

 

// std_tr1__random__geometric_distribution_construct.cpp 
// compile with: /EHsc 
#include <random> 
#include <iostream> 
 
typedef std::mt19937 Myeng; 
typedef std::geometric_distribution<int, double> Mydist; 
int main() 
    { 
    Myeng eng; 
    Mydist dist(0.1); 
    Mydist::input_type engval = eng(); 
    Mydist::result_type distval = dist(eng); 
 
    distval = distval;  // to quiet "unused" warnings 
    engval = engval; 
 
    std::cout << "p == " << dist.p() << 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); 
    } 
 
  

요구 사항

헤더: <random>

네임 스페이스: std

참고 항목

참조

<random>

geometric_distribution Class