Programmer Guide/Command Reference/EVAL/median: Difference between revisions

From STX Wiki
Jump to navigationJump to search
m (1 revision: Initial import)
No edit summary
 
(8 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{DISPLAYTITLE:{{SUBPAGENAME}}}}
{{DISPLAYTITLE:{{SUBPAGENAME}}}}
=====median=====
Compute median or quantiles of a vector ''x''.


Calculate the median of the vector <var>x</var>.
The quantile '''q<sub>p</sub>''' can be defined as the probability '''p''' such that ''an element of x is lower than'' '''q<sub>p</sub>'''. The value '''p''' must be in the range 0 to 1. The special quantile q<sub>0.5</sub> is also called '''median'''.
----
;Usage 1: <code>median(''x''<sub>vector</sub> {, ''p''<sub>scalar</sub> })</code>
;''x'': data vector
;''p'': the propability; 0 < ''p'' < 1 (default=0.5)
;Result 1: Returns the ''p''-quantile (scalar) of ''x''.
----
;Usage 2: <code>median(''x''<sub>vector</sub> , ''p''<sub>vector</sub> })</code>
;''x'': data vector
;''p'': vector with propability values
;Result 1: Returns a vector containing the quantiles for all probabilities p[i].
;See also: [[../avr|avr]], [[../sort|sort]], [[../hist|hist]]


=====Usage:=====
[[../#Functions|<function list>]]
 
<code>median(<var>x</var>)</code>
 
<code>median(<var>x</var>,<var>q</var>)</code>
 
=====Parameters:=====
 
;<var>x</var>
 
:The data vector.
 
;<var>q</var>
 
:The cut point (<code>0</code> < <var>q</var> < <code>1</code>) or a vector of cut points. If no cut point is specified, <code>0.5</code> is used. If <var>q</var> is a vector, each element <var>q</var><code>[i]</code> must be in the range <code>0</code> to <code>1</code>.
 
=====Return Type:=====
 
scalar
 
=====Result:=====
 
The value <code>xq</code> with <code>sum(h(</code><var>x</var> <code><= xq)) =</code> <var>q</var>
 
If q is a vector the result is a vector <code>xq</code> with <code>nrow(</code><var>q</var><code>)</code> elements with: <code>h(</code><var>x</var> <code>|</code> <var>x</var><code><=xq[i]) =</code> <var>q</var><code>[i]</code>

Latest revision as of 11:20, 21 April 2011

Compute median or quantiles of a vector x.

The quantile qp can be defined as the probability p such that an element of x is lower than qp. The value p must be in the range 0 to 1. The special quantile q0.5 is also called median.


Usage 1
median(xvector {, pscalar })
x
data vector
p
the propability; 0 < p < 1 (default=0.5)
Result 1
Returns the p-quantile (scalar) of x.

Usage 2
median(xvector , pvector })
x
data vector
p
vector with propability values
Result 1
Returns a vector containing the quantiles for all probabilities p[i].
See also
avr, sort, hist

<function list>

Navigation menu

Personal tools