Bookmarks    
nPr and nCr    
Random Number    
SD Calculator    
Sample Size    
Percent Error    
Density    
Molarity    
Molar Mass    
Ohm's Law    
Watts to Amps    
Voltage Drop    
Long Division    
Mixed Numbers    
Rounding    
Nth Root    
Exponents    
Half-Life    
Polar Form    
De Moivre    
3D Distance    
Point to Line    
Cross Product    
Determinant    
Sin Cos Tan    
Triangle Area    
Scale Factor    
Sector Area    
Ellipse Area    
Cube Volume    
Box Volume    
Sphere Volume    
Cone Volume    
Pipe Volume    
Time Duration    
Time Card    
Present Value    
Future Value    
Churn Rate    
A/B Test Calc    
SEO Traffic    
Ideal Weight    
Fat Intake    
Child Height    
Golf Handicap    
Heat Index    
Wind Chill    
Dew Point    
Download Time    
kWh to Cost    
AC Size (BTU)    
Heating Costs    
LED Savings    
Trip Gas Cost    
Tire Size    
Solar Output    
Solar Payback    
Battery Size    
Wall Area    
Gravel Needed    
Mortar Mix    
Slope Grade    
Curtain Size    
Soil Needed    
Sod Needed    
Ramp Length    
Blind Size    
Drain Slope    
Board Feet    
Heat Loss    
Furniture Fit    
Moving Boxes    
Plywood Cuts    
Shelf Sag    
   Add
