maTH
  • 👋Welcome!
  • 🗿Installation
  • Reference
    • 😱Mathematical operations
      • add
      • pascal
      • factorial
      • factorialL
      • GCD
      • LCM
      • pow
      • permutations
      • combinations
      • combinationsWithRep
      • subtract
      • multiply
      • divide
      • sin
      • cos
      • ln
      • log
      • radToDeg
      • degToRad
      • mod
      • abs
      • floor
      • ceil
      • root
      • exp
      • tan
      • arcsin
      • arccos
      • arctan
      • sinh
      • cosh
      • round
    • 🥶Statistics
      • Binomial
      • Poisson
      • Geometric
      • Pascal
      • Hypergeometric
      • Exponential
      • Uniform
    • 🥵Data structures
      • Stack
      • Queue
      • LinkedList
    • 🤓Algorithms
      • Bubble sort
      • Insertion sort
      • Selection sort
      • Merge sort
      • Quicksort
      • Heap sort
      • Count sort
      • Bucket sort
      • Radix sort
    • 😳Constants
Powered by GitBook
On this page
  • Create a new Uniform distribution
  • Example
  1. Reference
  2. Statistics

Uniform

Assigns equal probability to all outcomes within a specified range. It is characterized by two parameters: 𝑎 (the minimum value of the range) and 𝑏 (the maximum value of the range)

Create a new Uniform distribution

Uniform X = Uniform(a, b); 

creates a continuous Uniform probability distribution.

Distribution properties:

Property
Type/Return type
Description

a

double

Minimum value of the range.

b

double

Maximum value of the range.

E()

double

Returns the expected value of the range.

D()

double

Represents variance, that measures the spread of dispersion of the random variable around its expected value E(X).

P(int k)

double

The cumulative distribution function: P(X < k)

In continuous probability distributions, P(X = k) = 0.

Example

//Example: for a range [2, 5], whats the probability of getting the number 3?
double a = 2; //min. of range
double b = 5; //max. of range
Uniform X = Uniform(a, b);
std::cout << X.P(3) << std::endl; //0.333333
Uniform X = Uniform(5, 10); 
std::cout << X.P(11) << std::endl; //Error: Given value cannot be anything outside of [a, b].  

Good to know: k has to be within [a, b]

PreviousExponentialNextData structures

Last updated 11 months ago

🥶