Skip to content

Weighting data with normal distribution

2 messages · Alice Lin, Mark Lyman

#
I have a vector of binary data ? a string of 0?s and 1?s. 
I want to weight these inputs with a normal kernel centered around entry x
so it is transformed into a new vector of data that takes into account the
values of the entries around it (weighting them more heavily if they are
near).

Example:
      -
   -     -
-          -
0 1 0 0 1 0 0 1 1 1 1 
If x = 3, it?s current value is 0 but it?s new value with the Gaussian
weighting around would be something like .1*0+.5*1+1*0+0.5*0+.1*1= 0.6

I want to be able to play with adjusting the variance to different values as
well.
I?ve found wkde in the mixtools library and think it may be useful but I
have not figured out how to use it yet.

Any tips would be appreciated.

Thanks!
#
Alice Lin <alice.ly <at> gmail.com> writes:
I don't know anything about wkde. But the filter function in stats package 
should do what you want.
Time Series:
Start = 1 
End = 11 
Frequency = 1 
 [1]  NA  NA 0.6 0.6 1.0 0.6 0.7 1.6 2.1  NA  NA

In the signal package, there is also a variety of windows, including the 
gausswin function. However, the filter function in the signal package masks the 
filter function from the stats package
Mark Lyman
Statistician, ATK Launch Systems