Field-Map Scripting

4.1.3.2.21 Example

Example (Statistics):


// Functions listed in this chapter are mainly focused on simplifying of calculations of some descriptive statistics ...

begin
  Plots['Mean'] := Mean(Data.Table, 'Data', false);
  Plots['QuadraticMean'] := QuadraticMean(Data.Table, 'Data', false);
  Plots['Median'] := Median(Data.Table, 'Data', false);

  Plots['StDev'] := StandardDeviation(Data.Table, 'Data', false);
  Plots['Variance'] := SampleVariance(Data.Table, 'Data', false);

  Plots['StandError'] := StandardError(StandardDeviation(Data.Table, 'Data', false), Data.RecordCount);
  Plots['MeanError'] := MeanError(StandardDeviation(Data.Table, 'Data', false), Data.RecordCount);
  Plots['VarOfMean'] := VarianceOfMean(Data.Table, 'Data', false, Data.RecordCount, 10000);
  Plots['CIF'] := ConfidenceIntervalOfMean(Data.RecordCount, VarianceOfMean(Data.Table, 'Data', false, Data.RecordCount, 10000), 5);

  Plots['WMean'] := WeightedMean(Data.Table, 'Data', 'Weight', false);
  Plots['WVariance'] := WeightedSampleVariance(Data.Table, 'Data', 'Weight', false);
  Plots['WStDev'] := WeightedStandardDeviation(Data.Table, 'Data', 'Weight', false);
  Plots['WVarianceOfMean'] := WeightedVarianceOfMean(Data.Table, 'Data', 'Weight', false, Data.RecordCount, 10000);  

  Plots['SampleSize'] := SampleSize(0.01, SampleVariance(Data.Table, 'Data', false), Mean(Data.Table, 'Data', false), 5);

// ... however, you can also use them for calculations of other statistics.

Plots['CoefficientOfVariation'] := StandardDeviation(Data.Table, 'Data', false)/Mean(Data.Table, 'Data', false)

end.


// Moreover, scripts performing one-sample hypothesis testing can be simply introduced ...


var

  alpha: integer;
  mu: integer;
  UpperLimit, LowerLimit: double;

begin

// First, you ask the operator to input data necessary for calculations, i.e. expected mean and alpha ...

alpha := InputInteger('Alpha of Students One-Sample test', 'Insert confidence level Alpha (0-100)');
mu := InputInteger('Mu', 'Insert the expected mean');

// ... then the upper and lower limit of confidence interval of true mean is calculated ...

UpperLimit := Mean(Data.Table, 'Data', false) + 0.5*(ConfidenceIntervalOfMean(Data.RecordCount, VarianceOfMean(Data.Table, 'Data', false, Data.RecordCount, 1500), alpha));

LowerLimit := Mean(Data.Table, 'Data', false) - 0.5*(ConfidenceIntervalOfMean(Data.RecordCount, VarianceOfMean(Data.Table, 'Data', false, Data.RecordCount, 1500), alpha));

// ... and finally you decide whether the expected mean is inside or outside the confidence interval.

 if (mu>LowerLimit) and (mu<UpperLimit) then ShowMessage('True mean of sample DOES NOT significantly differ from expected mean on confidence level ' + Variant2String(alpha) + ' %')
  else
  ShowMessage('True mean of sample DOES significantly differ from expected mean on confidence level ' + Variant2String(alpha) + ' %')


end.




See also:

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


Example