_rock module

Rock definition for pyrockfall

This module defines the Rock class, representing a rock type or group to be thrown in rockfall simulations. Each Rock encapsulates material properties as probability distributions (or deterministic constants) to support uncertainty quantification during sampling.

Main Features

  • Material properties as distributions: - mass and density can be deterministic or random (SciPy frozen RVs

    or custom distributions).

  • Consistent sampling API: - Rock.ppf() for inverse-CDF sampling from quantiles. - Rock.rvs() for random variate draws.

Notes

Use stats.asDistribution() to convert numeric inputs into deterministic distributions and to accept frozen SciPy distributions seamlessly.

class pyrockfall._rock.Rock(name: str = '', mass: Distribution | SupportsToDistribution | Real | np.floating | np.integer | float | int = 0.0, density: Distribution | SupportsToDistribution | Real | np.floating | np.integer | float | int = 0.0, color: Tuple[int, int, int] | None = None)[source]

Bases: object

Represents a rock type or group in a rockfall simulation.

Each instance stores the probabilistic description of material properties, currently mass and density. Properties may be deterministic (e.g., Deterministic) or random (e.g., SciPy rv_frozen or custom TruncatedRandomVariable).

Parameters:

name (str, optional) – Name of the rock group. If not provided, names are auto-generated as "Group <i>".

name

Name of the rock group.

Type:

str

mass

stats.Distribution object for mass.

density

stats.Distribution object for density.

property name: str

Name of the rock group.

Type:

str

property mass: Distribution

stats.Distribution for mass (deterministic or random).

property density: Distribution

stats.Distribution for density (deterministic or random).

property color: Tuple[int, int, int] | None

Optional RGB color for visualization/export.

property numRandomVariables: int

mass and density).

Type:

int

Type:

Number of random variables (currently 2

ppf(q: ndarray) → List[ndarray][source]

Evaluate the percent-point function (inverse CDF).

Parameters:

q (np.ndarray) – Quantiles for each random variable, shape (2, N). - q[0, :]: quantiles for mass - q[1, :]: quantiles for density

Returns:

[mass_samples, density_samples], each of shape (N,).

Return type:

list[np.ndarray]

rvs(num_samples: int) → List[ndarray][source]

Draw random samples for mass and density.

Parameters:

num_samples (int) – Number of samples N.

Returns:

[mass_samples, density_samples], each of shape (N,).

Return type:

list[np.ndarray]