How to Generate Random Numbers in Desmos

How-to basics · Updated November 23, 2026

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

  1. 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.
  2. 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 example 0.374. This is the core function.
  3. 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)+1 and press Enter. The round() function rounds to the nearest integer, and the +1 shifts 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.
  4. Generate a decimal in a custom range. For a random decimal between a and b, use the formula a + random()*(b-a). For example, to get a decimal between 5 and 15, type 5 + random()*10. This gives a value like 8.234.
  5. 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]].
  6. 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 press Ctrl+Enter (Windows) or Cmd+Enter (Mac) to recalculate all expressions.
  7. 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 variable a that 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, type n=round(random()*10) and add a slider—it will show integer steps if you set the step to 1 in the slider settings.
  8. Plot random points. To scatter random points, define a list of x and y coordinates. For example, type x=[random() for i=[1..20]] and y=[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]].
  9. Randomize a function’s parameter. Suppose you want a sine wave with a random amplitude. Type amp=random()*5 and then y=amp*sin(x). Press Enter on the amp line to get a new amplitude each time.
  10. 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 of random(). Desmos only recognizes random(). Typing rand() will show an error.
  • Forgetting the parentheses. random without 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 of round() for uniform integer distribution. round() biases the endpoints slightly because it rounds .5 up. For a true uniform integer from 1 to 10, use floor(random()*10)+1. This works because floor() always rounds down, giving 0–9, then +1 gives 1–10.
  • Create a reusable random variable. Define r=random() once, then use r in 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 has randomNormal(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 to random, 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 range 1..10 and 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)+1 or round(random()*(N-1))+1 for 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) where x and y are 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

Try it: the Date Difference Calculator: days, months, years and weekdays between two dates, with the DATEDIF formulas.

More in How-to basics

Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources

Spotted an error in this guide? Let us know.