otaf.distribution package

Module contents

Distribution analysis and manipulation tools for the OTAF project.

otaf.distribution.compute_sup_inf_distributions(distributions, x_min=-10, x_max=10, n_points=10000)[source]

Compute the supremum and infimum CDFs for a list of distributions.

This function evaluates the Cumulative Distribution Functions (CDFs) at n_points evenly spaced points between x_min and x_max for a given list of distributions. It then computes the pointwise supremum and infimum of the CDFs across the distributions at each of these points.

Parameters:
  • distributions (list) – A list of objects where each object has a computeCDF(x) method to evaluate the CDF at a point x.

  • x_min (float, optional) – The lower bound of the x values over which the CDFs are evaluated. Default is -10.

  • x_max (float, optional) – The upper bound of the x values over which the CDFs are evaluated. Default is 10.

  • n_points (int, optional) – The number of points at which the CDFs are evaluated between x_min and x_max. Default is 10000.

Returns:

sup_data, inf_data – A tuple containing two 2D arrays, each with shape (n_points, 2). The first column corresponds to the x values. For sup_data, the second column contains the pointwise supremum of the CDFs. For inf_data, it contains the pointwise infimum.

Return type:

tuple of ndarray

otaf.distribution.generate_correlated_samples(mu1=0, mu2=0, sigma1=1, sigma2=1, corr=0, N=1)[source]

Generate bivariate correlated samples.

Parameters:
  • mu1 (float, optional) – Mean of the first marginal distribution. Default is 0.

  • mu2 (float, optional) – Mean of the second marginal distribution. Default is 0.

  • sigma1 (float, optional) – Standard deviation of the first marginal distribution. Default is 1.

  • sigma2 (float, optional) – Standard deviation of the second marginal distribution. Default is 1.

  • corr (float, optional) – Correlation coefficient between the two marginals. Default is 0.

  • N (int, optional) – The number of samples to generate. Default is 1.

Returns:

An (N, 2) NumPy array containing the generated bivariate correlated samples.

Return type:

array_like

otaf.distribution.get_composed_normal_defect_distribution(defect_names, mu_list=None, sigma_list=None, mu_dict=None, sigma_dict=None)[source]

Create a composed distribution of defects from names and variances.

Parameters:
  • defect_names (list of str or sympy.Symbol) – A list of defect variable names (symbols).

  • mu_list (list of float, optional) – List of means for each defect. If not provided, defaults to 0.0 for all defects.

  • sigma_list (list of float, optional) – List of standard deviations for each defect. If not provided, defaults to 1.0 for all defects.

  • mu_dict (dict, optional) – Dictionary mapping defect names to their mean values.

  • sigma_dict (dict, optional) – Dictionary mapping defect names to their standard deviation values.

Returns:

A composed distribution object.

Return type:

JointDistribution

Notes

The defect names are expected to have specific prefixes to identify their mechanical degrees of freedom:

  • u_ : translation along the x-axis

  • v_ : translation along the y-axis

  • w_ : translation along the z-axis

  • alpha_ : rotation around the x-axis

  • beta_ : rotation around the y-axis

  • gamma_ : rotation around the z-axis

This prefix pattern must be matched in keys if mu_dict or sigma_dict are provided, e.g., sigma_dict = {'u': 1.0}.

otaf.distribution.get_means_standards_composed_distribution(composed_distribution)[source]

Extract means and standard deviations from a composed distribution.

Assumes all distributions are normal (mean/std).

Parameters:

composed_distribution (JointDistribution) – The composed distribution of normal distributions.

Returns:

means, stds – A tuple containing two lists: the first list holds the means of the distributions, and the second list holds the standard deviations.

Return type:

tuple of list

otaf.distribution.get_prob_below_threshold(data_inf_sup, threshold=0)[source]

Get the probability of the gap being below a specified threshold.

This function finds the element in the array data_inf_sup where the absolute value of the difference between the first column and the threshold is the smallest, and then returns the corresponding value from the second column.

Parameters:
  • data_inf_sup (ndarray) – Array where the first column contains gap values and the second column contains probabilities.

  • threshold (float, optional) – The threshold to check against. Default is 0.

Returns:

The probability corresponding to the gap closest to the threshold.

Return type:

float

otaf.distribution.multiply_composed_distribution_standard_with_constants(composed_distribution, constants)[source]

Multiply sub-distribution standard deviations by corresponding constants.

This function assumes each sub-distribution is a Normal distribution, where each distribution’s parameters are in the form [mean, std, mean, std, …].

Parameters:
  • composed_distribution (JointDistribution) – The original composed distribution.

  • constants (list of float) – A list of constants to multiply each distribution’s standard deviation.

Returns:

A copy of the original composed distribution, with updated standard deviations scaled by constants.

Return type:

JointDistribution

otaf.distribution.multiply_composed_distribution_with_constant(composed_distribution, constant)[source]

Multiply all parameters in a JointDistribution by a constant.

Parameters:
  • composed_distribution (JointDistribution) – The original composed distribution.

  • constant (float) – The constant value by which to multiply all parameters.

Returns:

A copy of the original composed distribution, with its parameters scaled by the given constant.

Return type:

JointDistribution