Probability and random number calculators
Independent Events
Independent Events
Two Events Solver
Two Events Solver
Repeated Trials
Repeated Trials
Bayes' Theorem
Bayes' Theorem
Expected Value
Expected Value
Binomial Distribution
Binomial Distribution
nPr and nCr
nPr and nCr
Circular Permutation
Circular Permutation
With Repetition
With Repetition
Random Number
Random Number
Averages and statistics calculators
Average Calculator
Average Calculator
Mean Median Mode
Mean Median Mode
SD Calculator
SD Calculator
Quartiles & IQR
Quartiles & IQR
Frequency Table
Frequency Table
Correlation (r)
Correlation (r)
Normal Probability
Normal Probability
Z-Score Calculator
Z-Score Calculator
Confidence Interval
Confidence Interval
Sample Size
Sample Size
Mark & Recapture
Mark & Recapture
P-Value Calculator
P-Value Calculator
Percentage and ratio calculators
Percentage Calc
Percentage Calc
Percent Change
Percent Change
Percent Difference
Percent Difference
Percent Error
Percent Error
Ratio Calculator
Ratio Calculator
Discount Calculator
Discount Calculator
Sales Tax Calculator
Sales Tax Calculator
Margin Calculator
Margin Calculator
Speed calculators
Speed Calculator
Speed Calculator
Density and concentration calculators
Density
Density
Molarity
Molarity
Molar Mass
Molar Mass
Physics and electricity calculators
Ohm's Law
Ohm's Law
Watts to Amps
Watts to Amps
Resistor Colors
Resistor Colors
Voltage Drop
Voltage Drop
Unit conversion calculators
Weight Converter
Weight Converter
Shoe Size Converter
Shoe Size Converter
Integer and signed number calculators
Long Division
Long Division
LCM Calculator
LCM Calculator
GCF Calculator
GCF Calculator
Integer Calculator
Integer Calculator
Prime Factorization
Prime Factorization
Diophantine Solver
Diophantine Solver
Modulo Calculator
Modulo Calculator
Factor Calculator
Factor Calculator
Roman Numerals
Roman Numerals
Fraction, decimal and rounding calculators
Fraction Calculator
Fraction Calculator
Mixed Numbers
Mixed Numbers
Simplify Fractions
Simplify Fractions
Fraction to Decimal
Fraction to Decimal
Decimal to Fraction
Decimal to Fraction
Rounding
Rounding
Equation and inequality calculators
Linear Equation
Linear Equation
Linear Systems
Linear Systems
Quadratic Formula
Quadratic Formula
Absolute Value
Absolute Value
Quadratic Inequality
Quadratic Inequality
Polynomial calculators
Binomial Theorem
Binomial Theorem
Square root and nth root calculators
Simplify Radicals
Simplify Radicals
Nth Root
Nth Root
Exponent and logarithm calculators
Exponents
Exponents
Log Calculator
Log Calculator
Number of Digits
Number of Digits
Scientific Notation
Scientific Notation
Sci. Notation Math
Sci. Notation Math
Half-Life
Half-Life
Complex number calculators
Complex Numbers
Complex Numbers
Polar Form
Polar Form
De Moivre
De Moivre
Function and graph calculators
Slope Calculator
Slope Calculator
Linear Function
Linear Function
Direct & Inverse Variation
Direct & Inverse Variation
y = ax² Calculator
y = ax² Calculator
Distance Formula
Distance Formula
3D Distance
3D Distance
Section Formula
Section Formula
Point to Line
Point to Line
Lat/Long Distance
Lat/Long Distance
Complete the Square
Complete the Square
Circle Equation
Circle Equation
Conic Sections
Conic Sections
Polar Coordinates
Polar Coordinates
Sequence calculators
Arithmetic Sequence
Arithmetic Sequence
Geometric Sequence
Geometric Sequence
Fibonacci Sequence
Fibonacci Sequence
Recurrence Relation
Recurrence Relation
Vector calculators
Vector Calculator
Vector Calculator
Cross Product
Cross Product
Matrix calculators
Matrix Calculator
Matrix Calculator
Determinant
Determinant
Inverse Matrix
Inverse Matrix
Plane geometry calculators
Sin Cos Tan
Sin Cos Tan
Degrees ⇔ Radians
Degrees ⇔ Radians
a sin θ + b cos θ
a sin θ + b cos θ
Triangle Solver
Triangle Solver
Triangle Area
Triangle Area
Right Triangle
Right Triangle
Pythagorean Theorem
Pythagorean Theorem
Polygon Angles
Polygon Angles
Scale Factor
Scale Factor
Parallel Lines
Parallel Lines
Rectangle Area
Rectangle Area
Parallelogram Area
Parallelogram Area
Trapezoid Area
Trapezoid Area
Circle Calculator
Circle Calculator
Sector Area
Sector Area
Inscribed Angle
Inscribed Angle
Ellipse Area
Ellipse Area
Solid geometry calculators
Cube Volume
Cube Volume
Cube Surface Area
Cube Surface Area
Box Volume
Box Volume
Box Surface Area
Box Surface Area
Cylinder Volume
Cylinder Volume
Cylinder Surface
Cylinder Surface
Sphere Volume
Sphere Volume
Sphere Surface
Sphere Surface
Spherical Cap Volume
Spherical Cap Volume
Cap Surface Area
Cap Surface Area
Ellipsoid Volume
Ellipsoid Volume
Ellipsoid Surface
Ellipsoid Surface
Pyramid Volume
Pyramid Volume
Pyramid Surface
Pyramid Surface
Cone Volume
Cone Volume
Cone Surface Area
Cone Surface Area
Frustum Volume
Frustum Volume
Frustum Surface Area
Frustum Surface Area
Pipe Volume
Pipe Volume
Capsule Volume
Capsule Volume
Capsule Surface Area
Capsule Surface Area
Date and time calculators
Age Calculator
Age Calculator
Days Between Dates
Days Between Dates
Date Calculator
Date Calculator
Hours From Now
Hours From Now
Day of the Week
Day of the Week
Time Calculator
Time Calculator
Time Zone Converter
Time Zone Converter
Hours Calculator
Hours Calculator
Time Duration
Time Duration
Time Card
Time Card
Finance and economics calculators
Compound Interest
Compound Interest
Simple Interest
Simple Interest
Interest Calculator
Interest Calculator
TVM Calculator
TVM Calculator
Present Value
Present Value
Future Value
Future Value
ROI Calculator
ROI Calculator
IRR Calculator
IRR Calculator
Payback Period
Payback Period
Average Return
Average Return
GDP Calculator
GDP Calculator
Web marketing and ad metric calculators
CTR Calculator
CTR Calculator
Conversion Rate
Conversion Rate
CPC, CPM & CPA
CPC, CPM & CPA
ROAS Calculator
ROAS Calculator
Break-Even CPA
Break-Even CPA
LTV Calculator
LTV Calculator
CAC Calculator
CAC Calculator
Churn Rate
Churn Rate
A/B Test Calc
A/B Test Calc
A/B Sample Size
A/B Sample Size
SEO Traffic
SEO Traffic
Break-Even Point
Break-Even Point
Markup vs. Margin
Markup vs. Margin
CAGR Calculator
CAGR Calculator
Health and fitness calculators
BMI Calculator
BMI Calculator
Sleep Calculator
Sleep Calculator
Calorie Calculator
Calorie Calculator
BMR Calculator
BMR Calculator
TDEE Calculator
TDEE Calculator
Ideal Weight
Ideal Weight
Body Fat Calculator
Body Fat Calculator
Lean Body Mass
Lean Body Mass
Calories Burned
Calories Burned
Protein Intake
Protein Intake
Macro Calculator
Macro Calculator
Carb Calculator
Carb Calculator
Fat Intake
Fat Intake
Child Height
Child Height
Sports calculators
Golf Handicap
Golf Handicap
Pace Calculator
Pace Calculator
1RM Calculator
1RM Calculator
Target Heart Rate
Target Heart Rate
Weather calculators
Heat Index
Heat Index
Wind Chill
Wind Chill
Dew Point
Dew Point
Computer calculators
Base Converter
Base Converter
Subnet Calculator
Subnet Calculator
Download Time
Download Time
Household energy and budget calculators
Electricity Cost
Electricity Cost
kWh to Cost
kWh to Cost
Yearly kWh to Cost
Yearly kWh to Cost
AC Size (BTU)
AC Size (BTU)
AC Running Cost
AC Running Cost
Heating Costs
Heating Costs
Gas vs Electric
Gas vs Electric
LED Savings
LED Savings
Salary Calculator
Salary Calculator
Budget Calculator
Budget Calculator
Car calculators
Trip Gas Cost
Trip Gas Cost
EV Charging Cost
EV Charging Cost
EV vs Gas Cost
EV vs Gas Cost
MPG Calculator
MPG Calculator
Tire Size
Tire Size
Solar power and battery calculators
Solar Output
Solar Output
Solar Panel Count
Solar Panel Count
Solar Payback
Solar Payback
Battery Size
Battery Size
Home and DIY calculators
Tile Calculator
Tile Calculator
Stair Calculator
Stair Calculator
Concrete Volume
Concrete Volume
Wall Area
Wall Area
Wallpaper Rolls
Wallpaper Rolls
Paint Calculator
Paint Calculator
Flooring Needed
Flooring Needed
Exterior Walls
Exterior Walls
Gravel Needed
Gravel Needed
Mortar Mix
Mortar Mix
Slope Grade
Slope Grade
Lumber Cut List
Lumber Cut List
Lot Coverage/FAR
Lot Coverage/FAR
Sheet Vinyl Roll
Sheet Vinyl Roll
Insulation Needed
Insulation Needed
Curtain Size
Curtain Size
TV Size & Distance
TV Size & Distance
Soil Needed
Soil Needed
Sod Needed
Sod Needed
Block Calculator
Block Calculator
Brick Calculator
Brick Calculator
Deck Materials
Deck Materials
Ramp Length
Ramp Length
Pilot Hole Size
Pilot Hole Size
Room Ventilation
Room Ventilation
Paint Thinning
Paint Thinning
Baseboard & Trim
Baseboard & Trim
Blind Size
Blind Size
Picture Hanging
Picture Hanging
Drain Slope
Drain Slope
Screw Calculator
Screw Calculator
Board Feet
Board Feet
Fence Calculator
Fence Calculator
Wood Shrinkage
Wood Shrinkage
Caulk Calculator
Caulk Calculator
Heat Loss
Heat Loss
Furniture Fit
Furniture Fit
Moving Boxes
Moving Boxes
Storage Capacity
Storage Capacity
Plywood Cuts
Plywood Cuts
Shelf Sag
Shelf Sag

