Questions tagged [median]

The median is the 'middle' value from a set of values. If the number of values is an even number, the median is the mean of the 'middle' values.

The median is generally used in programming in the sense of the term that comes from statistics. In simple terms it means the number that has half the values above it and half the values below it in the range. It is different than average in that an average can be influenced by extremes on either end of the spectrum. If a few numbers are a lot greater or a lot smaller than the rest, the average will be significantly different from the median. Median can give you a better sense of where the typical middle case is than the average.

The median is also very useful in signal and image processing, in the context of a moving median filter. This filter is usually used to reduce "salt and pepper" type noise, as well as spikes, because each output pixel or element contains the median value of the m-by-n neighborhood around that corresponding pixel in the data.

For a more statistically and technically correct and thorough explanation, see Wikipedia.

In scientific software for statistical computing and graphics, the median of a numeric vector can be found by function median, or quantile with prob = 0.5.

1286 questions
-4
votes
3 answers

How to find median character of a string in Python 2.7

A median letter in a word is the letter present in the middle of the word and if the word length is even the middle letter is the left one out of the two middle letters. For example , consider "apple" . The program should return 'p'. As another…
Kartik Madaan
  • 83
  • 1
  • 9
-4
votes
1 answer

Calculate statistical parameters (quantile and median) from a serie of ECDF with R

Edit: Okay, sorry i will try to be more clear, I have 50 scenarios (here i create it randomly), and i put it all of this scenarios in a matrix. After i can apply the ecdf function, that give me a list of 50 ecdf. And i want to calculate, from all…
-4
votes
3 answers

How to find median (row&column) in a matrix C

I've made a code which creates a matrix and sort it in ascending form. (row) I want to do following things in the ex.'s that I've given with my code, but I can't find out how. ex. If I enter "r" as the input; a matrix entered like this; 3 4 5 9 2…
-4
votes
1 answer

python if elif different result

How can I find the median of the 1st, last and middle element and than swap the median with the 1st element?
JoleMile
  • 67
  • 5
-5
votes
1 answer

How to code using python so it can tell me the mode without using input or print and using def, if and ele

My code so far, but I get an error testing it: # without using any collection data types like list or set, this # function determines which value appears the most often and returns it. def mode3(a, b, c): # starting value for variable ans.…
Saron
  • 1
-5
votes
1 answer

Arrays, Statistics, and calculating mean, median, mode, average and sqrt

I need to implement four static methods in a class named ArrayStatistics. Each of the four methods will calculate the mean, median, mode, and population standard deviation, respectively, of the values in the array. This is my first time working…
-5
votes
3 answers

Calculate median

I can't figure out what is wrong, why doesnt my median work ? Everything works except my median and i have been sitting here for a while and looking at it and still don't understand why it doesnt work. import java.util.Arrays; public class Stat{ …
-5
votes
1 answer

Returning the median from two vectors in r

I have a vector containing the minimum and maximum of 3 ranges i.e low<-1,2,3 high<-2,3,4 represent the ranges 1-2,2-3,and 3-4 I need to return a third vector containing the midpoint of each range i.e. mid<-1.5,2.5,3.5 Any quick way to do this?
Elizabeth
  • 5,771
  • 16
  • 57
  • 88
-6
votes
2 answers

Finding the running median

I have to find the running median as per this problem: https://www.hackerrank.com/challenges/ctci-find-the-running-median I am trying to implement two heaps. A min heap which stores the elements lesser than the current median and a max heap which…
blueNinja
  • 1
  • 2
  • 1
-6
votes
2 answers

Finding median of 2D arrays

If the parameter was an int[][] called arry, how would you find the median of it? Sorry if my formatting is wrong, it's my first time here. The median of the entire 2d array counting every int in the array. All the rows are the same length, for…
user3397448
  • 1
  • 1
  • 4
-7
votes
1 answer

Given that integers are read from a data stream. Find median of elements read so for in efficient way

Can we use AVL tree for this, so that root element is the median at any point
rohitmb
  • 191
  • 1
  • 3
  • 11
1 2 3
85
86