how to calculate mean of erased outlier and insert them in their place

2 visualizaciones (últimos 30 días)
Sehoon Chang
Sehoon Chang el 6 de Abr. de 2020
Comentada: Tommy el 7 de Abr. de 2020
dear all,
using the code "rmoutlier", i was able to detect outliers as i intended.
But instead of deleting the outlier and thus making the sample size smaller, i was planning to calculate a mean at the location of the outlier using pre- & post-outliers value.
Situation)
I had a value W with idx variables.
Using rmoutlier and 'quartiles', i deleted all the outliers and got a new vector W_rmoutlers (with smaller amout of arrays due to deletion of outliers) and OutlierPosition.
OutlierPosition is another vector product that shows which value within W(idx) were outliers with 1/0. 1 being outlier and 0 being non-outlier.
ex)
[W_rmoutliers,OutlierPosition] = rmoutliers(W(idx),'quartiles')
W_rmoutliers = [2 2 2 2 3 3 3 3 1 1 2 2 5 5 3 3 .................]
OutlierPosition = [0 0 0 0 0 0 0 1 1 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 0 0 1 0 0 0 1 1 ......................]
searching)
using find code, i was able to locate the position of deleted outlier
OutlierPosition2 = find(OutlierPosition)
OutlierPosition2 = [8 9 14 15 16 .......]
As you may see, there are outliers that have been found in succesive order.
How may i calculte the mean values using pre- & post-OutlierPosition2 value
and place the calculated mean value back in the erased position of the original vector?
Thanks all.
  1 comentario
Tommy
Tommy el 7 de Abr. de 2020
What do you mean by pre- and post- outlier value?
You can get the outliers with
W(OutlierPosition)
and you can find the mean value of these outliers with
mean(W(OutlierPosition))
If you want to replace every outlier in W with this mean value, you can use
W(OutlierPosition) = mean(W(OutlierPosition))

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Descriptive Statistics en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by