API

invert_angles

invert_angles.G_angles_q12(angles, epsilon)[source]

The probability density function on the upper hemisphere of the Bloch sphere.

Parameters:
  • angles – A 3D numpy.array, where angles[0] is a 2D array with costheta values and angles[1] is a 2D array with phi values
  • epsilon – A positive real number parametrizing the strength of the weak measurement.
Returns:

A 2D numpy.array of probability densities on the Bloch sphere at the specified points.

invert_angles.G_q12(q1, q2, epsilon)[source]

The probability density function on the q1 q2 plane.

invert_angles.array_get_q12_vals(angles, epsilon)[source]

Takes points on the upper hemisphere of the bloch sphere and maps them to points on the q1 q2 plane.

Parameters:
  • angles – A 3D numpy.array, where angles[0] is a 2D array with costheta values and angles[1] is a 2D array with phi values
  • epsilon – A positive real number parametrizing the strength of the weak measurement.
Returns:

A 3D numpy.array “inverted”, where inverted[0] is a 2D array holding the q1 values and inverted[1] is a 2D array holding the q2 values.

invert_angles.construct_grid(N)[source]

Create a grid of theta/phi values with N samples every pi/2 radians. The grid covers all phi between 0 and 2pi, but only theta between 0 and pi/2, exclusive, since those endpoints are problematic for the function that calculates probability densities.

invert_angles.guess_q12_vals(angles, epsilon)[source]

Generates an initial guess of qp and qm for the rootfinder.

Parameters:
  • angles – A 3D numpy.array, where angles[0] is a 2D array with costheta values and angles[1] is a 2D array with phi values
  • epsilon – A positive real number parametrizing the strength of the weak measurement.
Returns:

A 3D numpy.array “guess”, where guess[0] is a 2D array holding the q1 values and guess[1] is a 2D array holding the q2 values.

invert_angles.map_q12_to_sphere_y(qs, epsilon)[source]

Takes values for q1 and q2 and maps them to points on the surface of the Bloch sphere given as pairs (cos theta, phi) for spherical coordinates around the y-axis with phi starting on the z-axis.

invert_angles.map_q12_to_sphere_z(qs, epsilon)[source]

Takes values for q1 and q2 and maps them to points on the surface of the Bloch sphere given as pairs (cos theta, phi) for spherical coordinates around the z-axis with phi starting on the x-axis (i.e. the standard arrangement).

invert_angles.parallelogram_area_q12(q1, q2, epsilon)[source]

Calculate the area of dOmega in units of dq1*dq2

invert_angles.q12_jac(qs, epsilon)[source]

The Jacobian of the mapping from q1, q2 to costheta, phi

sampling

sampling.avg_bin_val(q_ranges, epsilon)[source]

Currently not working.

sampling.bin_probability(q_ranges, epsilon)[source]

Calculate the probability of making measurement corresponding to q1 and q2 being in the specified range

sampling.get_samples(n, tree)[source]

Return n points in q1 q2 space sampled from the specified distribution over that space.

sampling.get_state_samples(min_q, max_q, lin_samps, epsilon, dist_samps)[source]

High level function that constructs all the necessary objects for sampling from the appropriate distribution and then does the sampling, with samples returned as normalized vectors in \(\mathbb{C}^2\) (represented in the computational z basis).

Parameters:
  • min_q – The minimum value of q1 and q2 to sample from
  • max_q – The maximum value of q1 and q2 to sample from
  • lin_samps – The number of bin edges in each direction (one more than the number of bins in each direction)
  • epsilon – The strength of the weak measurement
  • dist_samps – The number of times to sample from the distribution
Returns:

numpy.array with shape (2,dist_samps) with the first row containing the \(|0\rangle\) coefficients and the second row containingthe \(|1\rangle\) coefficients

sampling.prob_dens(qs, epsilon)[source]

The probability density function on the q1 q2 plane. (might be improperly normalized)