distribution#

Distribution Module

This module provides various classes representing 2D pupil distributions.

Kramer Harrison, 2024

Functions

create_distribution(distribution_type)

Create a distribution based on the given distribution type.

Classes

BaseDistribution()

Base class for distributions.

CrossDistribution()

A class representing a cross-shaped distribution.

GaussianQuadrature()

A class for Gaussian quadrature on circular domains, based on [1].

HexagonalDistribution()

A class representing a hexagonal distribution.

LineXDistribution([positive_only])

A class representing a line distribution along the x-axis.

LineYDistribution([positive_only])

A class representing a line distribution along the y-axis.

RandomDistribution([seed])

A class representing a random distribution.

RingDistribution()

RingDistribution class for generating points along a single ring.

SobolDistribution([seed])

A class representing a Sobol distribution.

UniformDistribution()

Represents a uniform distribution of points within a square, which is

class BaseDistribution[source]#

Base class for distributions.

This class provides a base implementation for generating points and

visualizing the distribution.

Variables:
  • x – The x-coordinates of the generated points.

  • y – The y-coordinates of the generated points.

abstractmethod generate_points(num_points: int)[source]#

Generate points based on the distribution.

Parameters:

num_points (int) – The number of points to generate.

view() tuple[Figure, Axes][source]#

Visualize the distribution.

This method plots the distribution points and a unit circle for reference. :returns: A tuple containing the figure and axes of the plot.

class CrossDistribution[source]#

A class representing a cross-shaped distribution.

This distribution generates points in the shape of a cross, with the x-axis and y-axis as the arms of the cross. If num_points is odd, it generates 2 * num_points - 1 points. If num_points is even and positive, it generates 2 * num_points points. num_points represents the number of points along the full extent of each axis before potential origin merging. If num_points is 0, 0 points are generated.

Variables:
  • x – Array of x-coordinates of the generated points.

  • y – Array of y-coordinates of the generated points.

generate_points(num_points: int)[source]#

Generate points in the shape of a cross.

Parameters:

num_points – The number of points to generate in each axis.

view() tuple[Figure, Axes]#

Visualize the distribution.

This method plots the distribution points and a unit circle for reference. :returns: A tuple containing the figure and axes of the plot.

class GaussianQuadrature[source]#

A class for Gaussian quadrature on circular domains, based on [1].

Generates points in a circular pattern, with optimal placement for Gaussian quadrature over the unit disk. The total number of points is num_rings * num_spokes.

Variables:
  • x – Array of x-coordinates of the generated points.

  • y – Array of y-coordinates of the generated points.

  • weights – Array of weights, normalized to 1.0.

generate_points(num_rings: int, num_spokes: int | None = None)[source]#

Generate radially symmetric points.

Parameters:
  • num_rings (int) – Number of rings.

  • num_spokes (int | None) – Number of spokes, by default None. If None, the number of spokes is 4 * (num_rings + 1). In that case, the integration over the unit disk is exact for polynomials of degree num_rings in x and y.

view() tuple[Figure, Axes]#

Visualize the distribution.

This method plots the distribution points and a unit circle for reference. :returns: A tuple containing the figure and axes of the plot.

class HexagonalDistribution[source]#

A class representing a hexagonal distribution.

Generates points in a hexagonal pattern. The total number of points is 1 + 3 * num_rings * (num_rings + 1), including the center point.

Variables:
  • x – Array of x-coordinates of the generated points.

  • y – Array of y-coordinates of the generated points.

generate_points(num_rings: int = 6)[source]#

Generate points in a hexagonal distribution.

Parameters:

num_rings – Number of rings in the hexagonal distribution. Defaults to 6.

view() tuple[Figure, Axes]#

Visualize the distribution.

This method plots the distribution points and a unit circle for reference. :returns: A tuple containing the figure and axes of the plot.

class LineXDistribution(positive_only: bool = False)[source]#

A class representing a line distribution along the x-axis.

Generates num_points along the x-axis.

Variables:
  • positive_only (bool) – Flag indicating whether the distribution should be limited to positive values only.

  • x – The x-coordinates of the generated points.

  • y – The y-coordinates of the generated points.

generate_points(num_points: int)[source]#

Generates points along the x-axis based on the specified parameters.

Parameters:

num_points (int) – The number of points to generate.

view() tuple[Figure, Axes]#

Visualize the distribution.

This method plots the distribution points and a unit circle for reference. :returns: A tuple containing the figure and axes of the plot.

class LineYDistribution(positive_only: bool = False)[source]#

A class representing a line distribution along the y-axis.

Generates num_points along the y-axis.

Variables:
  • positive_only – Flag indicating whether the distribution should be positive-only.

  • x – The x-coordinates of the generated points.

  • y – The y-coordinates of the generated points.

generate_points(num_points: int)[source]#

Generates points along the line distribution.

Parameters:

num_points (int) – The number of points to generate.

view() tuple[Figure, Axes]#

Visualize the distribution.

This method plots the distribution points and a unit circle for reference. :returns: A tuple containing the figure and axes of the plot.

class RandomDistribution(seed=None)[source]#

A class representing a random distribution.

Generates num_points random points within the unit disk.

Variables:
  • rng (be.Generator) – The random number generator from the backend.

  • x – The x-coordinates of the generated points.

  • y – The y-coordinates of the generated points.

generate_points(num_points: int)[source]#

Generates random points.

Parameters:

num_points (int) – The number of points to generate.

view() tuple[Figure, Axes]#

Visualize the distribution.

This method plots the distribution points and a unit circle for reference. :returns: A tuple containing the figure and axes of the plot.

class RingDistribution[source]#

RingDistribution class for generating points along a single ring.

Generates num_points along a single ring at the maximum aperture value (radius 1).

generate_points(num_points: int)[source]#

Generate points along a ring at the maximum aperture value.

Parameters:

num_points (int) – The number of points to generate in each ring.

view() tuple[Figure, Axes]#

Visualize the distribution.

This method plots the distribution points and a unit circle for reference. :returns: A tuple containing the figure and axes of the plot.

class SobolDistribution(seed: int | None = None)[source]#

A class representing a Sobol distribution.

Generates num_points points using a Sobol low-discrepancy sequence within the unit disk.

Variables:
  • seed (int | None) – Seed for the Sobol sequence generator.

  • x – The x-coordinates of the generated points.

  • y – The y-coordinates of the generated points.

generate_points(num_points: int)[source]#

Generates Sobol points.

Parameters:

num_points (int) – The number of points to generate.

view() tuple[Figure, Axes]#

Visualize the distribution.

This method plots the distribution points and a unit circle for reference. :returns: A tuple containing the figure and axes of the plot.

class UniformDistribution[source]#
Represents a uniform distribution of points within a square, which is

masked to the unit disk.

Generates points on a square grid of num_points x num_points and then masks them to the unit disk. The resulting number of points is approximately num_points^2 * pi / 4.

Variables:
  • x – The x-coordinates of the generated points.

  • y – The y-coordinates of the generated points.

generate_points(num_points: int)[source]#

Generates a grid of points within the unit disk.

Parameters:

num_points (int) – The number of points along each axis to generate.

view() tuple[Figure, Axes]#

Visualize the distribution.

This method plots the distribution points and a unit circle for reference. :returns: A tuple containing the figure and axes of the plot.

create_distribution(distribution_type: DistributionType) BaseDistribution[source]#

Create a distribution based on the given distribution type.

Parameters:

distribution_type – The type of distribution to create.

Returns:

An instance of the specified distribution type.

Raises:

ValueError – If an invalid distribution type is provided.