---
title: "Pseudorandom Value — AP CSA Definition & Exam Guide"
description: "A pseudorandom value is generated by an algorithm like Math.random() and only appears random. Learn how AP CSA tests it in Topic 1.11 with range formulas."
canonical: "https://fiveable.me/ap-comp-sci-a/key-terms/pseudorandom-value"
type: "key-term"
subject: "AP Computer Science A"
unit: "Unit 1"
---

# Pseudorandom Value — AP CSA Definition & Exam Guide

## Definition

In AP Computer Science A, a pseudorandom value is a number produced by a deterministic algorithm (like Math.random()) that looks random but is actually computed. Math.random() returns a pseudorandom double from 0.0 (inclusive) up to but not including 1.0, which you scale and shift to get other ranges.

## What It Is

A pseudorandom value is a number that looks random but isn't truly random. It's produced by an [algorithm](/ap-comp-sci-a/key-terms/algorithm "fv-autolink") following fixed mathematical steps. Computers can't flip real coins, so they fake it: an algorithm crunches a starting number (a seed) through a formula and spits out values that are spread out unpredictably enough to act random for your purposes.

In AP CSA, the pseudorandom value you care about comes from `Math.random()`, a static method in the [Math class](/ap-comp-sci-a/unit-1/using-the-math-class/study-guide/6e652tzJOa5eE5mjPATE "fv-autolink") (which lives in `java.lang`, so it's available by default with no import). It returns a `double` greater than or equal to 0.0 and strictly less than 1.0. On its own that's not super useful, so you transform it. `(int)(Math.random() * 6) + 1` simulates a die roll. The [pattern](/ap-comp-sci-a/unit-1/why-programming-why-java/study-guide/lVK6rmrBuug17i1Hna9z "fv-autolink") is multiply to set the range size, add to shift the starting point, and cast to `int` to chop off the decimal.

## Why It Matters

Pseudorandom values live in **Topic 1.11 (Using the Math Class)** in **[Unit 1](/ap-comp-sci-a/unit-1 "fv-autolink"): Using Objects and Methods**, under learning objective **1.11.A**, which asks you to write expressions using built-in math [libraries](/ap-comp-sci-a/key-terms/library "fv-autolink") and determine the values they produce. `Math.random()` is one of the Math class methods listed in the Java Quick Reference, so the College Board hands you its signature on the exam but expects you to know how to use it.

The real skill being tested isn't randomness trivia. It's whether you can reason about ranges. Given `(int)(Math.random() * 10) + 5`, can you say the result is an integer from 5 to 14, inclusive? That kind of expression-evaluation question is exactly what 1.11.A targets, and the random-range formula shows up again any time later code needs a simulated coin flip, dice roll, or random [index](/ap-comp-sci-a/key-terms/index "fv-autolink").

## Connections

### [Math.random() (Unit 1)](/ap-comp-sci-a/key-terms/mathrandom)

Math.random() is THE source of pseudorandom values in AP CSA. It's a [static method](/ap-comp-sci-a/key-terms/static-method "fv-autolink"), so you call it on the class itself, never on an object. Every random-range trick on the exam starts with this one method returning a double in [0.0, 1.0).

### Random number generation and range formulas (Unit 1)

The exam payoff is turning a raw pseudorandom double into a useful integer range. Memorize the template (int)(Math.random() * range) + min, where range is how many possible values you want and min is the smallest one. Read it backwards to decode someone else's [expression](/ap-comp-sci-a/key-terms/expression "fv-autolink").

### Casting and integer truncation (Unit 1)

The (int) cast in random expressions truncates toward zero, it does not round. That's why (int)(Math.random() * 6) gives 0 through 5 and never 6. Mixing up truncation and rounding is one of the easiest ways to be off by one on an MCQ.

### Static methods and the Math class (Unit 1)

The Math class contains only class (static) methods, per EK 1.11.A.2. Math.random() reinforces the bigger Unit 1 idea that some methods belong to the class, not to instances, so you write Math.random(), not new Math().

## On the AP Exam

This concept shows up in multiple-choice questions built on learning objective 1.11.A. A typical stem gives you an expression like `(int)(Math.random() * 20) + 10` and asks for the range of possible values, or describes a target range (say, integers 3 through 8) and asks which expression produces it. You need to identify both endpoints correctly and remember which one is inclusive. The full range of a random expression includes both the minimum and the maximum integer after truncation.

No released FRQ has used the phrase "pseudorandom value" verbatim, but FRQs regularly require a line of code that picks a random element, simulates a chance event, or generates a value in a range. Writing the scale-shift-cast expression correctly is a real point on the table. Practice converting both directions: expression to range, and range to expression.

## pseudorandom value vs truly random value

A truly random value comes from an unpredictable physical process. A pseudorandom value comes from a deterministic algorithm, meaning the same starting conditions produce the same sequence every time. Math.random() is pseudorandom. It just does such a good job of looking random that it works fine for simulations and games, which is all AP CSA asks of it.

## Key Takeaways

- A pseudorandom value is computed by a deterministic algorithm but appears random, and in Java you get one from Math.random().
- Math.random() returns a double that is greater than or equal to 0.0 and strictly less than 1.0, so 1.0 itself is never returned.
- To get a random integer from min to max inclusive, use (int)(Math.random() * (max - min + 1)) + min.
- The (int) cast truncates the decimal part instead of rounding, which is why the multiplier value itself is never reached.
- Math.random() is a static method in the Math class, part of java.lang, so it needs no import and is called on the class, not an object.
- On the exam, the core skill is determining the exact range of values an expression with Math.random() can produce, including both endpoints.

## FAQs

### What is a pseudorandom value in AP Computer Science A?

It's a value generated by an algorithm, like Math.random(), that appears random but is deterministically computed. In AP CSA it's covered in Topic 1.11 under learning objective 1.11.A, and Math.random() returns a pseudorandom double in the range [0.0, 1.0).

### Can Math.random() ever return 1.0?

No. Math.random() returns a double greater than or equal to 0.0 and strictly less than 1.0. That's why (int)(Math.random() * 6) gives 0 through 5, never 6.

### Is Math.random() actually random?

No, it's pseudorandom. An algorithm computes each value deterministically from internal state, so it only simulates randomness. For everything AP CSA asks (dice rolls, random indexes, simulations), that's good enough.

### How do I get a random integer between two numbers in Java?

Use (int)(Math.random() * (max - min + 1)) + min. For example, (int)(Math.random() * 6) + 1 produces an integer from 1 to 6, like rolling a standard die.

### What's the difference between Math.random() and other Math class methods like Math.pow()?

Math.pow(), Math.sqrt(), and Math.abs() take input and return a predictable result, while Math.random() takes no parameters and returns a different pseudorandom double each call. All of them are static methods in the Math class listed in the Java Quick Reference.

## Related Study Guides

- [1.11 Using the Math Class](/ap-comp-sci-a/unit-1/using-the-math-class/study-guide/6e652tzJOa5eE5mjPATE)

## Structured Data

```json
{"@context":"https://schema.org","@graph":[{"@type":"LearningResource","@id":"https://fiveable.me/ap-comp-sci-a/key-terms/pseudorandom-value#resource","name":"Pseudorandom Value — AP CSA Definition & Exam Guide","url":"https://fiveable.me/ap-comp-sci-a/key-terms/pseudorandom-value","learningResourceType":"Concept explainer","educationalLevel":"AP® / High School","about":{"@id":"https://fiveable.me/ap-comp-sci-a/key-terms/pseudorandom-value#term"},"audience":{"@type":"EducationalAudience","educationalRole":"student"},"dateModified":"2026-06-11T05:27:19.799Z","isPartOf":{"@type":"Collection","name":"AP Computer Science A Key Terms","url":"https://fiveable.me/ap-comp-sci-a/key-terms"},"publisher":{"@type":"Organization","name":"Fiveable","url":"https://fiveable.me"}},{"@type":"DefinedTerm","@id":"https://fiveable.me/ap-comp-sci-a/key-terms/pseudorandom-value#term","name":"pseudorandom value","description":"In AP Computer Science A, a pseudorandom value is a number produced by a deterministic algorithm (like Math.random()) that looks random but is actually computed. Math.random() returns a pseudorandom double from 0.0 (inclusive) up to but not including 1.0, which you scale and shift to get other ranges.","url":"https://fiveable.me/ap-comp-sci-a/key-terms/pseudorandom-value","inDefinedTermSet":{"@type":"DefinedTermSet","name":"AP Computer Science A Key Terms","url":"https://fiveable.me/ap-comp-sci-a/key-terms"}},{"@type":"FAQPage","mainEntity":[{"@type":"Question","name":"What is a pseudorandom value in AP Computer Science A?","acceptedAnswer":{"@type":"Answer","text":"It's a value generated by an algorithm, like Math.random(), that appears random but is deterministically computed. In AP CSA it's covered in Topic 1.11 under learning objective 1.11.A, and Math.random() returns a pseudorandom double in the range [0.0, 1.0)."}},{"@type":"Question","name":"Can Math.random() ever return 1.0?","acceptedAnswer":{"@type":"Answer","text":"No. Math.random() returns a double greater than or equal to 0.0 and strictly less than 1.0. That's why (int)(Math.random() * 6) gives 0 through 5, never 6."}},{"@type":"Question","name":"Is Math.random() actually random?","acceptedAnswer":{"@type":"Answer","text":"No, it's pseudorandom. An algorithm computes each value deterministically from internal state, so it only simulates randomness. For everything AP CSA asks (dice rolls, random indexes, simulations), that's good enough."}},{"@type":"Question","name":"How do I get a random integer between two numbers in Java?","acceptedAnswer":{"@type":"Answer","text":"Use (int)(Math.random() * (max - min + 1)) + min. For example, (int)(Math.random() * 6) + 1 produces an integer from 1 to 6, like rolling a standard die."}},{"@type":"Question","name":"What's the difference between Math.random() and other Math class methods like Math.pow()?","acceptedAnswer":{"@type":"Answer","text":"Math.pow(), Math.sqrt(), and Math.abs() take input and return a predictable result, while Math.random() takes no parameters and returns a different pseudorandom double each call. All of them are static methods in the Math class listed in the Java Quick Reference."}}]},{"@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"AP Computer Science A","item":"https://fiveable.me/ap-comp-sci-a"},{"@type":"ListItem","position":2,"name":"Key Terms","item":"https://fiveable.me/ap-comp-sci-a/key-terms"},{"@type":"ListItem","position":3,"name":"Unit 1","item":"https://fiveable.me/ap-comp-sci-a/unit-1"},{"@type":"ListItem","position":4,"name":"pseudorandom value"}]}]}
```
