FUNCTION
Prob
Calculates the probability that values in a range are between two limits.
Interface
#include <codecogs/statistics/moments/prob.h>
using namespace Statistics::Moments;
Returns the probability that values in a range are between two limits. If upper limit y is not supplied, then it returns the probability that values in data are equal to lower limit. If the data array does not sum to 1 or if one of its components are null, the function exits.
Example 1
#include <codecogs/statistics/moments/prob.h>
#include <iostream>
int main()
{
int x[5]={1, 2, 3, 4, 5};
double y[5] ={0.1, 0.2, 0.3, 0.2, 0.2};
double rez = Stats::Moments::prob<int>(5,x,y,2,4);
std::cout << "The probability is: " << rez << std::endl;
return 0;
}Output:
The probability is: 0.7Parameters
n
the size of the data and of the prob
data
is the range of numeric values of x with which there are associated probabilities
prob
is a set of probabilities associated with values in data
x
is the lower bound on the value for which you want a probability.
y
Default Value = INT_MAX
Returns
returns the probability that values in a range are between two limits
This function's source code is only visible to registered users — documentation and the calculator above are free to use either way. Sign in to see it.