【Percentile】
[code]inputs:PctRank( numericsimple ),
PriceValue( numericseries ),
Len( numericsimple ) ;
variables:
var0( 0 ),
var1( 0 ),
var2( 0 ),
var3( 0 ) ;
arrays:
arr0[1000]( 0 ) ;
Condition1 = PctRank >= 0 and PctRank <= 1 ;
condition1 = Condition1 and Len > 1 ;
if condition1 then
begin
for Value1 = 1 to Len
begin
arr0[Value1] = PriceValue[ Value1 - 1 ] ;
end ;
Value1 = SortArray( arr0, Len, -1 ) ;
var0 = 1 / ( Len - 1 ) ;
var1 = IntPortion( PctRank / var0 ) + 1 ;
var2 = var1 + 1 ;
var3 = ( PctRank - ( ( var1 - 1 ) * var0 ) ) / var0 ;
Percentile = ( arr0[var1] ) + ( var3 * ( arr0[var2]
- arr0[var1] ) ) ;
end
else
begin
condition1 = Condition1 and Len = 1 ;
if condition1 then Percentile = PriceValue
else
Percentile = -1 ;
end;
[/code]
页:
[1]