8000 BUG: fix the wind velocity factors usage and better visualization of uniform distributions in Stochastic Classes by kevin-alcaniz · Pull Request #783 · RocketPy-Team/RocketPy · GitHub
[go: up one dir, main page]

Skip to content

BUG: fix the wind velocity factors usage and better visualization of uniform distributions in Stochastic Classes #783

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Mar 23, 2025
Prev Previous commit
Next Next commit
BUG: StochasticModel visualize attributes of a uniform distribution
It showed the nominal and the standard deviation values and it doesn't make sense in a uniform distribution. In a np.random.uniform the 'nominal value' is the lower bound of the distribution, and the 'standard deviation' value is the upper bound. Now, a new condition has been added for the uniform distributions where the mean and semi range are calculated and showed. This way the visualize_attribute function will show the whole range where the random values are uniformly taken in
  • Loading branch information
kevin-alcaniz committed Mar 15, 2025
commit f6efa816442a740279ebaf880458049d28799b3e
19 changes: 14 additions & 5 deletions rocketpy/stochastic/stochastic_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -486,11 +486,20 @@ def format_attribute(attr, value):
)
elif isinstance(value, tuple):
nominal_value, std_dev, dist_func = value
return (
f"\t{attr.ljust(max_str_length)} "
f"{nominal_value:.5f} ± "
f"{std_dev:.5f} ({dist_func.__name__})"
)
if dist_func == np.random.uniform:
mean = (std_dev + nominal_value) / 2
semi_range = (std_dev - nominal_value) / 2
return (
f"\t{attr.ljust(max_str_length)} "
f"{mean:.5f} ± "
f"{semi_range:.5f} ({dist_func.__name__})"
)
else:
return (
f"\t{attr.ljust(max_str_length)} "
f"{nominal_value:.5f} ± "
f"{std_dev:.5f} ({dist_func.__name__})"
)
return None

attributes = {k: v for k, v in self.__dict__.items() if not k.startswith("_")}
Expand Down
0