New Dyalog Operator – Power

Smooth running medians of 3

med3←{1⌽⍵[1⌽1,⍴⍵],{(+/⍵)-(⌊/⍵)+⌈/⍵}⊃3,/⍵}

Old approach

⊃x (med3 x)(med3 med3 x)
14 76 46 54 22  5 68 94 39
14 46 54 46 22 22 68 68 39
14 46 46 46 22 22 68 68 39

Now it’s possible
⊃x ((med3⍣1) x)((med3⍣2) x) ((med3⍣3) x)
14 76 46 54 22  5 68 94 39
14 46 54 46 22 22 68 68 39
14 46 46 46 22 22 68 68 39
14 46 46 46 22 22 68 68 39

Or even iterate until the result is stabilized

(med3⍣≡) x
14 46 46 46 22 22 68 68 39

Добавить комментарий

Please log in using one of these methods to post your comment:

Логотип WordPress.com

You are commenting using your WordPress.com account. Log Out / Изменить )

Фотография Twitter

You are commenting using your Twitter account. Log Out / Изменить )

Фотография Facebook

You are commenting using your Facebook account. Log Out / Изменить )

Connecting to %s

Follow

Get every new post delivered to your Inbox.