A trajectory, also known as an episode or a rollout, is a sequence of states, actions, and rewards ((\mathbf{s}_0, \mathbf{a}_0, r_1, \mathbf{s}_1, \mathbf{a}_1, r_2, ...)) experienced by an agent from an initial state to a terminal state. It represents one complete trial of interaction, capturing the agent's entire decision-making history and the environment's responses. This sequence is the fundamental unit of data used for training in model-free RL algorithms, where the policy is improved by analyzing the outcomes of past trajectories.
Glossary
Trajectory

What is a Trajectory?
In reinforcement learning, a trajectory is the complete record of an agent's interaction with its environment during a single trial, from start to finish.
For sim-to-real transfer learning, trajectories generated in high-fidelity physics simulations are critical. They provide a low-cost, parallelizable source of training data for learning complex robotic skills. The quality and diversity of these simulated trajectories directly influence policy robustness. Techniques like domain randomization explicitly vary simulation parameters across trajectories to ensure the learned policy generalizes to the physical world's unpredictable dynamics, enabling successful zero-shot transfer.
Key Components of a Trajectory
A trajectory, or episode, is the fundamental unit of experience in reinforcement learning. It represents one complete trial of an agent's interaction with its environment, from an initial state to a terminal state. Understanding its constituent parts is essential for analyzing learning algorithms and designing effective training regimes.
State Sequence
The state sequence is the ordered list of observations the agent receives from the environment. In robotics, a state can be high-dimensional, including:
- Proprioceptive data: Joint angles, velocities, and motor torques.
- Exteroceptive data: Camera images, LiDAR point clouds, or depth sensor readings.
- Task-specific variables: The position of a target object or the remaining time in an episode.
The sequence
(s₀, s₁, ..., s_T)captures the environment's evolution, forming the primary observational input for the agent's policy and value functions.
Action Sequence
The action sequence comprises the decisions made by the agent's policy at each timestep. For robotic control, actions are typically continuous vectors specifying:
- Joint position or torque targets for a manipulator arm.
- Velocity commands for a mobile robot base.
- Gripper open/close signals.
The sequence
(a₀, a₁, ..., a_{T-1})represents the agent's direct influence on the environment. The policy's role is to map from the current states_tto an actiona_tthat maximizes cumulative reward.
Reward Signal
The reward signal r_t is a scalar feedback provided by the environment after each action. It quantifies the desirability of the transition from state s_t to s_{t+1} after taking action a_t. In robotics, rewards are carefully engineered to guide learning:
- Sparse rewards: A large positive reward only upon task completion (e.g., +1000 for inserting a peg).
- Dense rewards: Shaped feedback at every step (e.g., -distance to goal, -effort penalty).
- Composite rewards: A weighted sum of multiple objectives (e.g.,
α * (progress) - β * (energy_used)). The trajectory's total return,G_t = Σ γ^k * r_{t+k}, is the ultimate objective the agent seeks to maximize.
Terminal Condition
The terminal condition defines when a trajectory ends. It is a crucial component for structuring the learning problem and defining an episode's horizon. Common terminal conditions in robotic RL include:
- Task Success: The goal is achieved (e.g., object grasped, door opened).
- Task Failure: An irreversible error occurs (e.g., robot falls over, object dropped).
- Timeout: A maximum episode length
T_maxis reached. - Constraint Violation: A safety limit is breached (e.g., joint torque exceeds a threshold). Terminal states are often absorbing, meaning no further actions or rewards occur. Distinguishing between terminal states due to success or failure is vital for credit assignment.
Transition Tuples
A trajectory is fundamentally decomposed into a sequence of transition tuples (s_t, a_t, r_t, s_{t+1}, done_t). This atomic unit of experience is the core data structure for most RL algorithms.
s_t, a_t, r_t, s_{t+1}: Used in Temporal Difference (TD) learning and Q-Learning to update value functions via the Bellman equation.done_t: A boolean flag indicating ifs_{t+1}is terminal. These tuples are stored in a replay buffer for off-policy algorithms like DDPG and SAC, enabling sample-efficient learning by breaking temporal correlations through random minibatch sampling from past experiences.
Return and Discounting
The return G_t is the total discounted future reward from timestep t onward: G_t = r_t + γr_{t+1} + γ²r_{t+2} + ... + γ^{T-t-1}r_{T-1}.
- Discount factor (γ): A value between 0 and 1 that determines the present value of future rewards. A
γnear 1 makes the agent far-sighted, while aγnear 0 makes it short-sighted. - Undiscounted return: Used in episodic tasks with a natural horizon (γ=1).
The value function
V(s)orQ(s,a)is an estimate of the expected return, and the entire trajectory is used to compute or refine these estimates, either through Monte Carlo methods (using the full return) or TD methods (using bootstrapped estimates).
The Role of Trajectories in RL Training
In reinforcement learning, a trajectory is the fundamental unit of experience used for training. It encapsulates a complete trial of an agent's interaction with its environment.
A trajectory (also called an episode or rollout) is a sequence of states, actions, and rewards ((s_0, a_0, r_1, s_1, a_1, r_2, ...)) experienced by an agent from an initial state to a terminal state. It represents one complete attempt at a task, such as a robot completing a grasp or a game reaching its conclusion. Trajectories are the raw data from which value functions and policy gradients are estimated, making them the primary input for most RL algorithms.
During training, algorithms like Policy Gradient and Actor-Critic methods sample trajectories—often stored in a replay buffer—to compute updates. The sequential nature of a trajectory is crucial for calculating discounted returns and understanding long-term consequences via the Bellman equation. In sim-to-real transfer, generating vast quantities of diverse trajectories in simulation is essential for learning robust policies that can generalize to physical hardware with minimal online fine-tuning.
Types and Characteristics of Trajectories
A comparison of trajectory types based on their defining characteristics, data structure, and typical use cases in reinforcement learning for robotics.
| Characteristic | Deterministic Trajectory | Stochastic Trajectory | Optimal Trajectory | Expert Demonstration Trajectory |
|---|---|---|---|---|
Definition | A fixed sequence of states and actions produced by a deterministic policy. | A probable sequence generated by a stochastic policy, representing a distribution over possible paths. | A trajectory that maximizes the expected cumulative reward for a given task and reward function. | A trajectory generated by a human or algorithmic expert, used as ground truth for imitation learning. |
Policy Type Source | Deterministic Policy | Stochastic Policy | Optimal Policy | Expert Policy (often unknown) |
Primary Use Case | Deployment, reproducibility testing, and deterministic control. | Exploration, capturing environmental uncertainty, and policy gradient training. | Benchmarking, reward shaping analysis, and optimal control reference. | Behavioral cloning, dataset creation for inverse reinforcement learning. |
Data Variability | ||||
Contains Reward Signal | Varies (often yes) | |||
Key RL Algorithm Association | DDPG, TD3 | PPO, SAC, Vanilla Policy Gradient | Value Iteration, Q-Learning (theoretically) | Behavioral Cloning, DAGGER |
Critical for Sim-to-Real Transfer | High (for reproducible deployment) | High (for learning robust policies via domain randomization) | High (as a performance target) | Medium (for bootstrapping or reward learning) |
Storage in Replay Buffer |
Frequently Asked Questions
A trajectory, or episode, is the fundamental unit of experience in reinforcement learning, representing a complete sequence of interactions between an agent and its environment. These FAQs address its role in training, analysis, and the sim-to-real transfer process.
A trajectory (also called an episode or rollout) is a complete sequence of states, actions, and rewards experienced by an agent from an initial state to a terminal state, representing one full trial of interaction with an environment. Formally, a trajectory τ is denoted as τ = (s₀, a₀, r₁, s₁, a₁, r₂, ..., s_T), where s is state, a is action, and r is reward. It is the atomic data structure for model-free learning algorithms, which use collections of trajectories to estimate value functions or compute policy gradients. In sim-to-real transfer learning, trajectories generated in high-fidelity physics simulations are the primary training data used to develop robust policies before any real-world deployment.
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

