logo
search
Function Problems

How to Generate Random Numbers Using Median and IQR in Excel

Rana GarciaRana Garcia Oct 10, 2026 871 views

Question details

The user wants to generate random values based on a dataset's median and interquartile range (IQR), potentially following a normal distribution.

How to Generate Random Numbers Using Median and IQR in Excel
Product
Excel
Device & OS
not provided
Scenario
Simulating new data or conducting statistical analysis based on the baseline properties (median and quartiles) of an existing dataset.
Observed behavior
The user requires the correct combination of statistical functions to calculate the IQR and generate normally distributed random numbers around those parameters.
Before you start

Ensure your source dataset is clean and organized in a single column or row. You should also decide whether your generated numbers must strictly fall within the first and third quartiles or if they can approximate a normal distribution.

Solution 1Recommended

Use Statistical Functions and NORM.INV to Generate Values

Calculate the median and quartiles first, derive the IQR, and then use the NORM.INV and RAND functions to generate normally distributed random numbers.

This method uses an approximate normal-distribution approach. It generates values around the specified range but does not strictly guarantee that every single result will fall exactly between the first and third quartiles.

1
Calculate the Median

Select an empty cell and use the formula =MEDIAN(data_range) to find the middle value of your dataset.

2
Calculate the First and Third Quartiles

In two separate cells, calculate Q1 using =QUARTILE.INC(data_range, 1) and Q3 using =QUARTILE.INC(data_range, 3).

3
Determine the Interquartile Range (IQR)

Subtract your Q1 result from your Q3 result to find the IQR (e.g., =cell_Q3 - cell_Q1).

4
Generate the Random Numbers

Use the inverse normal distribution formula combined with RAND(). Enter =NORM.INV(RAND(), median - (IQR / 2), median + (IQR / 2)), substituting 'median' and 'IQR' with their respective cell references.

Use Statistical Functions and NORM.INV to Generate Values
Distribution Characteristics: Because the normal distribution spans infinitely, some generated values may occasionally exceed the bounds of Q1 and Q3. Choose a different probability distribution if your data strictly requires hard limits.

Generate Random Numbers and Perform Statistical Analysis with WPS Spreadsheet

WPS Spreadsheet fully supports advanced statistical functions like NORM.INV, MEDIAN, and QUARTILE.INC. You can easily perform complex data simulations and statistical analysis in a lightweight, free environment.

  1. 1. Open Your Dataset: Launch WPS Spreadsheet and open the workbook containing your source data.
  2. 2. Input Statistical Formulas: Use the MEDIAN and QUARTILE.INC formulas in empty cells to establish your baseline parameters.
  3. 3. Apply the Random Generation Formula: Type the NORM.INV and RAND combination formula into the target cells and drag the fill handle to generate multiple values.
  4. 4. Lock the Values: Since RAND() is volatile, copy your generated numbers, right-click, and select 'Paste as Values' to prevent them from recalculating.
Fully compatible with Microsoft Excel formulas and statistical functions.Free and lightweight alternative for data analysis and simulation.Familiar user interface ensures a seamless transition with zero learning curve.Easily freeze random values using the powerful Paste Special tools.
microsoft office alternative - wps office

Frequently Asked Questions

Can I strictly constrain the random numbers between Q1 and Q3?

Yes. If you do not need a normal distribution and simply want uniform random numbers bounded by Q1 and Q3, you can use the formula =Q1 + RAND() * (Q3 - Q1).

Why do the random numbers change every time I edit a cell?

The RAND() function is volatile, meaning it recalculates automatically whenever any change is made to the worksheet. To keep your simulated data static, copy the cells containing the formulas and use 'Paste Special' > 'Values' to overwrite the formulas with fixed numbers.

What is the difference between QUARTILE.INC and QUARTILE.EXC?

QUARTILE.INC includes the minimum (0th percentile) and maximum (100th percentile) values when evaluating the dataset. QUARTILE.EXC excludes them. For standard statistical IQR calculations, QUARTILE.INC is most commonly used.