Get range around median containing specified percentage of values.

Namespace:  AForge.Math
Assembly:  AForge.Math (in AForge.Math.dll) Version: 2.2.5.0 (2.2.5.0)

Syntax

C#
public static IntRange GetRange(
	int[] values,
	double percent
)

Parameters

values
Type: array< System..::.Int32 >[]()[]
Histogram array.
percent
Type: System..::.Double
Values percentage around median.

Return Value

Returns the range which containes specifies percentage of values.

Remarks

The input array is treated as histogram, i.e. its indexes are treated as values of stochastic function, but array values are treated as "probabilities" (total amount of hits).

The method calculates range of stochastic variable, which summary probability comprises the specified percentage of histogram's hits.

Sample usage:

CopyC#
// create histogram array
int[] histogram = new int[] { 1, 1, 2, 3, 6, 8, 11, 12, 7, 3 };
// get 75% range around median
IntRange range = Statistics.GetRange( histogram, 0.75 );
// output it ([4, 8])
Console.WriteLine( "range = [" + range.Min + ", " + range.Max + "]" );

See Also