Random Number Generator

Enter the lower and upper limits and press "Calculate" to generate random numbers in that range. You can also set how many, the decimal places and whether repeats are allowed (everything except the limits can be left blank, which means 1 whole number, repeats allowed).

Enter the count as a whole number from 1 to 999 and the decimal places as a whole number from 0 to 50. Each press gives new random numbers, even with the same input.
Result
Enter a range in the fields on the left and press "Calculate". The random numbers will appear here.

What you can do on this page

  • Just enter a lower and an upper limit to get random numbers (numbers picked by chance) in that range on the spot
  • You can make random decimals as well as whole numbers. Choose from 0 to 50 decimal places
  • Generate up to 999 numbers at once, with or without repeats. When you make 2 or more, the result also shows them sorted in ascending and descending order, along with the order they were generated in
  • Works for anything from a small range like 1 to 6 up to huge whole numbers with more than 20 digits
  • A plain-language explanation of how random numbers work and copy-and-paste formulas for Excel, Google Sheets and Python are all on this page
The random numbers on this page are pseudorandom numbers, made by a computer with a formula (the method used is of the quality used in cryptography). They are random enough for drawings, games and simulations. To create encryption keys or passwords themselves, however, please use a dedicated tool that works offline.

What is this calculation used for?

Fair drawings, raffles and seat assignments

