method number.median
Contract
Return typenumber
No input parameters.
Parameter kindDefault valueType
Other unkeyed argumentsopt
Other keyed argumentsopt
Water Contract
<method number.median
  _other_keyed=opt=wob=ekind.code="_add_to_environment"
  _other_unkeyed=opt=wob=ekind.code="_body"
  _return_type=number/>

Roughly speaking the "Middle value" of a vector of numbers, which is not necessarily the average. The result is the smallest number such that at least half the numbers in the vector are no greater than the returned value. If the vector has an odd number of entries, the median is the middle entry in the vector after sorting the vector. If the vector has an even number of entries, the median is equal to the sum of the two middle (after sorting) numbers divided by two. Thus if the length of the vector is odd, the returned value will be one of the items in the vector, otherwise is will be the average of the two middle values of the vector, and thus NOT one of the numbers in the vector. If the length of the vector is even and only integers are in the vector, it is likely that you'll get a double as the returned value.
number.<median _other_unkeyed=<v 4 6 5/>/>
5
number.<median _other_unkeyed=<v 4 6 5 3/>/>
4.5
2.5.<median 3.5/>3.0

You can also pass in other keyed args instead of unkeyed args.
number.<median x=2 y=5/>3.5

This is probably more useful when you have a record that has fields who's keys are strings but who's values are numbers:
number.<median _other_keyed=<thing x=4 y=5 z=99/>/>
5