Observables¶
Pauli Operators¶

class
qucumber.observables.
SigmaZ
[source]¶ Bases:
qucumber.observables.ObservableBase
The observable.
Computes the magnetization in the Z direction of a spin chain.

apply
(nn_state, samples)[source]¶ Computes the magnetization of each sample given a batch of samples.
Parameters:  nn_state (qucumber.nn_states.WaveFunctionBase) – The WaveFunction that drew the samples.
 samples (torch.Tensor) – A batch of samples to calculate the observable on. Must be using the convention.

name
¶ The name of the Observable.

sample
(nn_state, k, num_samples=1, initial_state=None, overwrite=False)[source]¶ Draws samples of the observable using the given WaveFunction.
Parameters:  nn_state (qucumber.nn_states.WaveFunctionBase) – The WaveFunction to draw samples from.
 k (int) – The number of Gibbs Steps to perform before drawing a sample.
 num_samples (int) – The number of samples to draw.
 initial_state (torch.Tensor) – The initial state of the Markov Chain. If given, num_samples will be ignored.
 overwrite (bool) – Whether to overwrite the initial_state tensor, if it is provided, with the updated state of the Markov chain.

statistics
(nn_state, num_samples, num_chains=0, burn_in=1000, steps=1)[source]¶ Estimates the expected value, variance, and the standard error of the observable over the distribution defined by the WaveFunction.
Parameters:  nn_state (qucumber.nn_states.WaveFunctionBase) – The WaveFunction to draw samples from.
 num_samples (int) – The number of samples to draw. The actual number of samples drawn may be slightly higher if num_samples % num_chains != 0.
 num_chains (int) – The number of Markov chains to run in parallel; if 0, will use a number of chains equal to num_samples.
 burn_in (int) – The number of Gibbs Steps to perform before recording any samples.
 steps (int) – The number of Gibbs Steps to take between each sample.
Returns: A dictionary containing the (estimated) expected value (key: “mean”), variance (key: “variance”), and standard error (key: “std_error”) of the observable.
Return type:

statistics_from_samples
(nn_state, samples)[source]¶ Estimates the expected value, variance, and the standard error of the observable using the given samples.
Parameters:  nn_state (qucumber.nn_states.WaveFunctionBase) – The WaveFunction that drew the samples.
 samples (torch.Tensor) – A batch of sample states to calculate the observable on.

symbol
¶ The algebraic symbol representing the Observable.


class
qucumber.observables.
SigmaX
[source]¶ Bases:
qucumber.observables.ObservableBase
The observable
Computes the magnetization in the X direction of a spin chain.

apply
(nn_state, samples)[source]¶ Computes the magnetization along X of each sample in the given batch of samples.
Parameters:  nn_state (qucumber.nn_states.WaveFunctionBase) – The WaveFunction that drew the samples.
 samples (torch.Tensor) – A batch of samples to calculate the observable on. Must be using the convention.

name
¶ The name of the Observable.

sample
(nn_state, k, num_samples=1, initial_state=None, overwrite=False)[source]¶ Draws samples of the observable using the given WaveFunction.
Parameters:  nn_state (qucumber.nn_states.WaveFunctionBase) – The WaveFunction to draw samples from.
 k (int) – The number of Gibbs Steps to perform before drawing a sample.
 num_samples (int) – The number of samples to draw.
 initial_state (torch.Tensor) – The initial state of the Markov Chain. If given, num_samples will be ignored.
 overwrite (bool) – Whether to overwrite the initial_state tensor, if it is provided, with the updated state of the Markov chain.

statistics
(nn_state, num_samples, num_chains=0, burn_in=1000, steps=1)[source]¶ Estimates the expected value, variance, and the standard error of the observable over the distribution defined by the WaveFunction.
Parameters:  nn_state (qucumber.nn_states.WaveFunctionBase) – The WaveFunction to draw samples from.
 num_samples (int) – The number of samples to draw. The actual number of samples drawn may be slightly higher if num_samples % num_chains != 0.
 num_chains (int) – The number of Markov chains to run in parallel; if 0, will use a number of chains equal to num_samples.
 burn_in (int) – The number of Gibbs Steps to perform before recording any samples.
 steps (int) – The number of Gibbs Steps to take between each sample.
