CStats:Rank


The Rank method computes the rank percentile and standard deviation for a data sample based on the nPercentile value in the data sample. The sample may be a Lua table or a class object of type CImage, CArray, or CMatrix. For CImage and CMatrix objects, an optional CRect object can be used to define the points used in the calculation.

Syntax

nRank, nStdDev = CStats:Rank( table, nPercentile )

nRank, nStdDev = CStats:Rank( CImage, nPercentile )

nRank, nStdDev = CStats:Rank( CImage, nPercentile, CRect )

nRank, nStdDev = CStats:Rank( CArray, nPercentile )

nRank, nStdDev = CStats:Rank( CArray, nPercentile, CRect )

nRank, nStdDev = CStats:Rank( CMatrix, nPercentile )

where

    table, CImage, CArray, and CMatrix are class objects containing the data to measure,

    CRect is a CRect rectangle object that defines the region to measure.

    nPercentile is a number in the range 0 through 100.

    nRank and nStdDev are rank percentile and standard deviation of the data. On failure, 0,0 is returned.

Example

Suppose that CImage object I and CRect object R exist. The following script returns the value for the 32.5 percentile rank inside a rectangle on the image:

S = CStats:new()

-- create a CStats object

nVal = S:Rank( I, 32.5, R )

-- returns the value at the 32.5 percentile

Printf("rankval=%lg\n", nVal)

-- list the results

The following script returns the 60 percentile rank value in a table of data:

S = CStats:new()

-- create a CStats object

t = { 4,1,4,2,2.1,5,6.4,2,-1.4,-.5,3,4 }

-- create some data in a table

Printf("mean=%lg\n", S:Rank(t,60) )

-- list the result

Related Topics

Median

CStats Class