cauchy_distribution a() in C++ with Examples
Last Updated :
16 Oct, 2018
The cauchy_distribution::a() function is an inbuilt function in C++ STL which is used to returns the distribution parameter associated with Cauchy distribution. The class cauchy_distribution is present in header file random. Before going to the syntax of the function, brief introduction to Cauchy Distribution.
Cauchy Distribution A random variable X is said to follow Cauchy Distribution with parameter a and b if it has the probability density function of the form,
Where a is the location parameter specifying the location of peak of the distribution and b is the scale parameter specifying the half-width at half-maximum. Mean and Variance of the distribution is not defined, but its median and mode both exists and equals to a.
Syntax:
cauchy_distribution_name.a()
Parameters: This function does not accepts any parameter.
Return Value: The function returns the distribution parameter associated with the distribution. This parameter is known as the peak location parameter of the Cauchy distribution, which determines the shift to either side of the distribution shape. The parameter is set on construction.
Below programs illustrates the cauchy_distribution::a() function in C++ STL:
Program 1:
#include <iostream>
#include <random>
using namespace std;
int main()
{
default_random_engine generator;
cauchy_distribution< double > d(0.78, 1.45);
cout << "Cauchy distribution: " << d.a();
return 0;
}
|
Output:
Cauchy distribution: 0.78
Program 2:
#include <iostream>
#include <random>
using namespace std;
int main()
{
default_random_engine generator;
cauchy_distribution< double > d;
cout << "Cauchy distribution: " << d.a();
return 0;
}
|
Output:
Cauchy distribution: 0
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...