Returns: A dictionary containing the (estimated) expected value (key: “mean”), variance (key: “variance”), and standard error (key: “std_error”) of the observable.
Return type:

statistics_from_samples
(nn_state, samples)[source]¶ Estimates the expected value, variance, and the standard error of the observable using the given samples.
Parameters:  nn_state (qucumber.nn_states.WaveFunctionBase) – The WaveFunction that drew the samples.
 samples (torch.Tensor) – A batch of sample states to calculate the observable on.

symbol
¶ The algebraic symbol representing the Observable.


class
qucumber.observables.
SigmaY
[source]¶ Bases:
qucumber.observables.ObservableBase
The observable
Computes the magnetization in the Y direction of a spin chain.

apply
(nn_state, samples)[source]¶ Computes the magnetization along Y of each sample in the given batch of samples.
Parameters:  nn_state (qucumber.nn_states.WaveFunctionBase) – The WaveFunction that drew the samples.
 samples (torch.Tensor) – A batch of samples to calculate the observable on. Must be using the convention.

name
¶ The name of the Observable.

sample
(nn_state, k, num_samples=1, initial_state=None, overwrite=False)[source]¶ Draws samples of the observable using the given WaveFunction.
Parameters:  nn_state (qucumber.nn_states.WaveFunctionBase) – The WaveFunction to draw samples from.
 k (int) – The number of Gibbs Steps to perform before drawing a sample.
 num_samples (int) – The number of samples to draw.
 initial_state (torch.Tensor) – The initial state of the Markov Chain. If given, num_samples will be ignored.
 overwrite (bool) – Whether to overwrite the initial_state tensor, if it is provided, with the updated state of the Markov chain.

statistics
(nn_state, num_samples, num_chains=0, burn_in=1000, steps=1)[source]¶ Estimates the expected value, variance, and the standard error of the observable over the distribution defined by the WaveFunction.
Parameters:  nn_state (qucumber.nn_states.WaveFunctionBase) – The WaveFunction to draw samples from.
 num_samples (int) – The number of samples to draw. The actual number of samples drawn may be slightly higher if num_samples % num_chains != 0.
 num_chains (int) – The number of Markov chains to run in parallel; if 0, will use a number of chains equal to num_samples.
 burn_in (int) – The number of Gibbs Steps to perform before recording any samples.
 steps (int) – The number of Gibbs Steps to take between each sample.
Returns: A dictionary containing the (estimated) expected value (key: “mean”), variance (key: “variance”), and standard error (key: “std_error”) of the observable.
Return type:

statistics_from_samples
(nn_state, samples)[source]¶ Estimates the expected value, variance, and the standard error of the observable using the given samples.
Parameters:  nn_state (qucumber.nn_states.WaveFunctionBase) – The WaveFunction that drew the samples.
 samples (torch.Tensor) – A batch of sample states to calculate the observable on.

symbol
¶ The algebraic symbol representing the Observable.

Neighbour Interactions¶

class
qucumber.observables.
NeighbourInteraction
(periodic_bcs=False, c=1)[source]¶ Bases:
qucumber.observables.ObservableBase
The observable
Computes the cth nearest neighbour interaction for a spin chain with either open or periodic boundary conditions.
Parameters: 
apply
(nn_state, samples)[source]¶ Computes the energy of this neighbour interaction for each sample given a batch of samples.
Parameters:  nn_state (qucumber.nn_states.WaveFunctionBase) – The WaveFunction that drew the samples.
 samples (torch.Tensor) – A batch of samples to calculate the observable on. Must be using the convention.

name
¶ The name of the Observable.

