Re: [Python-ideas] NAN handling in the statistics module

2019-01-08 Thread Steven D'Aprano
On Tue, Jan 08, 2019 at 04:25:17PM +0900, Stephen J. Turnbull wrote: > Steven D'Aprano writes: > > > By definition, data containing Not A Number values isn't numeric :-) > > Unfortunately, that's just a joke, because in fact numeric functions > produce NaNs. I'm not sure if you're agreeing with

Re: [Python-ideas] NAN handling in the statistics module

2019-01-08 Thread Tim Peters
I'd like to see internal consistency across the central-tendency statistics in the presence of NaNs. What happens now: mean: the code appears to guarantee that a NaN will be returned if a NaN is in the input. median: as recently detailed, just about anything can happen, depending on how undefi

Re: [Python-ideas] NAN handling in the statistics module

2019-01-08 Thread Steven D'Aprano
On Mon, Jan 07, 2019 at 11:27:22AM +1100, Steven D'Aprano wrote: [...] > I propose adding a "nan_policy" keyword-only parameter to the relevant > statistics functions (mean, median, variance etc), and defining the > following policies: I asked some heavy users of statistics software (not just

Re: [Python-ideas] NAN handling in the statistics module

2019-01-08 Thread David Mertz
On Tue, Jan 8, 2019 at 11:57 PM Tim Peters wrote: > I'd like to see internal consistency across the central-tendency > statistics in the presence of NaNs. What happens now: > I think consistent NaN-poisoning would be excellent behavior. It will always make sense for median (and its variants).

Re: [Python-ideas] NAN handling in the statistics module

2019-01-08 Thread Tim Peters
[David Mertz ] > I think consistent NaN-poisoning would be excellent behavior. It will > always make sense for median (and its variants). > >> >>> statistics.mode([2, 2, nan, nan, nan]) >> nan >> >>> statistics.mode([2, 2, inf - inf, inf - inf, inf - inf]) >> 2 > > > But in the mode case, I'm not