Give each entrant or student a number and pick with random numbers, and the choice is fair, with no one's intentions involved. Everyone has the same chance of being picked (a uniform distribution). It is a drawing whose fairness is backed by math.
The white balls in Powerball, "5 numbers from 1 to 69 with no repeats", work in exactly this way, and there are 11,238,513 possible sets of them.

Random sampling for polls and statistical surveys

How can a poll of a few thousand people tell us what the whole country thinks, without asking every American? The answer is random sampling, choosing the people to ask with random numbers. Choosing on purpose would bias the results, so picking at random is what makes a survey trustworthy.
Random digit dialing (RDD), used in many opinion polls, creates the phone numbers themselves with random numbers, so that people with unlisted numbers have the same chance of being called.

Simulation (the Monte Carlo method) in finance, weather and science

Even a problem too complex to solve with a formula can be answered approximately by running tens of thousands of random trials and adding up the results. This is called the Monte Carlo method. It is used everywhere from risk calculations at banks and ensemble weather forecasts (running many forecasts with slightly different starting conditions) to research in physics and medicine.
Its theoretical foundation is the property you learn on this page: the average of random numbers gets closer to the expected value.

Chance in games (dice, card shuffles and loot drops)

All the chance in video games, from dice rolls and card shuffles to loot drops and randomly generated maps, is made with pseudorandom numbers.
The fact that the same seed gives the same sequence is actually put to good use, in replay features and in sharing a world seed with friends so everyone plays the same map.

Random numbers behind encryption and security (and the limits of pseudorandom numbers)

Encrypted connections for online shopping and one-time passwords only work because of random numbers, numbers an attacker cannot predict.
Ordinary pseudorandom numbers could be predicted, so they cannot be used here. Instead, cryptographically secure generators and hardware random number generators, which use physical events such as heat noise, are used. This is the most demanding use of random numbers, where their quality decides how safe the world is.

Formula

