(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

The median of a set of five numbers.

This tutorial will explain how to find the median of numbers. The median of a set of numbers is the middle value. If the set of numbers has an even amount, the median is the average of the two middle numbers. For more information, see Wikipedia.

## Sorting the Values

Main article: Sorting Values

The first step in finding the median is to sort the data from least to greatest. Doing this first will make this finding the median much easier.

## Finding the Median

First, sort the values in order.

Once the values have been sorted, use the following script to get the median. Remember that the list "Data" contains the set of values. The variables "Med1" and "Med2" represent the values that will be used to solve for the median.

```set [Med1 v] to (item ((length of [data v]) / (2)) of [data v])
set [Med2 v] to (item (((length of [data v]) / (2)) + (1)) of [data v])
if < ((length of [data v]) mod (2)) = (0)> then
say (join [median=] (((Med1) + (Med2)) / (2))) for (2) secs
else
say (join [median=] (item (((length of [data v]) / (2)) + (0.5)) of [data v])) for (2) secs
end
```
{"found_math": false, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0, "url": "https://test.scratch-wiki.info/w/index.php?title=Zho:%E6%9F%A5%E6%89%BE%E6%95%B0%E5%AD%97%E7%9A%84%E4%B8%AD%E9%97%B4%E5%80%BC&oldid=16985", "fetch_time": 1568600540000000000, "content_mime_type": "text/html", "warc_filename": "crawl-data/CC-MAIN-2019-39/segments/1568514572471.35/warc/CC-MAIN-20190916015552-20190916041552-00277.warc.gz", "warc_record_offset": 730985200, "warc_record_length": 9314, "token_count": 329, "char_count": 1201, "score": 3.703125, "int_score": 4, "crawl": "CC-MAIN-2019-39", "snapshot_type": "latest", "language": "en", "language_score": 0.8057346343994141, "file_path": "/sailhome/yjruan/project/latent-lm/data/processed/finemath-4plus/finemath-4plus/train-00047-of-00064.parquet"}