Input: fraction F, seed S, then a CSV sensor,pm25. Outliers are readings above Q3 + 1.5 × IQR.
- Print
200 readings, 4 outliers above 51. - Draw a random sample of round(F × n) readings without replacement with
rng = np.random.default_rng(S)andrng.choice(n, size, replace=False)(rows kept in original order). Printrandom 10% sample: 20 readings, outliers kept 0 of 4, max 45 (true max 140). - With the same generator (next call), keep all outliers plus a random round(F × number of normal readings) of the normal ones:
outliers + 10% of the rest: 24 readings, outliers kept 4 of 4, max 140. - Print
mean pm25: all 36.1, random sample 34.4.