A mode of a sample is not ill-defined, it is just not unique. Neither is a median, if you are interested in probability.
You can encapsulate mode, median and mean in a single formula. Suppose y is a data vector and t is a scalar. The a value of t which minimizes +/ (|y-t)^i [with special meaning for x^0: see below] is - A mode of y if i=0. -A median of y if i=1. -The mean of y if i=2. Here x^0 meas 1 if x=0 and 0 if x is nonzero. John ________________________________ From: Programming <[email protected]> on behalf of Devon McCormick <[email protected]> Sent: Friday, July 24, 2020 2:35 PM To: J-programming forum <[email protected]> Subject: [Jprogramming] Standard library version of statistical "mode"? Hi - I've started reading "Fun Q" which is a book on machine learning using the q language. Early on, the author points out that his "mode" function - where "mode" is stats-talk for "the most frequent observation" - is order-dependent. I checked my own "mode" and found that this is true of mine as well: mode ~. {~ [: (i. >./) #/.~ mode 1 2 2 3 3 2 mode 1 3 3 2 2 3 This might be an ill-defined statistical concept but does anyone have any insight based on practice? Is this order-dependence just a weakness of the definition of "mode"? I could not find "mode" defined in any of the J standard libraries. Thanks, Devon -- Devon McCormick, CFA Quantitative Consultant ---------------------------------------------------------------------- For information about J forums see https://nam02.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.jsoftware.com%2Fforums.htm&data=02%7C01%7Crandall%40newark.rutgers.edu%7C9268e894e1b04ca93df908d830006906%7Cb92d2b234d35447093ff69aca6632ffe%7C1%7C0%7C637312125620292237&sdata=xvY7cIgqsxRSEHWlcFSPefOJ1pLu%2FJXciQbm10AMS4o%3D&reserved=0 ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
