Questions tagged [median]
For code which finds the statistical median of a set of values.
38 questions
5
votes
1
answer
234
views
Compute rolling median absolute deviation (MAD) in R
I am computing the rolling Median Absolute Deviation (MAD) in R for outlier detection in a time series dataset. The goal is to:
Detect outliers based on a rolling MAD.
Exclude previously detected ...
2
votes
2
answers
428
views
Median of two sorted arrays in Python
Problem Statement
(Source: Leetcode Problem 4: Median of Two Sorted Arrays [Hard])(Topics: [Array] [Binary Search] [Divide and Conquer])
Given two sorted arrays ...
5
votes
1
answer
104
views
Compute median of a histogram
Another look at finding median value. This time the input is a histogram represented as an ordered range of (value, count) pairs, or simply as a range of counts, with value inferred from position. I'...
7
votes
2
answers
1k
views
Calculating the median and mode of a list of integers
Going through the Rust book for the second time as I've been wrapped up in Typescript for a while and I want to build a personal project in Rust.
In chapter 8.3, there's an exercise:
Given a list of ...
6
votes
2
answers
92
views
Flexible median evaluator
I recently posted an externally-evaluating median algorithm
(i.e. not requiring move or copy of elements), and the feedback encouraged me
to develop it further.
One simple suggestion was to handle NaN ...
7
votes
2
answers
1k
views
Median cut algorithm
I have implemented a simple version of the median cut algorithm. It takes a vector of Color structs representing pixel in an image. I also use the ...
4
votes
1
answer
509
views
Find median of values without copying
For practice, I've been playing with calculating median values. This time, I wanted to make something that works well without copying the input values (perhaps because they are bulky, or of a type ...
3
votes
2
answers
249
views
Generic implementation of median #2: Follow up
Follow on from this codereview:
generic implementation of median
As before the vector2 class is just for illustrative purposes and not the focus.
I have ...
6
votes
3
answers
776
views
generic implementation of median
Below is a generic implementation of the summary statistics function Median.
Discussion of efficient use of std::nth_element and ...
1
vote
1
answer
91
views
Stream that computes running median value
I was solving a DSA question, running median in a stream.
And I decided to design my own stream class with additional features.
...
3
votes
1
answer
983
views
LeetCode: Sliding Window Median C#
https://leetcode.com/problems/sliding-window-median/
Median is the middle value in an ordered integer list. If the size of
the list is even, there is no middle value. So the median is the mean
...
5
votes
2
answers
180
views
Rolling median function (Daily Coding Problem 377)
Given an array of numbers arr and a window of size k, print out the
median of each window of size k starting from the left and moving
right by one position each time.
For example, given the ...
4
votes
2
answers
354
views
Finding median of sub arrays taking too much time
I'm trying to solve a programming challenge where I have to find the median of given subarrays of an array. I have used std::vector's ...
3
votes
1
answer
485
views
Find Median of Two Sorted Arrays in JS
The task
is taken from leetcode
There are two sorted arrays nums1 and nums2 of size m and n
respectively.
Find the median of the two sorted arrays. The overall run time
complexity should ...
6
votes
2
answers
2k
views
Finding median from unsorted array with duplicate elements without sorting it
I am implementing a method to find the median of an unsorted array using a counting sort. I would happily go for a median of medians or selection algorithm for better performance but they are ...