Probability of each value for random whole numbers (discrete uniform distribution)
Standard notation (the usual math form)
\(P(X=k)\) \(=\) \(1\) \(\div\) \((b-a+1)\)
In words (symbols replaced with words)
③ \(P(X=k)\): probability of getting a given whole number \(k\) \(=\) ① \(1\): total probability \(\div\) ② \((b-a+1)\): number of possible whole numbers
The formula in words
① Split the \(1\): total probability
② into equal parts by the \((b-a+1)\): number of possible whole numbers
③ and you get the \(P(X=k)\): probability of getting a given whole number \(k\) (every whole number is equally likely)
Quick example
A die can be thought of as a random whole number from 1 to 6. The probability of rolling a 3 is
probability of a 3 \(P\) \(=\) total probability \(1\) \(\div\) possible values (6)
\(1 \div (6 - 1 + 1) = \frac{1}{6} \approx 0.167\ \ (16.7\%)\)
Key idea
A random number generator is built so that every number in the range is equally likely. This pattern is called a uniform distribution. With a lower limit \(a\) and an upper limit \(b\), there are \(b - a + 1\) possible whole numbers (for 1 to 6, \(6 - 1 + 1 = 6\)), so the probability of each one is 1 divided by that count. "A 3 just came up, so a 3 is less likely next time" is not true. Every draw starts fresh with the same probabilities.
How likely random decimals are (probability density of the continuous uniform distribution)
Standard notation (the usual math form)
\(f(x)\) \(=\) \(1\) \(\div\) \((b-a)\)
In words (symbols replaced with words)
③ \(f(x)\): probability density (height of the graph) \(=\) ① \(1\): total probability \(\div\) ② \((b-a)\): width of the range
The formula in words
① Spread the \(1\): total probability
② evenly over the \((b-a)\): width of the range
③ and you get the \(f(x)\): probability density (height of the graph) (the graph is a flat rectangle)
Quick example
For random decimals from 0 to 10, the height of the graph is 1 ÷ 10 = 0.1. The probability of landing between 2 and 5 is height × width
height of the graph \(f(x)\) \(=\) total probability \(1\) \(\div\) width of the range (10)
\(1 \div (10 - 0) = 0.1\)
\(0.1 \times (5 - 2) = 0.3\ \ (30\%)\)
Key idea
Random decimals have infinitely many possible values, so the probability of getting exactly 3.000… (or any other single point) is 0. That is why, for random decimals, we think about the probability of landing in a range. The probability is the area under the graph (height × width), and over the whole range it is \(0.1 \times 10 = 1\) (100%). The height \(f(x)\) is the same everywhere in the range, so every part is equally likely. That is what a uniform distribution means.
Average of random numbers (expected value of a uniform distribution)
Standard notation (the usual math form)
\(E[X]\) \(=\) \((a+b)\) \(\div\) \(2\)
In words (symbols replaced with words)
③ \(E[X]\): average of the random numbers (expected value) \(=\) ① \((a+b)\): lower limit \(a\) plus upper limit \(b\) \(\div\) ② \(2\): divisor (takes the middle)
The formula in words
① Take the \((a+b)\): lower limit \(a\) plus upper limit \(b\)
② divide it by the \(2\): divisor to find the exact middle of the range
③ and you get the \(E[X]\): average of the random numbers (expected value)
Quick example
When you make many random whole numbers from 1 to 100, their average gets closer and closer to
average (expected value) \(E[X]\) \(=\) lower plus upper limit (1 + 100) \(\div\) divisor (2)
\((1 + 100) \div 2 = 50.5\)
Key idea
A uniform distribution is symmetric within its range, so the average (expected value) is exactly in the middle. For a die (1 to 6) it is \((1+6) \div 2 = 3.5\). Each roll is a whole number, but the average of many rolls gets closer and closer to 3.5. For random decimals, the spread (variance) is \(V[X] = \frac{(b-a)^2}{12}\).
Turning a random number from 0 to 1 into a random whole number in a range
Standard notation (the usual math form)
\(n\) \(=\) \(a\) \(+\) \(\lfloor\) \(u\) \(\times\) \((b-a+1)\) \(\rfloor\)
In words (symbols replaced with words)
⑤ \(n\): random whole number in the range \(=\) ④ \(a\): lower limit \(+\) \(\lfloor\) ① \(u\): random number from 0 up to (not including) 1 \(\times\) ② \((b-a+1)\): number of possible whole numbers ③ \(\rfloor\)
The formula in words
① Take the \(u\): random number from 0 up to (not including) 1
② stretch it by multiplying by the \((b-a+1)\): number of possible whole numbers
③ drop the decimal part with the floor symbol \(\lfloor\ \rfloor\) to get a whole number
④ add the \(a\): lower limit
⑤ and you get the \(n\): random whole number in the range
Quick example
If the random number from 0 to 1 is 0.32, turning it into a random whole number from 1 to 10 gives
random whole number \(n\) \(=\) lower limit (1) \(+\) \(\lfloor\) random number from 0 to 1 (0.32) \(\times\) possible values (10) \(\rfloor\)
\(1 + \lfloor 0.32 \times 10 \rfloor = 1 + \lfloor 3.2 \rfloor = 1 + 3 = 4\)
Key idea
Computers often make a random number first as a decimal from 0 up to (not including) 1, then use this formula to move it into the range you want. If \(u\) is spread evenly between 0 and 1, then \(n\) is equally likely to be any whole number from \(a\) to \(b\). This is exactly the formula you use to make random whole numbers from Excel's RAND function (see the Excel section).
A classic way to make pseudorandom numbers (linear congruential generator)
Standard notation (the usual math form)
\(X_{n+1}\) \(=\) \((aX_n + c)\) \(\bmod\) \(m\)
In words (symbols replaced with words)
③ \(X_{n+1}\): next random number \(=\) ① \((aX_n + c)\): current random number \(X_n\) times \(a\), plus \(c\) \(\bmod\) ② \(m\): divisor
The formula in words
① Take the \((aX_n + c)\): current random number \(X_n\) times \(a\), plus \(c\)
② divide it by the \(m\): divisor and keep the remainder
③ and you get the \(X_{n+1}\): next random number (repeat this to make a sequence of random numbers)
Quick example
With multiplier 5, increment 3, divisor 16 and a starting value (seed) of 7, the sequence of random numbers is set as follows
next random number \(X_1\) \(=\) 7 times 5, plus 3 (38) \(\bmod\) divisor (16)
\((5 \times 7 + 3) \bmod 16 = 38 \bmod 16 = 6\)
\((5 \times 6 + 3) \bmod 16 = 33 \bmod 16 = 1\)
Key idea
Just repeating a simple step, "multiply, add, keep the remainder", produces a sequence of numbers that looks random. That is the basic idea behind pseudorandom numbers. (Here \(a, c, m\) are constants chosen in advance. They are not the lower and upper limits from the formulas above.) The key property is that the same starting value (seed) always gives exactly the same sequence. In other words, random numbers made by a formula are not truly random. Real computers use improved methods such as the Mersenne Twister instead of a plain linear congruential generator, but the core idea, "a sequence of calculations decided by the seed", is the same.
The numbers from a random number generator follow a uniform distribution, where every number in the range is equally likely. The most important point is that computer random numbers are pseudorandom numbers made by a formula. The same seed (starting value) always gives the same sequence, so they are not true chance.

