Trial Placement¶
Trial placement strategies for adaptive psychophysical experiments.
Package Overview¶
trial_placement
¶
trial_placement¶
Non-acquisition-based trial placement strategies.
NOTE: this modeule is currently untested and still in active development.
This module provides classical (non-Bayesian-optimization) placement strategies:
- GridPlacement: Fixed grid designs for systematic exploration
- SobolPlacement: Quasi-random low-discrepancy sequences (space-filling)
For acquisition-based adaptive designs (Bayesian optimization), use: - psyphy.acquisition: Expected Improvement, UCB, Mutual Information - See: psyphy.acquisition.optimize_acqf_discrete() for trial selection
Examples:
Classes:
| Name | Description |
|---|---|
GridPlacement |
Fixed grid placement. |
SobolPlacement |
Sobol quasi-random placement. |
GridPlacement
¶
Fixed grid placement.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
grid_points
|
list of (ref, probe)
|
Predefined set of trial stimuli. |
required |
Notes
- grid = your set of allowable trials; this class simply walks through that set.
- Not yet tested. Pending the same
TrialBatchredesign asSobolPlacement: each trial's stimuli should be a singlenp.ndarrayof shape(K, d)rather than a two-element tuple, to align with the generalisedTrialDatalayout introduced in the data-object refactor.
Methods:
| Name | Description |
|---|---|
propose |
Return the next batch of trials from the grid. |
Attributes:
| Name | Type | Description |
|---|---|---|
grid_points |
|
Source code in src/psyphy/trial_placement/grid.py
propose
¶
propose(posterior, batch_size: int) -> TrialBatch
Return the next batch of trials from the grid.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
posterior
|
Posterior
|
|
required |
batch_size
|
int
|
Number of trials to return. |
required |
Returns:
| Type | Description |
|---|---|
TrialBatch
|
Fixed batch of (ref, probe). |
Source code in src/psyphy/trial_placement/grid.py
SobolPlacement
¶
Sobol quasi-random placement.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dim
|
int
|
Dimensionality of stimulus space. |
required |
bounds
|
list of (low, high)
|
Bounds per dimension. |
required |
seed
|
int
|
RNG seed. |
0
|
Notes
Not yet tested. Pending two design changes tracked in the trial-placement follow-up issue:
-
TrialBatchcurrently stores stimuli aslist[tuple[Any, Any]](two-stimulus tuples). It should be updated tolist[np.ndarray]each of shape(K, d)to align withTrialData.stimuliand allowResponseData.add_batchto consume it without conversion. -
The zero reference vector is hardcoded here. It should be an explicit parameter so the caller controls which point in stimulus space acts as the reference, rather than always using the origin.
Methods:
| Name | Description |
|---|---|
propose |
Propose Sobol points (ignores posterior). |
Attributes:
| Name | Type | Description |
|---|---|---|
bounds |
|
|
engine |
|
Source code in src/psyphy/trial_placement/sobol.py
propose
¶
propose(posterior, batch_size: int) -> TrialBatch
Propose Sobol points (ignores posterior).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
posterior
|
Posterior
|
Ignored in MVP. |
required |
batch_size
|
int
|
Number of trials to return. |
required |
Returns:
| Type | Description |
|---|---|
TrialBatch
|
Candidate trials from Sobol sequence. |
Source code in src/psyphy/trial_placement/sobol.py
Grid¶
grid
¶
grid.py
Grid-based placement strategy.
Full WPPM mode: - Could refine the grid adaptively around regions of high posterior uncertainty.
Classes:
| Name | Description |
|---|---|
GridPlacement |
Fixed grid placement. |
GridPlacement
¶
Fixed grid placement.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
grid_points
|
list of (ref, probe)
|
Predefined set of trial stimuli. |
required |
Notes
- grid = your set of allowable trials; this class simply walks through that set.
- Not yet tested. Pending the same
TrialBatchredesign asSobolPlacement: each trial's stimuli should be a singlenp.ndarrayof shape(K, d)rather than a two-element tuple, to align with the generalisedTrialDatalayout introduced in the data-object refactor.
Methods:
| Name | Description |
|---|---|
propose |
Return the next batch of trials from the grid. |
Attributes:
| Name | Type | Description |
|---|---|---|
grid_points |
|
Source code in src/psyphy/trial_placement/grid.py
propose
¶
propose(posterior, batch_size: int) -> TrialBatch
Return the next batch of trials from the grid.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
posterior
|
Posterior
|
|
required |
batch_size
|
int
|
Number of trials to return. |
required |
Returns:
| Type | Description |
|---|---|
TrialBatch
|
Fixed batch of (ref, probe). |
Source code in src/psyphy/trial_placement/grid.py
Sobol¶
sobol
¶
sobol.py
Sobol quasi-random placement.
MVP: - Uses a Sobol engine to generate low-discrepancy points. - Ignores the posterior (pure exploration).
Levaraging WPPM's posterior: - Could combine Sobol exploration (early) with posterior-aware exploitation (later).
Classes:
| Name | Description |
|---|---|
SobolPlacement |
Sobol quasi-random placement. |
SobolPlacement
¶
Sobol quasi-random placement.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dim
|
int
|
Dimensionality of stimulus space. |
required |
bounds
|
list of (low, high)
|
Bounds per dimension. |
required |
seed
|
int
|
RNG seed. |
0
|
Notes
Not yet tested. Pending two design changes tracked in the trial-placement follow-up issue:
-
TrialBatchcurrently stores stimuli aslist[tuple[Any, Any]](two-stimulus tuples). It should be updated tolist[np.ndarray]each of shape(K, d)to align withTrialData.stimuliand allowResponseData.add_batchto consume it without conversion. -
The zero reference vector is hardcoded here. It should be an explicit parameter so the caller controls which point in stimulus space acts as the reference, rather than always using the origin.
Methods:
| Name | Description |
|---|---|
propose |
Propose Sobol points (ignores posterior). |
Attributes:
| Name | Type | Description |
|---|---|---|
bounds |
|
|
engine |
|
Source code in src/psyphy/trial_placement/sobol.py
propose
¶
propose(posterior, batch_size: int) -> TrialBatch
Propose Sobol points (ignores posterior).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
posterior
|
Posterior
|
Ignored in MVP. |
required |
batch_size
|
int
|
Number of trials to return. |
required |
Returns:
| Type | Description |
|---|---|
TrialBatch
|
Candidate trials from Sobol sequence. |