[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #54567] median(uint8) gives bad results
From: |
Dan Sebald |
Subject: |
[Octave-bug-tracker] [bug #54567] median(uint8) gives bad results |
Date: |
Fri, 24 Aug 2018 15:22:27 -0400 (EDT) |
User-agent: |
Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:61.0) Gecko/20100101 Firefox/61.0 |
Follow-up Comment #1, bug #54567 (project octave):
The question is whether Matlab does the arithmetic using the intrinsic
variable type. The median() routine is supposed to return the same variable
type, but that doesn't necessarily mean the average of the center values
should be computed using that type. Why should it, I guess? In fact, mean()
appears to do its arithmetic not using native, but instead converts it
afterward:
octave:12> u = [1 140 140 255];
octave:13> u8 = uint8(u);
octave:14> mean(u)
ans = 134
octave:15> mean(u8)
ans = 134
So, attached a patch to change the behavior for median. Basically it uses
mean() instead of sum() with the assumption that the proper averaging behavior
is already baked into mean(). I added a couple more tests as well.
(file #44857)
_______________________________________________________
Additional Item Attachment:
File name: octave-median_even_averaging-djs2018aug24.patch Size:1 KB
_______________________________________________________
Reply to this item at:
<http://savannah.gnu.org/bugs/?54567>
_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/
- [Octave-bug-tracker] [bug #54567] median(uint8) gives bad results, anonymous, 2018/08/24
- [Octave-bug-tracker] [bug #54567] median(uint8) gives bad results,
Dan Sebald <=
- [Octave-bug-tracker] [bug #54567] median(uint8) gives bad results, Kai Torben Ohlhus, 2018/08/24
- [Octave-bug-tracker] [bug #54567] median(uint8) gives bad results, Kai Torben Ohlhus, 2018/08/24
- [Octave-bug-tracker] [bug #54567] median(uint8) gives bad results, Dan Sebald, 2018/08/24
- [Octave-bug-tracker] [bug #54567] median(uint8) gives bad results, Dan Sebald, 2018/08/24
- [Octave-bug-tracker] [bug #54567] median(uint8) gives bad results, Kai Torben Ohlhus, 2018/08/25
- [Octave-bug-tracker] [bug #54567] median(uint8) gives bad results, Michael Godfrey, 2018/08/25
- [Octave-bug-tracker] [bug #54567] median(uint8) gives bad results, Dan Sebald, 2018/08/25
- [Octave-bug-tracker] [bug #54567] median(uint8) gives bad results, Rik, 2018/08/25
- [Octave-bug-tracker] [bug #54567] median(uint8) gives bad results, Dan Sebald, 2018/08/26
- [Octave-bug-tracker] [bug #54567] median(uint8) gives bad results, Dan Sebald, 2018/08/26