<random>

公有成員函式
<random>

std::lognormal_distribution::(建構函式)

(1)
explicit lognormal_distribution ( result_type m = 0.0, result_type s = 1.0 );
(2)
explicit lognormal_distribution ( const param_type& parm );
構造對數正態分佈
構造一個 lognormal_distribution 物件,採用由 ms 指定的分佈引數,或由物件 parm 指定的分佈引數。

引數

m
此分佈中可能值的對數變換所形成的底層正態分佈的均值。
result_type是一個成員型別,表示每次呼叫 operator() 時生成的隨機數的型別。它被定義為第一個類模板引數(實數型別 (RealType)).
s
此分佈中可能值的對數變換所形成的底層正態分佈的標準差。
此值應為正值 (s>0)。
result_type是一個成員型別,表示每次呼叫 operator() 時生成的隨機數的型別。它被定義為第一個類模板引數(實數型別 (RealType)).
parm
表示分佈引數的物件,透過呼叫成員函式 param 獲得。
param_type是一個成員型別。

示例

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
// lognormal_distribution example
#include <iostream>
#include <chrono>
#include <random>

int main()
{
  // construct a trivial random generator engine from a time-based seed:
  unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
  std::default_random_engine generator (seed);

  std::lognormal_distribution<double> distribution (0.0,1.0);

  std::cout << "some lognormal-distributed(0.0,1.0) results:" << std::endl;
  for (int i=0; i<10; ++i)
    std::cout << distribution(generator) << std::endl;

  return 0;
}

可能的輸出
some lognormal-distributed(0.0,1.0) results:
1.76931
0.426828
2.13448
3.41825
0.574683
1.7239
1.49771
1.27637
0.371665
1.13434


複雜度

常量。

另見