2.1.17.8.22.2 y50


Description

Get the 50th percentile of vector.

Syntax

double y50( vector & vec )

Parameters

vec
[input] Origin C vector object

Return

Returns the 50th percentile of vector.

Examples

EX1

// This is a self contained sample program for the function y50, 
// Its sample data is created at the beginning of the program. 
// To run the program, enter the following command in the Script window:
//   y50_ex1
// It returns like:
//   50th Percentile of Book2_B = 0.35628
//
void y50_ex1()
{ 
    Worksheet wks;
    wks.Create();
    Dataset myDs(wks, 1);
    String strDsName = myDs.GetName();
 
    //******* Create sample data *****************
    myDs.SetSize(8);
    myDs[0]=0.3; 
    myDs[1]=0.097; 
    myDs[2]=0.41256;
    myDs[3]=0.24909;
    myDs[4]=0.47304;
    myDs[5]=0.2476;
    myDs[6]=0.64529;
    myDs[7]=0.44514;
    myDs.Sort();
    //******** End of Sample Data Creation *******
 
    vector vVal = myDs;
    double dP50 = y50(vVal);
 
    printf("50th Percentile of %s = %g\n",strDsName, dP50);
}

Remark

Let the i\,th percentile be y, setp=i/100\, , n is the number of data points, and let  np=(j+g) \,

where j is the integer part of np, and g is the fractional part of np, then different methods define the i^{th}\, percentile, y, as described by the following.

y = 
\begin{cases} 
 \frac 12(x(j)+x(j+1)),& \mbox{if }\ g=0 \\
  x_(j+1),& \mbox{if }\ g>0
\end{cases}

Get the 50th percentile of a vector(Not suppotted Dataset after version 8.0).

See Also

y25, y75

Header to Include

origin.h

Reference