Skip to main content
20 votes

Compute the Median

Python 2, 48 bytes An unnamed function which returns the result. -1 byte thanks to xnor. lambda l:l.sort()or(l[len(l)/2]+l[~len(l)/2])/2. The first step is ...
FlipTack's user avatar
  • 14.7k
16 votes

Compute the Median

Python3 - 31 30 bytes Saved a byte thanks to @Dennis! I wasn't planning on a builtin answer, but I found this module and thought it was really cool cuz I had no idea it existed. ...
Maltysen's user avatar
  • 25.7k
13 votes
Accepted

Mean bits: an average challenge

Pyth, 6 bytes .Oml.B Try it online here. ...
Maltysen's user avatar
  • 25.7k
12 votes

Approximate when you are going to die

JavaScript (ES6), Score:  59.51  59.10 L = 52 bytes, M ≈ 0.1150638 Expects (n)(m), where m is 1 for Male or 0 for Female. ...
Arnauld's user avatar
  • 194k
12 votes

Approximate when you are going to die

R, score=67.47 47.92 30 bytes, MSE = 0.54587 -1 byte (and -1.47 in score) thanks to Dominic van Essen. pnorm(scan(),31,41,F)*scan()-2 Try it online! The input ...
Robin Ryder's user avatar
  • 15.6k
12 votes

Sniff out biased random permutations

Python 3, 45 43 bytes (−2 bytes from xnor) lambda v:sum(r<r[-1:]for r in v)/len(v)>.51 Try it online! How it works Computes the fraction of samples where ...
Anders Kaseorg's user avatar
11 votes

Ordinary Least Squares Regression

R, 34 bytes function(x)try(lm(V1~.,x,si=F)$co) Try it online! Notes: Takes input as a data frame (which is what lm expects) ...
Kirill L.'s user avatar
  • 13.9k
10 votes

Frequency Distribution of Multiple Dice Rolls

Octave, 38 bytes @(a,b)round(ifft(fft((a:a*b<a+b)).^a)) Try it online! Explanation Adding independent random variables corresponds to convolving their ...
Luis Mendo's user avatar
  • 105k
10 votes

Weighted average - the pressup trend problem

Python 3, 38 bytes lambda x:sum(x+x[7:]+x[14:]+x[21:])/70 Try it online!
Dennis's user avatar
  • 210k
9 votes

Mean bits: an average challenge

Jelly, 6 bytes R’BFL÷ Try it online! ...
Leaky Nun's user avatar
  • 49.9k
9 votes

Compute the Median

Brain-Flak, 914 + 1 = 915 bytes ...
Wheat Wizard's user avatar
  • 98.9k
9 votes

Compute the Median

Jelly, 9 bytes L‘HịṢµ÷LS Try it online! Explanation I'm still getting the hang of Jelly... I wasn't able to find built-ins for either the median or the mean of ...
Martin Ender's user avatar
9 votes

Average Two Letters

C# (Visual C# Interactive Compiler), 20 bytes a=>b=>(char)(a+b>>1) Try it online!
Gymhgy's user avatar
  • 8,008
8 votes

Interquartile Mean

Pyth, 11 10 bytes .O><lQS*4Ql .OsPtc4S*4 Test suite. How it works It quadruplicates the input list to ensure that the data count is divisible by 4. It still needs sorting, because ...
Leaky Nun's user avatar
  • 49.9k
8 votes

Interquartile Mean

MATL, 12 11 bytes 4Y"G"6L)]Ym Input is a horizontal vector, with the format [1, 3, 4, 5, 6, 6, 7, 7, 8, 8, 9, 38] or ...
Luis Mendo's user avatar
  • 105k
8 votes

Compute the Median

Actually, 1 byte Try it online!
Dennis's user avatar
  • 210k
8 votes

Fake Statistics

Pyth, 44 35 34 bytes ?eA.DhQ2+eQ*G,-eQJ*E@hc1thQ2+eQJ*G,-eQKE+eQK .N?eA.DN2+T*G+LT_B*Y@hc1tN2*G+LT_BY .N?eA.DN2+T*G+LT_B*Y@cNtN2*G+LT_BY Try it online! (The code above defines a function. ...
Leaky Nun's user avatar
  • 49.9k
8 votes

Frequency Distribution of Multiple Dice Rolls

Mathematica, 29 bytes Tally[Tr/@Range@#2~Tuples~#]& Just generates all possible dice rolls, takes their totals, then counts. Each frequency comes labeled ...
Misha Lavrov's user avatar
  • 5,245
8 votes

An Array of Challenges #3: Moving Averages

Dyalog APL, 4 bytes 1 byte saved thanks to @Graham 2 bytes saved thanks to @jimmy23013 Did I mention APL is not a golfing language? ⊢+/÷ with ...
Uriel's user avatar
  • 13.2k
8 votes

Standardize the Samples (Compute the z-Score)

R, 51 45 38 37 bytes Thanks to Giuseppe and J.Doe! function(x)scale(x)/(1-1/sum(x|1))^.5 Try it online!
Robert S.'s user avatar
  • 1,323
8 votes

Average Two Letters

x86-16 machine code, IBM PC DOS, 13 12 10 bytes Binary (xxd): 00000000: a182 0002 c4d0 e8cd 29c3 .......... Listing: ...
640KB's user avatar
  • 11.9k
8 votes

Critical Calculations

Charcoal, 16 bytes NθI∕ΣX⊕×N⊖N…·¹θθ Try it online! Link is to verbose version of code. Takes the number of rings as the first parameter, then the odds and ...
Neil's user avatar
  • 173k
7 votes

Mean bits: an average challenge

Octave, 29 bytes @(n)1+sum(fix(log2(1:n-1)))/n Explanation ...
beaker's user avatar
  • 2,639
7 votes

Compute the Median

R, 6 bytes median Not surprising that R, a statistical programming language, has this built-in.
rturnbull's user avatar
  • 3,919
7 votes

An Array of Challenges #3: Moving Averages

Jelly, 3 bytes ṡÆm Try it online! Pretty simple thanks to How it works ...
caird coinheringaahin g's user avatar
7 votes

An Array of Challenges #3: Moving Averages

Wolfram Language (Mathematica), 13 bytes Mathematica has a built-in for everything MovingAverage Try it online! Takes a list and then a radius...
JungHwan Min's user avatar
  • 13.8k
7 votes

An Array of Challenges #3: Moving Averages

Haskell, 47 bytes n!a|length a<n=[]|_:t<-a=div(sum$take n a)n:n!t Try it online! Saved two bytes thanks to xnor!
lynn's user avatar
  • 68.8k
7 votes

Frequency Distribution of Mixed Dice Rolls

Jelly,  14  7 bytes -3 bytes thanks to Mr. Xcoder (use of an implicit range to avoid leading R; replacement of reduce by the dyadic Cartesian product and ...
Jonathan Allan's user avatar
7 votes

Average Idle-Dice Rolling

R, 50 32 bytes function(M)prod(M/2+.5)*691250/9 Try it online! -17 Bytes thanks to Nick Kennedy, and thanks to Jonathan Allan for suggesting a precision fix, with ...
Giuseppe's user avatar
  • 28.7k
7 votes

Average Two Letters

Jelly, 4 bytes OSHỌ Try it online! Explanation ...
hyper-neutrino's user avatar
  • 42.4k

Only top scored, non community-wiki answers of a minimum length are eligible