# Uczenie z różnic czasowych (TD) i metody Monte Carlo

EN: **Temporal-difference learning and Monte Carlo methods** · id `tdlearning` · aliases: temporal-difference learning, TD learning, TD(λ), SARSA, Monte Carlo methods, metody Monte Carlo, różnice czasowe

Path: [AI Atlas](https://aiatlasgraph.com/llms.txt) › [Uczenie ze wzmocnieniem i decyzje](https://aiatlasgraph.com/t/decisions.md) › [Podstawy RL](https://aiatlasgraph.com/t/rlbasics.md) › Uczenie z różnic czasowych (TD) i metody Monte Carlo

## Description

- PL: Uczenie funkcji wartości z doświadczenia bez modelu środowiska: Monte Carlo uśrednia pełne zwroty z epizodów, a TD aktualizuje oceny po każdym kroku na podstawie oceny następnego stanu.
- EN: Learning value functions from experience without an environment model: Monte Carlo averages full episode returns, while TD updates estimates after every step using the next state's estimate.

## In one sentence

- PL: To uczenie się oceny sytuacji z własnych prób: po całym przebiegu albo już po każdym kolejnym kroku.
- EN: This learns how good situations are from your own attempts: after a whole run, or already after every next step.

## Problem it solves

- PL: Nie znasz reguł świata, a czekanie z wnioskami do samego końca długiego zadania bardzo spowalnia naukę.
- EN: You do not know the world's rules, and waiting until the very end of a long task to draw conclusions slows learning badly.

## What it does

- PL: Działa jak poprawianie prognozy dojazdu w trakcie podróży: każdy przejechany odcinek koryguje wcześniejsze oczekiwanie, zanim dotrzesz na miejsce.
- EN: It works like updating your arrival estimate during a trip: each stretch you cover corrects the earlier expectation before you get there.

## Everyday example

- PL: Kierowca szacuje czas powrotu do domu i poprawia go, gdy utknie w korku, zamiast czekać, aż wejdzie do mieszkania.
- EN: A driver estimates when they will get home and revises it on hitting a traffic jam, instead of waiting until they walk through the door.

## This concerns you if you…

- PL: uczysz program na podstawie prób, bez znajomości reguł
- PL: chcesz zrozumieć, jak działają popularne algorytmy oceniające działania
- PL: masz długie zadania, w których wynik pojawia się dopiero na końcu
- EN: train software from trials without knowing the rules
- EN: want to understand how popular action-scoring algorithms work
- EN: have long tasks where the outcome only appears at the end

## Keywords

TD(0) · TD(lambda) · SARSA · eligibility traces · n-step returns · Monte Carlo prediction · bootstrapping · deadly triad

## How it works

- PL: Metody Monte Carlo szacują wartość stanu jako średni zwrot z zakończonych epizodów; nie potrzebują modelu i nie zakładają własności Markowa. TD(0) po każdym przejściu przesuwa ocenę stanu w stronę celu TD, czyli nagrody z jednego kroku plus zdyskontowanej oceny następnego stanu – łączy próbkowanie jak w Monte Carlo z bootstrappingiem jak w programowaniu dynamicznym. Metody pośrednie, np. zwroty n-krokowe i TD(λ), interpolują między TD(0) a Monte Carlo.
- EN: Monte Carlo methods estimate a state's value as the mean return from finished episodes; they need no model and do not assume the Markov property. TD(0) moves the state's estimate after every transition towards the TD target – the one-step reward plus the discounted estimate of the next state – combining Monte Carlo sampling with dynamic-programming bootstrapping. Intermediate methods such as n-step returns and TD(λ) interpolate between TD(0) and Monte Carlo.

## Limits

- PL: Monte Carlo ma zwykle dużą wariancję, potrzebuje dużo danych i działa tylko w zadaniach epizodycznych, bo czeka na koniec epizodu. TD jest obciążone, bo na początku zależy od wstępnych ocen, ale ma zwykle mniejszą wariancję. Połączenie bootstrappingu, aproksymacji funkcji i uczenia off-policy (tzw. śmiertelna triada) może prowadzić do rozbieżności ocen.
- EN: Monte Carlo usually has high variance, needs a lot of data and only works in episodic tasks, because it waits for the episode to end. TD is biased, since early on it depends on initial estimates, but usually has lower variance. Combining bootstrapping, function approximation and off-policy learning (the so-called deadly triad) can make estimates diverge.

## Key terms

- PL: **cel TD**: Nagroda z jednego kroku plus zdyskontowana ocena następnego stanu.
- PL: **błąd TD**: Różnica między celem TD a bieżącą oceną stanu.
- PL: **bootstrapping**: Aktualizowanie oceny na podstawie innej, również szacowanej oceny.
- EN: **TD target**: The one-step reward plus the discounted estimate of the next state.
- EN: **TD error**: The gap between the TD target and the current state estimate.
- EN: **bootstrapping**: Updating an estimate from another estimate that is itself learned.

## Know first

- [Funkcje wartości i równanie Bellmana (Value functions and the Bellman equation)](https://aiatlasgraph.com/t/bellman.md)

## Examples

- PL: Monte Carlo · TD(0) · SARSA · TD(λ) · zwroty n-krokowe
- EN: Monte Carlo · TD(0) · SARSA · TD(λ) · n-step returns

## Related topics

Untyped, symmetric "see also" links.

- [Q-learning i głębokie sieci Q (DQN) (Q-learning and deep Q-networks (DQN))](https://aiatlasgraph.com/t/qlearning.md)

## Sources

- [Reinforcement Learning: An Introduction (2nd edition)](<http://incompleteideas.net/book/the-book-2nd.html>) `sutton-barto-rl-2018` · by Richard S. Sutton, Andrew G. Barto
- [Stanford CS234 · Lecture 3: Model-Free Policy Evaluation (Winter 2026)](<https://web.stanford.edu/class/cs234/slides/lecture3pre.pdf>) `cs234-2026-lecture3` · by Emma Brunskill
- [Learning to Predict by the Methods of Temporal Differences](<https://mlanthology.org/mlj/1988/sutton1988mlj-learning/>) `sutton-td-1988` · by Richard S. Sutton
- [Deep Reinforcement Learning and the Deadly Triad](<https://arxiv.org/abs/1812.02648>) `deadly-triad-2018` · by Hengshuai Yao

---

AI Atlas revision 122 (2026-10-30) · HTML: https://aiatlasgraph.com/t/tdlearning · index: https://aiatlasgraph.com/llms.txt · everything: https://aiatlasgraph.com/llms-full.txt · updated 2026-10-30
