cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
The Discovery Summit 2025 Call for Content is open! Submit an abstract today to present at our premier analytics conference.
Choose Language Hide Translation Bar
View Original Published Thread

Calculate empirical median

Feli
Level IV

There are two definitions of the median: one as the 0.5 quantile of a (probability) distribution, the other as the "middle element" of a finite list ( Wikipedia median ).

I know how to calculate the former, but does anybody know a JMP function or elegant, fast way to calculate the latter for implementing in a rolling median in a formula column?

Creating a small list, sorting this, getting the middle value ... does not appear to be efficient to do for every row in a long table

1 REPLY 1
Victor_G
Super User


Re: Calculate empirical median

Hi @Feli,

 

I think the function "Col Median()" might be useful in your case, as the scripting index mentions that "the ordering is cached internally so that multiple evaluations will be efficient". You can also specify a "By" group variable.
Example on the Big class dataset from the scripting index (menu Help, Scripting Index), with a formula for median height calculated for each Age group:

 

dt << New Column( "Col Median Height by Age",
	numeric,
	continuous,
	formula( Col Median( :height, :age ) )
);

I hope this answer will help you,

Victor GUILLER

"It is not unusual for a well-designed experiment to analyze itself" (Box, Hunter and Hunter)