다음을 통해 공유


normal_distribution::normal_distribution

분포를 생성합니다.

normal_distribution(result_type mean0 = result_type(0.0),
    result_type sigma0 = result_type(1.0));
explicit normal_distribution(const param_type& par0);

매개 변수

  • mean0
    평균 분포의 매개 변수입니다.

  • sigma0
    시그마 분포의 매개 변수입니다.

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

설명

전제 조건:0.0 <= sigma0

첫 번째 생성자는 개체를 저장된 값 생성 stored_mean 의 값은 mean0 및 저장된 값 stored_sigma 의 값은 sigma0.

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

예제

 

// std_tr1__random__normal_distribution_construct.cpp 
// compile with: /EHsc 
#include <random> 
#include <iostream> 
 
typedef std::ranlux64_base_01 Myeng; 
typedef std::normal_distribution<double> Mydist; 
int main() 
    { 
    Myeng eng; 
    Mydist dist(1.5, 2.0); 
    Mydist::input_type engval = eng(); 
    Mydist::result_type distval = dist(eng); 
 
    distval = distval;  // to quiet "unused" warnings 
    engval = engval; 
 
    std::cout << "mean == " << dist.mean() << std::endl; 
    std::cout << "sigma == " << dist.sigma() << 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>

normal_distribution Class