Symbols and terms

Symbols

\(a\) a The lower limit of the range (this number or more). (Example - for random numbers from 1 to 100, \(a = 1\))
\(b\) b The upper limit of the range (this number or less). (Example - for random numbers from 1 to 100, \(b = 100\))
\(P(X=k)\) P of X equals k The probability that the random number \(X\) is exactly the whole number \(k\). For uniform random whole numbers, it is the same for every \(k\).
\(f(x)\) f of x (probability density) The height of the graph that shows how likely random decimals are (the probability density function). For a uniform distribution, the height is the same everywhere in the range.
\(E[X]\) E of X (expected value) The value that the average gets closer to when you generate many random numbers \(X\). E stands for "expectation".
\(u\) u A uniform random number from 0 up to (not including) 1. Most computer random numbers are first made in this form, then moved into the range you want.
\(\lfloor\ \rfloor\) floor (floor function) A symbol that drops the decimal part of the number inside and rounds it down to a whole number. (Example - \(\lfloor 3.2 \rfloor = 3\))
\(X_n\) X sub n The \(n\)th value in a sequence of pseudorandom numbers. The starting value \(X_0\) is the seed.
\(\bmod\) mod The operation that gives the remainder of a division. (Example - \(38 \bmod 16 = 6\), because 38 divided by 16 is 2 with remainder 6)

Terms

random number A number with no pattern that lets you predict what comes next, like the roll of a die. The generator on this page makes numbers picked at random from the range you set.
uniform distribution A distribution where every value in the range is equally likely. For random whole numbers, every whole number has the same probability. For random decimals, the graph has the same height everywhere.
pseudorandom number A number from a sequence made by a formula that looks random. The formula is called a PRNG (pseudorandom number generator). Almost all computer random numbers are pseudorandom numbers.
seed The starting value for calculating pseudorandom numbers. Starting from the same seed always gives exactly the same sequence. Normally the seed is set automatically, for example from the current time, so each sequence looks different.
linear congruential generator The most classic way to make pseudorandom numbers, by repeating "multiply, add, keep the remainder". It is ideal for learning how they work, but today higher-quality methods such as the Mersenne Twister are the norm in practice.
hardware random number generator A device that makes random numbers from physical events, such as dice, coins, electrical noise in the atmosphere or heat noise in electronic circuits. Since no formula is involved, the numbers cannot be reproduced and come close to true random numbers.
expected value The average of a chance outcome over many repeats. For uniform random numbers, the expected value is exactly the middle of the range.
random sampling Choosing who or what to study at random, for example with random numbers, with no human choice involved. It is the basic way to avoid bias in statistical surveys.

Good to know before you start

Here is what helps you use the calculation on this page with real understanding, not just by pressing the button.

Division with remainders (Grade 4)
  • Being able to find the remainder of a division, as in 38 ÷ 16 = 2 remainder 6 (used in the linear congruential generator)
Decimals and rounding down (Grades 4–5)
  • Being able to drop the decimal part of 3.2 to get 3
  • Knowing that the number of decimal places refers to the tenths place, the hundredths place and so on
Ratios and percents (Grade 6)
  • Being able to switch between decimals and percents, as in a probability of 0.1 and 10%
