Computation of median for discrete data: non-standard computation

Open
#87 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Domain
data

Research direction

Start by reading the math library's median implementation and its documentation, then run the reported example with (list 1 2 3 4). Check how quantile handles even-length discrete data as well. Done means the documented median behavior is consistent with the intended convention, with coverage for the even-length case.

Written by the indexing model from the issue text.

Description

Using (require math), we can compute (median < data), where data is a list of numbers.
When data length is even, then normally the median is computed by averaging the two central elements, after ordering.
The problem is that running the following code we obtain 2, but considering tipical references (e.g. wikipedia median) the value should be 2.5:
#lang racket
(require math)
(define data (list 1 2 3 4))
(median < data)

Could we maybe add some parameterization to the function median (and may be also to quantile) in order to compute the average of the central two elements, when the number of elements is even?

Thank you and congratulations for all your great work.

Dominant language
Racket
Stars
40
Forks
32
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from racket/math

All issues in racket/math

Similar issues

More Data Engineering issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.