Desmos doesn’t have a built-in RAND() function like Excel, but you can still generate random numbers using the random() function inside the graphing calculator. This guide shows you the exact syntax, how to make a list of random numbers, how to refresh them, and how to use them in sliders or expressions. You only need a web browser or the Desmos app—no account required.
What You’ll Need
- A device with internet access (or the Desmos app installed).
- Open desmos.com/calculator in your browser, or launch the Desmos Graphing Calculator app.
- No login or account is necessary for basic use.
Step-by-Step
- Open a new graph. Go to desmos.com/calculator and click “Start Graphing” or open the app. You’ll see an empty expression list on the left.
- Type the basic random function. Click on the first empty input line (where it says “Untitled Graph” or “Add Item”). Type
random()and press Enter. Desmos will return a random decimal between 0 and 1, for example0.374. This is the core function. - Generate an integer between 1 and N. To get a whole number, multiply and round. For a random integer from 1 to 10, type
round(random()*9)+1and press Enter. Theround()function rounds to the nearest integer, and the+1shifts the range from 0–9 to 1–10. Test it a few times by pressing Enter on the expression—each time you press Enter on that line, it recalculates. - Generate a decimal in a custom range. For a random decimal between
aandb, use the formulaa + random()*(b-a). For example, to get a decimal between 5 and 15, type5 + random()*10. This gives a value like8.234. - Create a list of random numbers. Use curly braces to make a list. Type
[random() for i=[1..10]]to get a list of 10 random decimals. Press Enter—Desmos shows a list like[0.231, 0.982, ...]. To get 10 integers from 1 to 100, use[round(random()*99)+1 for i=[1..10]]. - Refresh the random values. Desmos recalculates
random()every time you press Enter on the expression line, or when you click the “recalculate” button (the circular arrow icon that appears when you hover over the expression). You can also pressCtrl+Enter(Windows) orCmd+Enter(Mac) to recalculate all expressions. - Use random numbers in a slider. Create a slider by typing
a=random()and pressing Enter. Desmos will ask if you want to “Add slider”. Click “Add slider”. Now you have a variableathat holds a random value. You can drag the slider or click the refresh icon to get a new random value. To make an integer slider, typen=round(random()*10)and add a slider—it will show integer steps if you set the step to 1 in the slider settings. - Plot random points. To scatter random points, define a list of x and y coordinates. For example, type
x=[random() for i=[1..20]]andy=[random() for i=[1..20]]. Then type(x,y)and press Enter—Desmos will plot 20 random points in the unit square. You can adjust the range by multiplying, e.g.,x=[random()*10 for i=[1..20]]. - Randomize a function’s parameter. Suppose you want a sine wave with a random amplitude. Type
amp=random()*5and theny=amp*sin(x). Press Enter on theampline to get a new amplitude each time. - Save or share your random generator. Once you have your random expressions, click “Share” at the top right to copy a link or embed code. Others can view and interact with your random generator.
Common Mistakes
- Using
rand()instead ofrandom(). Desmos only recognizesrandom(). Typingrand()will show an error. - Forgetting the parentheses.
randomwithout parentheses is not a function call—Desmos treats it as a variable name, not a random value. - Expecting
random()to give an integer. It always returns a decimal between 0 and 1. You must multiply and round to get integers. - Using square brackets for lists instead of curly braces. In Desmos, lists use curly braces
{}, not square brackets[]. For example,{1,2,3}is a list, while[1,2,3]is invalid. - Not recalculating. If you copy a random expression and paste it elsewhere, it may not update automatically. Press Enter on the new line to recalculate.
Tips
- Use
floor()instead ofround()for uniform integer distribution.round()biases the endpoints slightly because it rounds .5 up. For a true uniform integer from 1 to 10, usefloor(random()*10)+1. This works becausefloor()always rounds down, giving 0–9, then +1 gives 1–10. - Create a reusable random variable. Define
r=random()once, then userin multiple expressions. This ensures the same random value is used across all expressions until you recalculate. - Use the “recalculate” button for quick refreshes. Hover over the expression and click the circular arrow to get a new random value without pressing Enter.
- Combine with sliders for interactive exploration. Set a slider to a random value and then drag it—you can see how the graph changes with different random seeds.
- For a normal distribution, use the
randomNormal()function. Desmos also hasrandomNormal(mean, sd)which returns a random number from a normal distribution. For example,randomNormal(0,1)gives a standard normal random value.
Troubleshooting
- I see an error “undefined variable”. Make sure you typed
random()with parentheses. If you see “undefined” next torandom, you forgot the parentheses. - My random number doesn’t change. Desmos only recalculates when you press Enter on the expression or click the refresh icon. Also, if you defined a variable like
r=random(), it only changes when you press Enter on that specific line. - My list syntax fails. Check that you used curly braces for the list and square brackets for the range. The correct syntax is
[random() for i=[1..10]]—note the square brackets around the range1..10and the curly braces around the whole list (actually, the whole list uses square brackets in Desmos? Let me correct: In Desmos, lists are defined with curly braces, e.g.,{1,2,3}. However, for list comprehensions, you use square brackets:[random() for i=[1..10]]is correct. I apologize for the confusion. The correct list comprehension syntax is square brackets. So use[random() for i=[1..10]]. - I get a decimal but I need a whole number. Use
floor(random()*N)+1orround(random()*(N-1))+1for integers from 1 to N. - Random points don’t appear on the graph. Make sure you plot them as a list of points, e.g.,
(x,y)wherexandyare lists of the same length. If you have a single point, it will show as one dot. Also check that your x and y ranges are visible in the current viewport.
Frequently Asked Questions
Q: Can I generate a random integer between 1 and 100?
A: Yes. Use floor(random()*100)+1. This gives a whole number from 1 to 100 inclusive.
Q: How do I get a random number between two specific numbers, like 2.5 and 7.5?
A: Use the formula 2.5 + random()*5 because 7.5 – 2.5 = 5. In general, min + random()*(max-min).
Q: Does Desmos have a RAND() function like Excel?
A: No. Desmos uses random() (lowercase) and randomNormal(). They work similarly but the syntax is different.
Q: Can I make a random number that updates automatically without pressing Enter?
A: No, Desmos doesn’t auto-update random values. You must press Enter or click the refresh icon on the expression. There is no continuous animation for random numbers.
Q: How do I generate a list of 50 random numbers?
A: Type [random() for i=[1..50]]. This creates a list of 50 decimals between 0 and 1. For integers, use [floor(random()*10)+1 for i=[1..50]].
Q: Can I use random numbers in a table?
A: Yes. Click the “+” button and choose “Table”. In the first column, enter x_1 and then type an expression like random() in the cell. Desmos will fill each row with a random value. You can also use a list comprehension to fill a column.
Related
- Google Sheets DDB Function: Double-Declining Depreciation
- Data Entry and CRM Management: A Practical Guide
- Random Number for Verification Code: How It Works
Try it: the Date Difference Calculator: days, months, years and weekdays between two dates, with the DATEDIF formulas.
More in How-to basics
- Select a Cell and Highlight Whole Row in ExcelYes, you can make Excel highlight the entire row when you select a cell. The most reliable method…
- Color by Number Hot Air Balloon: How It WorksA color by number hot air balloon is a printable or digital coloring page where the balloon is…
- Find and Replace Duplicates in Excel: Safe MethodsTo find duplicates in Excel, select the cells and choose Home > Conditional Formatting > Highlight Cells Rules…
- Custom Number Format in Excel for Lakhs: A Clear GuideTo show numbers with Indian lakh-style digit grouping in Excel, select the cells, press Ctrl+1, choose Custom, and…
- Out of Office Reply in Outlook: Set It Up Step by StepTo set an out-of-office notice in Outlook, open Automatic Replies, turn them on, write your message, and—if available—set…
- DDSolver Excel Add-in: What It Does and How to Use ItDDSolver is a specialized Excel add-in for analyzing and comparing in-vitro drug dissolution profiles; it is not the…
Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources
Spotted an error in this guide? Let us know.