sample
(nn_state, k, num_samples=1, initial_state=None, overwrite=False)[source]¶ Draws samples of the observable using the given WaveFunction.
Parameters:  nn_state (qucumber.nn_states.WaveFunctionBase) – The WaveFunction to draw samples from.
 k (int) – The number of Gibbs Steps to perform before drawing a sample.
 num_samples (int) – The number of samples to draw.
 initial_state (torch.Tensor) – The initial state of the Markov Chain. If given, num_samples will be ignored.
 overwrite (bool) – Whether to overwrite the initial_state tensor, if it is provided, with the updated state of the Markov chain.

statistics
(nn_state, num_samples, num_chains=0, burn_in=1000, steps=1)[source]¶ Estimates the expected value, variance, and the standard error of the observable over the distribution defined by the WaveFunction.
Parameters:  nn_state (qucumber.nn_states.WaveFunctionBase) – The WaveFunction to draw samples from.
 num_samples (int) – The number of samples to draw. The actual number of samples drawn may be slightly higher if num_samples % num_chains != 0.
 num_chains (int) – The number of Markov chains to run in parallel; if 0, will use a number of chains equal to num_samples.
 burn_in (int) – The number of Gibbs Steps to perform before recording any samples.
 steps (int) – The number of Gibbs Steps to take between each sample.
Returns: A dictionary containing the (estimated) expected value (key: “mean”), variance (key: “variance”), and standard error (key: “std_error”) of the observable.
Return type:

statistics_from_samples
(nn_state, samples)[source]¶ Estimates the expected value, variance, and the standard error of the observable using the given samples.
Parameters:  nn_state (qucumber.nn_states.WaveFunctionBase) – The WaveFunction that drew the samples.
 samples (torch.Tensor) – A batch of sample states to calculate the observable on.

symbol
¶ The algebraic symbol representing the Observable.

Abstract Observable¶
Note
This is an Abstract Base Class, it is not meant to be used directly. The following API reference is mostly for developers.

class
qucumber.observables.
ObservableBase
[source]¶ Bases:
abc.ABC
Base class for observables.

apply
(nn_state, samples)[source]¶ Computes the value of the observable, rowwise, on a batch of samples. Must be implemented by any subclasses.
Parameters:  nn_state (qucumber.nn_states.WaveFunctionBase) – The WaveFunction that drew the samples.
 samples (torch.Tensor) – A batch of sample states to calculate the observable on.

name
¶ The name of the Observable.

sample
(nn_state, k, num_samples=1, initial_state=None, overwrite=False)[source]¶ Draws samples of the observable using the given WaveFunction.
Parameters:  nn_state (qucumber.nn_states.WaveFunctionBase) – The WaveFunction to draw samples from.
 k (int) – The number of Gibbs Steps to perform before drawing a sample.
 num_samples (int) – The number of samples to draw.
 initial_state (torch.Tensor) – The initial state of the Markov Chain. If given, num_samples will be ignored.
 overwrite (bool) – Whether to overwrite the initial_state tensor, if it is provided, with the updated state of the Markov chain.

statistics
(nn_state, num_samples, num_chains=0, burn_in=1000, steps=1)[source]¶ Estimates the expected value, variance, and the standard error of the observable over the distribution defined by the WaveFunction.
Parameters:  nn_state (qucumber.nn_states.WaveFunctionBase) – The WaveFunction to draw samples from.
 num_samples (int) – The number of samples to draw. The actual number of samples drawn may be slightly higher if num_samples % num_chains != 0.
 num_chains (int) – The number of Markov chains to run in parallel; if 0, will use a number of chains equal to num_samples.
 burn_in (int) – The number of Gibbs Steps to perform before recording any samples.
 steps (int) – The number of Gibbs Steps to take between each sample.
Returns: A dictionary containing the (estimated) expected value (key: “mean”), variance (key: “variance”), and standard error (key: “std_error”) of the observable.
Return type:

statistics_from_samples
(nn_state, samples)[source]¶ Estimates the expected value, variance, and the standard error of the observable using the given samples.
Parameters:  nn_state (qucumber.nn_states.WaveFunctionBase) – The WaveFunction that drew the samples.
 samples (torch.Tensor) – A batch of sample states to calculate the observable on.

symbol
¶ The algebraic symbol representing the Observable.