Basic probability (Grade 7)
  • Knowing that when all outcomes are equally likely, the probability is (number of matching outcomes) ÷ (number of all outcomes)
  • Knowing that the last roll does not change the probability of the next roll (independence)
Expected value (high school, Statistics)
  • Knowing that the expected value is the average you get over many repeats

How to calculate it in Excel

Copy the whole table below and paste it into cell A1 in Excel. It works as is.
Table to find the probability of each whole number
Lower limit a 1
Upper limit b 6
Probability of each whole number =1/(B2-B1+1)
Table to find the graph height (probability density) for random decimals
Lower limit a 0
Upper limit b 10
Probability density (graph height) =1/(B2-B1)
Table to find the average (expected value) of the random numbers
Lower limit a 1
Upper limit b 100
Average (expected value) =(B1+B2)/2
Table to make a random whole number
Lower limit a 1
Upper limit b 100
Random whole number (changes on every recalculation) =B1+INT(RAND()*(B2-B1+1))
Table to find the next random number with a linear congruential generator
Current random number Xn 7
Multiplier a 5
Increment c 3
Divisor m 16
Next random number =MOD(B2*B1+B3,B4)
After pasting, the upper rows are your inputs and the formula in the last row is calculated automatically.
The first table shows about 0.1667 (= 1/6), the third shows 50.5, and the fifth shows 6.
RAND() in the fourth table makes a random number from 0 up to (not including) 1, in exactly the form of the conversion formula in the Formula section. Press F9 to get a new random number each time.
Excel also has the function =RANDBETWEEN(B1,B2), which gives the same kind of random whole number with a single function.

How to calculate it in Google Sheets

Copy the whole table below and paste it into cell A1 in Google Sheets. It works as is.
Table to find the probability of each whole number
Lower limit a 1
Upper limit b 6
Probability of each whole number =1/(B2-B1+1)
Table to find the graph height (probability density) for random decimals
Lower limit a 0
Upper limit b 10
Probability density (graph height) =1/(B2-B1)
Table to find the average (expected value) of the random numbers
Lower limit a 1
Upper limit b 100
Average (expected value) =(B1+B2)/2
Table to make a random whole number
Lower limit a 1
Upper limit b 100
Random whole number (changes on every recalculation) =B1+INT(RAND()*(B2-B1+1))
Table to find the next random number with a linear congruential generator
Current random number Xn 7
Multiplier a 5
Increment c 3
Divisor m 16
Next random number =MOD(B2*B1+B3,B4)
The same formulas as in Excel work as is (RAND, RANDBETWEEN, INT and MOD have the same names in Google Sheets).
Copy the whole table, paste it into cell A1, and replace the input numbers with your own.

How to calculate it in Python

import random

lower = 1     # lower limit
upper = 100   # upper limit
count = 5     # how many to generate

# random whole numbers (repeats allowed)
integers = [random.randint(lower, upper) for _ in range(count)]
# random whole numbers (no repeats)
unique_integers = random.sample(range(lower, upper + 1), count)
# random decimals
decimals = [random.uniform(lower, upper) for _ in range(count)]

print(f"Random whole numbers (repeats allowed): {integers}")
print(f"Random whole numbers (no repeats): {unique_integers}")
print(f"Random decimals: {decimals}")

# with a fixed seed, the same sequence comes back every time you run it (a property of pseudorandom numbers)
random.seed(42)
print(f"Random numbers with seed 42: {[random.randint(1, 100) for _ in range(3)]}")
Runs with just the standard random module (a pseudorandom number generator called the Mersenne Twister). Run the last two lines and you can see that the same seed gives the same result every time. To generate passwords or encryption keys, use the dedicated secrets module instead of random.

How to write it in LaTeX and other math languages (copy and paste)

Probability of each value for random whole numbers (discrete uniform distribution)
P(X = k) = 1 / (b − a + 1)
P(X = k) = \frac{1}{b - a + 1}
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
  <mrow>
    <mi>P</mi><mo>(</mo><mi>X</mi><mo>=</mo><mi>k</mi><mo>)</mo>
    <mo>=</mo>
    <mfrac>
      <mn>1</mn>
      <mrow><mi>b</mi><mo>&#x2212;</mo><mi>a</mi><mo>+</mo><mn>1</mn></mrow>
    </mfrac>
  </mrow>
