Writing already defined function

Hi,
I always face difficulty in writing the code with built function. Here is an example which I tried to calculate the CDF. Is there any any to solve my problem?

{
double x = 1.5;
double a = 2.0;
double b = 5.2;
double p =  double ROOT::Math::beta_cdf_c (x, a, b);

double y = double ROOT::Math::binomial_cdf(unsigned int k = 5, double 	p1 = 5.0, unsigned int 	n= 100);	
cout <<" p: " << p << endl;
cout <<" y: " << y << endl;

 }

I tried both both way and get error on both.
Thank you
Kanhaiya Gupta

_Please read tips for efficient and successful posting and posting code

ROOT Version: Not Provided
Platform: Not Provided
Compiler: Not Provided


What errors did you get? All I can tell is that this line:

double p = double ROOT::Math::beta_cdf_c (x, a, b);

Should be

double p = ROOT::Math::beta_cdf_c (x, a, b);

And this one:

double y = double ROOT::Math::binomial_cdf(unsigned int k = 5, double p1 = 5.0, unsigned int n= 100);

Should be:

double y = ROOT::Math::binomial_cdf(5, 5.0, 100);

root [11] .x n.C
Error: Invalid type ‘unsigned’ in declaration of ‘int k’ n.C:8:
Error: Invalid type ‘double’ in declaration of ‘p1’ n.C:8:
Error: Invalid type ‘unsigned’ in declaration of ‘int n’ n.C:8:
*** Interpreter error recovered ***

See my previous (edited) post

My question:

can you tell when I to have to write
ROOT::Math::beta_cdf_c instead
double ROOT::Math::beta_cdf_c ?

This is not a valid C++ syntax !
It should be:

double p = ROOT::Math::beta_cdf_c (x, a, b);

Lorenzo

Thanks.

Your code should look like:

{
double x = 1.5;
double a = 2.0;
double b = 5.2;
double p = ROOT::Math::beta_cdf_c(x, a, b);

double y = ROOT::Math::binomial_cdf(5, 5.0, 100);
cout <<" p: " << p << endl;
cout <<" y: " << y << endl;
}

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.