Field-Map Scripting

4.1.3.2.4 Median

Median function


Prototype:

function Median (TableOrLayer :TObjectWrapper; const AttributeName :string; const NullAsZero :boolean) : extended;

Description:

Calculates median of a specific attribute

Syntax:

variable := Median (tab, AttributeName, NullAsZero);


Part

Description


variable

A variable declared as type of extended


tab

Table containing source variables


AttributeName

Attribute of source table containing data to enter calculations


NullAsZero

Boolean expression defining whether to exclude null (false) entries or replace nulls with zeros (true)







Return value:

Median



Example:


Task:

Calculate median of DBH.


Data stored in the database.



Script:

var

 tab : TTableWrapper;

 attributeName: string;

 nullAsZero: boolean;

 x: extended;


begin

 tab:= Trees.table;

 attributeName:= 'DBH_mm';

 nullAsZero:= false;                    // dont want calculate with a null value


 x:= Median(tab, attributeName, nullAsZero);


 ShowMessage(FloatToStr(x));

end.


Output in Field-Map Data Collector:

median of DBH


See also:

Mean; QuadraticMean; WeightedMean; Median; SampleVariance; StandardDeviation; StandardError; MeanError;VarianceOfMean; WeightedSampleVariance; WeightedStandardDeviation; WeightedVarianceOfMean;ConfidenceIntervalOfMean; VarianceOfTotal; ConfidenceIntervalOfTotal; StratifiedConfidenceIntervalOfTotal; SampleSize;ShowDistributionChart; ParameterizeRegressionModel; CalculateModelValue


Example