</math>
P(X = k) = 1/(b - a + 1)
1/(b - a + 1)
p := 1/(b - a + 1);
p = 1/(b - a + 1);
P(X = k) = 1/(b - a + 1)
How likely random decimals are (probability density of the continuous uniform distribution)
f(x) = 1 / (b − a)
f(x) = \frac{1}{b - a}
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
  <mrow>
    <mi>f</mi><mo>(</mo><mi>x</mi><mo>)</mo>
    <mo>=</mo>
    <mfrac>
      <mn>1</mn>
      <mrow><mi>b</mi><mo>&#x2212;</mo><mi>a</mi></mrow>
    </mfrac>
  </mrow>
</math>
f(x) = 1/(b - a)
1/(b - a)
f := 1/(b - a);
f = 1/(b - a);
f(x) = 1/(b - a)
Average of random numbers (expected value of a uniform distribution)
E[X] = (a + b) / 2
E[X] = \frac{a + b}{2}
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
  <mrow>
    <mi>E</mi><mo>[</mo><mi>X</mi><mo>]</mo>
    <mo>=</mo>
    <mfrac>
      <mrow><mi>a</mi><mo>+</mo><mi>b</mi></mrow>
      <mn>2</mn>
    </mfrac>
  </mrow>
</math>
E[X] = (a + b)/2
(a + b)/2
mean := (a + b)/2;
mean_x = (a + b)/2;
E[X] = (a + b)/2
Turning a random number from 0 to 1 into a random whole number in a range
n = a + ⌊u × (b − a + 1)⌋
n = a + \lfloor u \times (b - a + 1) \rfloor
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
  <mrow>
    <mi>n</mi>
    <mo>=</mo>
    <mi>a</mi>
    <mo>+</mo>
    <mo>&#x230A;</mo>
    <mi>u</mi>
    <mo>&#xD7;</mo>
    <mo>(</mo><mi>b</mi><mo>&#x2212;</mo><mi>a</mi><mo>+</mo><mn>1</mn><mo>)</mo>
    <mo>&#x230B;</mo>
  </mrow>
</math>
n = a + |__ u xx (b - a + 1) __|
a + Floor[u*(b - a + 1)]
n := a + floor(u*(b - a + 1));
n = a + floor(u*(b - a + 1));
n = a + ⌊u × (b - a + 1)⌋
A classic way to make pseudorandom numbers (linear congruential generator)
Xₙ₊₁ = (a·Xₙ + c) mod m
X_{n+1} = (a X_n + c) \bmod m
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
  <mrow>
    <msub><mi>X</mi><mrow><mi>n</mi><mo>+</mo><mn>1</mn></mrow></msub>
    <mo>=</mo>
    <mo>(</mo>
    <mi>a</mi><msub><mi>X</mi><mi>n</mi></msub>
    <mo>+</mo><mi>c</mi>
    <mo>)</mo>
    <mo>mod</mo>
    <mi>m</mi>
  </mrow>
</math>
X_(n+1) = (a X_n + c) mod m
Mod[a*x + c, m]
X[n + 1] := (a*X[n] + c) mod m;
x_next = mod(a*x + c, m);
X_(n+1) = (a X_n + c) mod m

How to have ChatGPT  do the calculation

You are an assistant for generating random numbers. Do the following by actually running Python code, and base your answer only on the numbers from the execution result (random numbers cannot be made without running code, so do not guess or make up any numbers).

1. Generate 5 random whole numbers from 1 to 100 with no repeats.
2. Sort those 5 numbers in ascending order.
3. Generate 1 random decimal from 0.2 to 112.5 with 3 decimal places.

Show the code you used and the numbers from the execution result.

How to Use
  1. 1
    Enter your numbers
    Type the numbers you want to calculate with into the input fields
  2. 2
    Calculate
    Press the "Calculate" button
  3. 3
    Check the result
    The result appears on the spot. The same page also explains the idea behind the calculation and the formula
  DataChef Features
Easy and Free
Unlimited conversions for free.
No technical knowledge required.
Intuitive and user-friendly operation.
No Registration Required
Available immediately after access.
Can be used without registering personal information.
Safe and Secure
Fully SSL encrypted communication.
Automatic file deletion by clicking "download".
Fast
High-speed site access
and rapid file conversion.
No Watermark
No watermark.
No attribution required.
Commercial Use Available
Free for commercial use.
No need to contact us for commercial use permission.