Is there a clean way to remove repeating values from waves? I have waves that sometimes have duplicates or triplicates of a number and I would like to keep only one instance. I have looked in the forum and manual but I haven't spotted anything like a function that may help in doing this. I was thinking of sorting and creating two lists to move numbers from one to the other after parsing through but any ideas are appreciated.
Just for clarification: You want unique INTEGERS in the wave (and not just zap consecutive occurrences)?
Maybe this could serve as a first idea (result is sorted):
make/N=6 test ={1,1,3,4,4,1}make/N=10 hist // Probably needs to be adjusted to the minimum and maximum values of the wavehistogram/B={0,1,10} test, hist // here as well
hist= (hist==0) ? nan : pwavetransform ZapNaNs hist
[quote=_sk]Here is my take on it. Zaps all repeating integers after the first one.
Invoke it like: thunk_zapnum(w_wave, 5)[/quote]
The code is limited to Integer values and you would have to loop over a list of integers which you want to remove.
If you just wanted to remove a specific value from a wave it is simpler to execute:
MatrixOP/O aa=replace(w_wave,specificValue,NaN)WaveTransform zapNaNs aa
Note that in this example specificValue is any real-value and strict equality is required, something that FindDuplicates handles via the Tolerance flag.
MatrixOP/O aa=replace(w_wave,specificValue,NaN)WaveTransform zapNaNs aa
..
A.G.[/quote]
This will also remove the first instance of the duplicate integer, which I interpreted as a requirement of the poster. If this isn't the case, then, indeed, there is no need for looping through the indeces of the duplicate integer.
[quote=_sk]
This will also remove the first instance of the duplicate integer, which I interpreted as a requirement of the poster. If this isn't the case, then, indeed, there is no need for looping through the indeces of the duplicate integer.
_sk[/quote]
You are absolutely right. It will remove all instances.
Maybe this could serve as a first idea (result is sorted):
Beware of floats !
HJ
August 22, 2017 at 03:00 pm - Permalink
A.G.
WaveMetrics, Inc.
August 22, 2017 at 03:41 pm - Permalink
August 22, 2017 at 06:09 pm - Permalink
Invoke it like:
thunk_zapnum(w_wave, 5), wherew_waveis your wave,5is the number you want to zap.best,
_sk
August 23, 2017 at 01:17 am - Permalink
Invoke it like:
thunk_zapnum(w_wave, 5)[/quote]The code is limited to Integer values and you would have to loop over a list of integers which you want to remove.
If you just wanted to remove a specific value from a wave it is simpler to execute:
Note that in this example specificValue is any real-value and strict equality is required, something that FindDuplicates handles via the Tolerance flag.
A.G.
August 23, 2017 at 10:59 am - Permalink
..
..
A.G.[/quote]
This will also remove the first instance of the duplicate integer, which I interpreted as a requirement of the poster. If this isn't the case, then, indeed, there is no need for looping through the indeces of the duplicate integer.
best,
_sk
August 23, 2017 at 12:41 pm - Permalink
This will also remove the first instance of the duplicate integer, which I interpreted as a requirement of the poster. If this isn't the case, then, indeed, there is no need for looping through the indeces of the duplicate integer.
_sk[/quote]
You are absolutely right. It will remove all instances.
August 23, 2017 at 05:51 pm - Permalink