# tinker_cookbook.rl.compute_advantages

### [**tinker_cookbook.rl.compute_advantages**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/rl/data_processing.py#L23)( _trajectory_groups_P_)

Compute advantages for each trajectory, centered within groups.

**Parameters:**

- [**trajectory_groups_P**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/rl/data_processing.py#L23) ( _list[ [TrajectoryGroup](https://tinker-docs.thinkingmachines.ai/cookbook/api-reference/rl/trajectorygroup/]_) – Groups of trajectories, where each group's rewards are centered independently.

**Returns:** _list[torch.Tensor]_ – Per-group advantage tensors of shape `(G,)`, where `G` is the number of trajectories in each group.

## Referenced by

- [tinker_cookbook.rl.assemble_training_data](https://tinker-docs.thinkingmachines.ai/cookbook/api-reference/rl/assemble_training_data/)
