Skip to content

Instantly share code, notes, and snippets.

@quachngocxuan
Last active January 2, 2018 16:39
Show Gist options
  • Save quachngocxuan/67f21fa077f6177331b009560915bc21 to your computer and use it in GitHub Desktop.
Save quachngocxuan/67f21fa077f6177331b009560915bc21 to your computer and use it in GitHub Desktop.
Learn enough to be dangerous - Statistics

Learn enough to be dangerous - Statistics

Mean, median, mode

Tutorial

Ex: https://www.hackerrank.com/challenges/s10-basic-statistics

mean

The average of all the integers in a set of values.

Example:

arr = [1, 1, 1, 2, 2, 3, 4, 4]
=> mean = sum(arr)/n = 18/8

weighted mean Given a discrete set of numbers, X, and a corresponding set of weights, W, the weighted mean is calculated as follows: Mw = sum(Xi*Wi)/sum(Wi)

Example:

X = [1, 3, 5], W = [2, 4, 6]
Mw = (1*2 + 2*4 + 5*6) / (2+4+6) = 3.66

Ex: https://www.hackerrank.com/challenges/s10-weighted-mean

median

The midpoint value of a data set for which an equal number of samples are less than and greater than the value. For an odd sample size, this is the middle element of the sorted sample; for an even sample size, this is the average of the 2 middle elements of the sorted sample.

Example:

arr = [1, 1, 1, 2, 2, 3, 4, 4]
=> median = (2+2)/2 = 2

mode

The element(s) that occur most frequently in a data set.

Example:

arr = [1, 1, 1, 2, 2, 3, 4, 4]
=> mode = 1

Quartiles

The quartiles of an ordered data set are the 3 points that split the data set into 4 equal groups. The 3 quartiles are defined as follows: quartiles

  • Q1: median number of the first lower half
  • Q2: median number of the data set
  • Q3: median number of the first upper half

Ex: https://www.hackerrank.com/challenges/s10-quartiles

Interquartile The interquartile range of an array is the difference between its first (Q1) and third (Q3) quartiles (i.e., Q3-Q1).

Ex: https://www.hackerrank.com/challenges/s10-interquartile-range

Standard deviation

Ref: https://www.hackerrank.com/challenges/s10-standard-deviation/tutorial

  • Variance
  • Standard Deviation

Ex: https://www.hackerrank.com/challenges/s10-standard-deviation

Probability

Ref: https://www.hackerrank.com/challenges/s10-mcq-1/tutorial

Conditional Probability P(B | A) = P(A intersect B)/P(A) P(B |A) denotes the probability of the occurrence of B given that A has occurred

Bayes' Theorem

Permutation & combination

Ref: http://mathworld.wolfram.com/Permutation.html https://www.hackerrank.com/challenges/s10-mcq-5/tutorial

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment