📌  相关文章
📜  C++中的cauchy_distribution a()与示例

📅  最后修改于: 2021-05-26 01:25:01             🧑  作者: Mango

cauchy_distribution :: a()函数是C++ STL中的内置函数,用于返回与Cauchy分布关联的分布参数。头文件random中存在类cauchy_distribution。在转到函数的语法之前,请先对Cauchy分布进行简要介绍。

柯西分布如果随机变量X具有以下形式的概率密度函数,则称其随参数a和b跟随柯西分布:
 f(x)=\frac{1}{\pi b[1+(\frac{x-a}{b})^2]}

其中a是位置参数,指定分布峰的位置,b是scale参数,指定最大宽度的一半。分布的均值和方差未定义,但其中位数和众数均存在且等于a。

句法:

cauchy_distribution_name.a()

参数:该函数不接受任何参数。

返回值:该函数返回与分布关联的分布参数。此参数称为柯西分布的峰值位置参数,该参数确定向分布形状的任一侧的偏移。该参数在构造时设置。

下面的程序说明了C++ STL中的cauchy_distribution :: a()函数:

程序1:

// CPP program to illustrate
// cauchy_distribution::a()
#include 
#include 
using namespace std;
  
// Driver program
int main()
{
    default_random_engine generator;
    cauchy_distribution d(0.78, 1.45);
  
    // prints the first value
    cout << "Cauchy distribution: " << d.a();
  
    return 0;
}
输出:
Cauchy distribution: 0.78

程式2:

// CPP program to illustrate
// cauchy_distribution::a()
#include 
#include 
using namespace std;
  
// Driver program
int main()
{
    default_random_engine generator;
  
    // Define a cauchy distribution with default 
    // parameters a=0.0 and b=1.0
    cauchy_distribution d;
  
    // prints the first value
    cout << "Cauchy distribution: " << d.a();
  
    return 0;
}
输出:
Cauchy distribution: 0
要从最佳影片策划和实践问题去学习,检查了C++基础课程为基础,以先进的C++和C++ STL课程基础加上STL。要完成从学习语言到DS Algo等的更多准备工作,请参阅“完整面试准备课程”