Point#

ball_uniform(num_points: int, num_dimensions: int, center_point: Iterable[float] = None, widths: float | Iterable[float] = 1, only_envelope: bool = False, seed: int = None) ndarray[source]#

Samples points uniformly at random in a ball. This function can also handle spheres and spheres of different width per dimensions, leading to distributions that are not really balls. For instance, you can obtain an ellipse by providing two different widths in the 2D case.

Parameters:
  • num_points (int) – The number of points to sample.

  • num_dimensions (int) – The number of dimensions for the ball.

  • center_point (Iterable[float]) – The coordinates of the center point of the ball. It needs to have one coordinate per dimension.

  • widths (float | Iterable[float], default: 1) – The width of the ball. If a single value is given, the width is applied to all dimensions. In case multiple values are given, they are applied to each dimension independently.

  • only_envelope (bool, default: False) – If set to True only points on the envelope of the ball (the corresponding sphere) are sampled, and not in the inside.

  • seed (int, default: None) – Seed for numpy random number generator.

Returns:

The coordinates of the num_points points that have been sampled.

Return type:

np.ndarray

Validation

Observed frequencies for a uniform ball model
sphere_uniform(num_points: int, num_dimensions: int, center_point: Iterable[float] = None, widths: float | Iterable[float] = 1, seed: int = None) ndarray[source]#

Samples points uniformly at random in a sphere, that is, in the envelope of a ball.

This is simply a shortcut of the ball_uniform() with only_envelope = True.

Parameters:
  • num_points (int) – The number of points to sample.

  • num_dimensions (int) – The number of dimensions for the ball.

  • center_point (Iterable[float]) – The coordinates of the center point of the ball. It needs to have one coordinate per dimension.

  • widths (float | Iterable[float], default: 1) – The width of the ball. If a single value is given, the width is applied to all dimensions. In case multiple values are given, they are applied to each dimension independently.

  • seed (int, default: None) – Seed for numpy random number generator.

Returns:

The coordinates of the num_points points that have been sampled.

Return type:

np.ndarray

Validation

Observed frequencies for a uniform sphere model
ball_resampling(num_points: int, num_dimensions: int, inner_sampler: Callable, inner_sampler_args: dict, center_point: Iterable[float] = None, width: float = 1, max_numer_resampling: int = 1000, seed: int = None) ndarray[source]#

Uses another point sampler and reject all points that do not fall inside the ball described as parameter.

Be careful, if not set properly, this can run until the end of time (if always resampling for instance).

Parameters:
  • num_points (int) – The number of points to sample.

  • num_dimensions (int) – The number of dimensions for the ball.

  • inner_sampler (Callable) – The function used to sample points before resampling. This function should accept an optional seed parameter. Other parameters should be passed by name via the inner_sampler_args argument.

  • inner_sampler_args (dict) – The arguments passed to the inner_sampler.

  • center_point (Iterable[float]) – The coordinates of the center point of the ball. It needs to have one coordinate per dimension.

  • width (float, default: 1) – The width of the ball. Can only be a single value (as opposed to ball_uniform()).

  • max_numer_resampling (int, default: 1000) – The maximum number of resampling. If exceeded, the center point is used.

  • seed (int, default: None) – Seed for numpy random number generator. We increase the seed by one each time we resample (to avoid always resampling the same point).

Returns:

The coordinates of the num_points points that have been sampled.

Return type:

np.ndarray

Validation

Observed frequencies for a uniform ball model
cube(num_points: int, num_dimensions: int, center_point: Iterable[float] = None, widths: float | Iterable[float] = 1, seed: int = None) ndarray[source]#

Samples points uniformly at random in a cube.

Parameters:
  • num_points (int) – The number of points to sample.

  • num_dimensions (int) – The number of dimensions for the cube.

  • center_point (Iterable[float]) – The coordinates of the center point of the cube. It needs to have one coordinate per dimension.

  • widths (float | Iterable[float], default: 1) – The width of the space distribution. If a single value is given, the width is applied to all dimensions. In case multiple values are given, they are applied to each dimension independently.

  • seed (int, default: None) – Seed for numpy random number generator.

Returns:

The coordinates of the num_points points that have been sampled.

Return type:

np.ndarray

Validation

Observed frequencies for a uniform cube model
gaussian(num_points: int, num_dimensions: int, center_point: Iterable[float] = None, sigmas: float | Iterable[float] = 1, widths: Iterable[float] = None, seed: int = None) ndarray[source]#

Samples points uniformly at random in a gaussian space.

Parameters:
  • num_points (int) – The number of points to sample.

  • num_dimensions (int) – The number of dimensions for the Gaussian space.

  • center_point (Iterable[float]) – The coordinates of the center point of the gaussian distribution. It needs to have one coordinate per dimension.

  • sigmas (float | Iterable[float], default: 1) – The standard deviation of the gaussian distribution. If a single value is given, the width is applied to all dimensions. In case multiple values are given, they are applied to each dimension independently.

  • widths (Iterable[float], default: None) – Maximal widths for the Gaussian distributions. One width per dimension needs to be provided. When sampling points, if the distance between the point and the center point is larger than half the width of a dimension, the point is resampled.

  • seed (int, default: None) – Seed for numpy random number generator.

Returns:

The coordinates of the num_points points that have been sampled.

Return type:

np.ndarray

Validation

Observed frequencies for a Gaussian model