SDE/Fokker–Planck input models

oracq.algorithms.qode.sde

Linear ODE input model for Fokker–Planck/SDE and a pure-Python classical witness.

The probability density of the one-dimensional Ito SDE dx = a(x) dt + sqrt(2 D(x)) dW satisfies the Fokker–Planck equation p' = -∂x(a p) + ∂xx(D p). This module performs a zero-flux finite-volume discretization on a uniform grid, yielding a discrete generator G with zero column sums; once G becomes a BlockEncoding via an explicit Pauli expansion, a QODEProblem/LinearODE can be assembled and handed to the existing linear ODE solvers (LCHS etc.). The dissipativity of the generator is an input-model declaration, not proved by the language.

class oracq.algorithms.qode.sde.FokkerPlanckProblem(drift, diffusion, grid)[source]

Bases: object

Zero-flux finite-volume discretization input model of the conservative-form Fokker–Planck operator.

Parameters:
  • drift – Drift coefficient a(x); a constant or a pointwise vector.

  • diffusion – Diffusion coefficient D(x) >= 0; a constant or a pointwise vector.

  • grid – Uniformly increasing grid coordinate sequence.

drift
diffusion
grid
property size

Number of grid points; also the dimension of the discrete generator matrix.

property width

Quantum register bit count for the grid, equal to log2(size).

Raises ValidationError when the number of grid points is not a power of two.

generator_matrix()[source]

Return the discrete generator G (column-vector convention p' = G p, zero column sums).

Returns:

A square matrix of grid dimension, as row-nested tuples.

Return type:

tuple[tuple[float, …], …]

generator_encoding()[source]

BlockEncoding via a small-scale explicit Pauli expansion; no quantum speedup is claimed.

Returns:

The explicit Pauli-expansion block encoding of the discrete generator G.

Return type:

BlockEncoding

qode_problem(initial=None)[source]

Assemble the QODEProblem for p' = G p; dissipative is a caller declaration.

Parameters:

initial – Initial state preparation handle; defaults to the uniform distribution state over the grid width, and its width must match the grid.

Returns:

The quantum ODE problem driven by the generator G, tagged with zero-flux finite-volume evidence.

Return type:

QODEProblem

linear_ode(initial=None)[source]

A u' = -A u LinearODE view of the same problem (A = -G).

Parameters:

initial – Initial state preparation handle; defaults to the uniform distribution state over the grid width.

Returns:

The linear ODE view with A = -G, labeled fokker_planck_minus_A.

Return type:

LinearODE

oracq.algorithms.qode.sde.sde_state_preparation(probabilities, *, implementation='gate', angle_width=8, work_width=0)[source]

Encode a discrete initial distribution as a StatePreparation with amplitudes sqrt(p_i).

Parameters:
  • probabilities – Non-negative discrete probabilities of power-of-two length.

  • implementation – "gate" for the ordinary reused-rotation implementation, "qram" for the QRAM angle-table implementation.

  • angle_width – Angle-table word width of the QRAM implementation.

  • work_width – Extra work bit width of the gate implementation.

Returns:

Preparation handle of the discrete distribution with amplitudes sqrt(p_i).

Return type:

StatePreparation

oracq.algorithms.qode.sde.sde_state_angles(probabilities, *, angle_width=8)[source]

Angle-table binding data of the QRAM implementation; keys are rotation-tree node addresses.

Parameters:
  • probabilities – Non-negative discrete probabilities of power-of-two length; normalized internally.

  • angle_width – Quantization bit width of the angle-table words; a positive integer.

Returns:

Binding data keyed by rotation-tree node address with quantized angle integers as values.

Return type:

dict[int, int]

oracq.algorithms.qode.sde.matrix_exponential(matrix, time=1.0)[source]

Pure-Python matrix exponential by scaling-and-squaring plus Taylor; only for small-scale classical witnesses.

Parameters:
  • matrix – A nonempty square matrix with finite real entries.

  • time – Duration scaling factor; a finite real number.

Returns:

The matrix exp(matrix*time), as row-nested lists.

Return type:

list[list[float]]

oracq.algorithms.qode.sde.evolve_distribution(matrix, initial, time, *, steps=None)[source]

Classical reference evolution; uses the matrix exponential when steps is None, explicit Euler otherwise.

Parameters:
  • matrix – Generator square matrix under the convention p' = matrix * p.

  • initial – Initial vector of the same dimension as the matrix.

  • time – Evolution duration; a non-negative finite real number.

  • steps – Explicit Euler step count; when omitted, the solve is a single matrix-exponential call.

Returns:

The distribution vector evolved to the given time.

Return type:

list[float]

oracq.algorithms.qode.sde.distribution_moments(points, probabilities, orders=(1, 2))[source]

Compute the moments <x^k> from grid coordinates and a probability vector; defaults to (<x>, <x^2>).

Parameters:
  • points – Grid coordinate sequence, of the same length as the probability vector.

  • probabilities – Per-point probability weights; the sum must be positive; normalized internally.

  • orders – Moment orders to compute; a tuple of positive integers.

Returns:

Normalized moments <x^k> corresponding one-to-one with the orders.

Return type:

tuple[float, …]

oracq.algorithms.qode.sde.stationary_distribution(problem)[source]

Exact stationary state of the zero-flux discretization; adjacent-point ratios are (1+u)/(1-u).

Parameters:

problem – A normalized Fokker–Planck discrete problem; the diffusion coefficients at all faces must be positive.

Returns:

Discrete stationary probabilities, one per grid point, summing to one.

Return type:

tuple[float, …]

oracq.algorithms.qode.sde.boltzmann_distribution(problem)[source]

Continuous stationary reference p ∝ exp(∫ a/D dx), differing from the discrete stationary state by O(h^2).

Parameters:

problem – A normalized Fokker–Planck discrete problem; the diffusion coefficients at all faces must be positive.

Returns:

Continuous stationary reference probabilities, one per grid point, summing to one.

Return type:

tuple[float, …]