Automate internal workflows
Use AI to route work, draft outputs, trigger actions, and keep approvals and logs in place.
Useful when repetitive work moves across multiple tools and teams.

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
Related Terms
A trajectory is a fundamental unit of experience in RL. Understanding these related concepts is essential for designing, analyzing, and improving learning algorithms.
Episode
An episode is synonymous with a trajectory, representing one complete trial from an initial state to a terminal state. It is the atomic unit for Monte Carlo methods in RL, where the total return is calculated at the end. Episodes can be of fixed length or terminate upon reaching a goal or failure condition.
- Key Distinction: While 'trajectory' emphasizes the sequence of transitions, 'episode' often refers to the entire experiential unit, including its final outcome and return.
Rollout
A rollout refers to the process of executing a policy in an environment to generate a trajectory. It is both a noun (the resulting data) and a verb (the act of collection). In model-based RL, rollouts are generated from a learned dynamics model for planning. In on-policy algorithms like PPO, each training step involves collecting a batch of fresh rollouts from the current policy.
- Primary Use: Generating data for policy evaluation, planning, or training updates.
Experience Tuple
An experience tuple (or transition) is the fundamental data point within a trajectory, typically represented as (s, a, r, s').
- State (s): The observation at time
t. - Action (a): The action taken.
- Reward (r): The scalar feedback received.
- Next State (s'): The resulting observation.
These tuples are stored in a replay buffer for off-policy learning (e.g., DDPG, SAC), where they are sampled randomly to break temporal correlations and improve sample efficiency.
Return (Cumulative Reward)
The return (G) is the total discounted future reward accumulated over a trajectory. For a trajectory starting at time t, it's calculated as: G_t = r_t + γr_{t+1} + γ²r_{t+2} + ... where γ (gamma) is the discount factor between 0 and 1.
- Purpose: It defines the objective the agent aims to maximize. The value function
V(s)is the expected return starting from states. - Credit Assignment: Analyzing which actions in a trajectory contributed to a high or low return is a core challenge in RL.
Horizon
The horizon defines the temporal scope of a trajectory. It can be:
- Finite Horizon: The trajectory has a maximum fixed number of steps (e.g., 1000). Common in episodic tasks.
- Infinite Horizon: Tasks continue indefinitely, requiring a discount factor
γ < 1to ensure the return is finite. Common in continuing tasks.
Effective Horizon: The number of steps into the future where rewards significantly impact the current decision, roughly 1/(1-γ). A high gamma (e.g., 0.99) implies a long effective horizon (~100 steps), encouraging long-term planning.
Monte Carlo vs. Temporal Difference
These are two fundamental approaches for learning from trajectories:
- Monte Carlo (MC) Methods: Learn directly from complete trajectories. They wait until the end of an episode, calculate the actual return
G_t, and use it to update value estimates. High variance, zero bias. - Temporal Difference (TD) Methods: Learn from incomplete trajectories. They update estimates based on the observed reward and the current estimate of the next state's value (a bootstrapped estimate). Lower variance, some bias. TD(λ) provides a spectrum between pure TD (one-step) and MC (full-trajectory) updates.
This trade-off is central to value function learning and policy evaluation.

About the author
Prasad Kumkar
CEO & MD, Inference Systems
Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.
His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.
Partnered with leading AI, data, and software stack.
How We Work
Custom AI workflows for your Business
One-fit-all AI don't work for modern businesses. At Inferensys, we aim to understand your business & custom requirements; which we use to define most efficient agentic workflows, the data, and the tools for your business.
01
Review the use case
We understand the task, the users, and where AI can actually help.
Read more02
Pick the right approach
We define what needs search, automation, or product integration.
Read more03
Build the first useful version
We implement the part that proves the value first.
Read more04
Improve from there
We add the checks and visibility needed to keep it useful.
Read moreThe first call is a practical review of your use case and the right next step.
Talk to Us