# HP Forums

Full Version: Winsorising
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
hi,
a program to make the winsorising of a data set for statistical purpose.
See here in Wikipedia: «Winsorising or Winsorisation is the transformation of statistics by limiting extreme values in the statistical data to reduce the effect of possibly spurious outliers. It is named after the engineer-turned-biostatistician Charles P. Winsor (1895–1951)...»
Values must be already in Statistic 1var (D1 matrix). The program put the resulting items in D2.

Enjoy!

Salvo Micciché

Code:
``` EXPORT winsorising(p) // Data in Statistic 1var; p -> i.e. 90 = 90%, from 5th to 95th percentile) BEGIN LOCAL q1, q2, j; q1 := quantile(D1, (100-p)/100); q2 := quantile(D1, p/100); D2 := D1; FOR j FROM 1 TO size(D1) DO     IF D1(j) < q1 THEN D2(j):= q1; END;     IF D1(j) > q2 THEN D2(j):= q2; END; END; RETURN D2; END;```
Reference URL's
• HP Forums: https://www.hpmuseum.org/forum/index.php
• :