Advanced Octave A25 — Robust estimation and unusual observations

by Giux GX-TXT, octave-en, scripts-en 2 min read

Advanced GNU Octave with GX-TXT · Module 05

A value very distant from others can strongly influence an average. Mediana and absolute median deviation, or MAD, offer complementary information, but do not automatically decide whether an observation is wrong.

Objectives and data

We repeat the descriptive statistics of the introductory course and compare two small synthetic samples with NUMERIC_API_v1/statistics and mad. The test uses GX-TXT dev112-P011-bis and GNU Octave 9.4.0. The values are didactic numbers without assigned physical units, not measures.

The first sample is [9,8; 10,1; 10,0; 10,2; 9,9]; in the second we replace the last value with 30,0. It is a deliberate change to study the sensitivity of statistics.

Compare media, median and MAD

Import stime_robuste.m, record it in the Session and start it in the Runner.

For each sample the script calls:

stats = gxtxt_api_call('NUMERIC_API_v1','statistics',{x});
robust = gxtxt_api_call('NUMERIC_API_v1','mad',{x});

The first service returns, among other fields, median, and variance; the second returns the MAD and the scale convention used. The raw MAD is the median of the absolute wastes from the sample median. A rescaled version should be distinguished from the crude one, checking the scale field.

In the test the first sample has average 10,0 and median 10,0. In the second half it becomes 14,02, the median 10,1 and the raw MAD 0,1. The great value moves the average a lot, while the effect on the median is more contained in this example. The figure also shows scale = raw : we must not present that value as a standard deviation without any additional assumptions and appropriate conversions.

Interpreting an abnormal value

A distant value may result from a mistake, from a rare real condition or from a process change. Before excluding verification of origin, instrument, unity, context and criteria established. Keep the original data and document every choice; compare, when useful, results with and without observation, explaining both.

Robustness does not mean absolute immunity or superiority in every situation. With five comments, the information is limited and we cannot deduce a general distribution from the summary alone.

Exercise

  1. What statistics change most in the example: median or median?
  2. What does the scale = raw field mean associated with the MAD?
  3. Is it correct to delete the value 30 just because it is distant from others?

Worked solution

  1. The average: switches from 10,0 to 14,02.
  2. That is reported the absolute crude median deviation, without the scale factor of other conventions.
  3. No. It serves a motivation based on quality, context and method, documenting the decision.

Download the Module 05 scripts (ZIP)

#GNU Octave #GX-TXT #GX-TXT public APIs

Other steps of this project

Leave a Reply

Your email address will not be published. Required fields are marked *