Hi,
I am looking for a simple thing: the median of an array.
I found complex things with tabulate, summary tables,...But I need simpler:
Suppose I have an array (Matrix) A:
A = 1::10;
How to get the media of A ??
Thank you.
Hi @samir,
You can use the quantile function without and with a by variable as shown in the example below.
Names Default To Here( 1 ); Open( "$SAMPLE_DATA/Big Class.jmp" ); Row() = 1; median_ht = Col Quantile( :height, 0.5 ); Row() = 1; median_htbyage = Col Quantile( :height, 0.5, :age ); Show( median_ht ); //Show median height Show( median_htbyage ); //Show median height by age<BR /><BR /><BR />
Col Median Function
cheers,
Stan
@stan_koprowski, While I thought of this, I think @samir was asking, how the same can be calculated for a matrix not from a data table ? I looked at the scripting index, there does not seem a direct way to compute the quantiles or median for a matrix (unless I missed it)
Hi @uday_guntupalli,
You could do the same with a matrix as follows--
Names Default To Here( 1 ); Open( "$SAMPLE_DATA/Big Class.jmp" ); htmat = :height<<Get As Matrix; htmat1 = 1 :: 10; Eval List( { Quantile( 0.5, 0, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000 ), Quantile(0.5,htmat), Quantile(0.5,htmat1) } );
//output
{500, 63, 5.5}
Thanks !
I guess @uday_guntupalli got my point and @stan_koprowski got a solution.
Indeed I was looking for a median of a matrix because I was not able to extract it immediatly from the table, but may be you can lead me to a way:
I hava a table (like below). I would like to calculate the median of each row in a simple way. Of course I need to exclude the 1st column from the calculation. In excel it is straight forward, but in JSL-JMP, I do not know how to do it simply (avoiding to stack the table,...).
Example of a table:
Consumption Monday Tuesday Wednesday Thursday Friday Saturday Sunday Median
Electricity 11.2 10.4 13.0 7.1 12.4 11.9 9.7 ?
Gas 100.4 86.9 94.8 103.0 112.3 95.3 97.8 ?