Triangular distribution
Can the triangular distribution be added to the distribution collections so that reliability analysis can be carried out when a random variable is of triangular distribution? Thank you.
Thanks for suggesting this feature! It's a good idea and we hope to include it in a future release. In the meantime, the distribution can be implemented as a subclass of the existing DistributionContinuous1D class. I hope this helps!
from scipy import stats
from UQpy.distributions.baseclass import DistributionContinuous1D
class Triangular(DistributionContinuous1D):
def __init__(self, c: float, loc: float = 0.0, scale: float = 1.0):
"""
:param c: Shape parameter between :math:`0 \leq c \leq 1`
:param loc: The non-zero part distribution starts at ``loc``. Default: 0.0
:param scale: The width of the non-zero part of the distribution. Default: 1.0
"""
super().__init__(c=c, loc=loc, scale=scale, ordered_parameters=("c", "loc", "scale"))
self._construct_from_scipy(scipy_name=stats.triang)
def __repr__(self):
s = "c={c}"
if self.parameters["loc"] != 0.0:
s += ", loc={loc}"
if self.parameters["scale"] != 1.0:
s += ", scale={scale}"
s = s.format(**self.parameters)
return f"Triangular({s})"
Hi Connor,
Thank you so much for providing the code. I can now consider the triangular distribution in FORM analysis.
Yours sincerely, Xu Han
From: Connor Krill @.> Sent: Friday, March 28, 2025 11:49 AM To: SURGroup/UQpy @.> Cc: xuhan-incore @.>; Author @.> Subject: Re: [SURGroup/UQpy] Triangular distribution (Issue #262)
Thanks for suggesting this feature! It's a good idea and we hope to include it in a future release. In the meantime, the distribution can be implemented as a subclass of the existing DistributionContinuous1D class. I hope this helps!
from scipy import stats from UQpy.distributions.baseclass import DistributionContinuous1D
class Triangular(DistributionContinuous1D):
def __init__(self, c: float, loc: float = 0.0, scale: float = 1.0):
"""
:param c: Shape parameter between :math:`0 \leq c \leq 1`
:param loc: The non-zero part distribution starts at ``loc``. Default: 0.0
:param scale: The width of the non-zero part of the distribution. Default: 1.0
"""
super().__init__(c=c, loc=loc, scale=scale, ordered_parameters=("c", "loc", "scale"))
self._construct_from_scipy(scipy_name=stats.triang)
def __repr__(self):
s = "c={c}"
if self.parameters["loc"] != 0.0:
s += ", loc={loc}"
if self.parameters["scale"] != 1.0:
s += ", scale={scale}"
s = s.format(**self.parameters)
return f"Triangular({s})"
— Reply to this email directly, view it on GitHubhttps://github.com/SURGroup/UQpy/issues/262#issuecomment-2761742788, or unsubscribehttps://github.com/notifications/unsubscribe-auth/A66BPNSD5VIVAF3V5V2OGND2WVVOZAVCNFSM6AAAAABZSZ65VOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDONRRG42DENZYHA. You are receiving this because you authored the thread.Message ID: @.***>
[connor-krill]connor-krill left a comment (SURGroup/UQpy#262)https://github.com/SURGroup/UQpy/issues/262#issuecomment-2761742788
Thanks for suggesting this feature! It's a good idea and we hope to include it in a future release. In the meantime, the distribution can be implemented as a subclass of the existing DistributionContinuous1D class. I hope this helps!
from scipy import stats from UQpy.distributions.baseclass import DistributionContinuous1D
class Triangular(DistributionContinuous1D):
def __init__(self, c: float, loc: float = 0.0, scale: float = 1.0):
"""
:param c: Shape parameter between :math:`0 \leq c \leq 1`
:param loc: The non-zero part distribution starts at ``loc``. Default: 0.0
:param scale: The width of the non-zero part of the distribution. Default: 1.0
"""
super().__init__(c=c, loc=loc, scale=scale, ordered_parameters=("c", "loc", "scale"))
self._construct_from_scipy(scipy_name=stats.triang)
def __repr__(self):
s = "c={c}"
if self.parameters["loc"] != 0.0:
s += ", loc={loc}"
if self.parameters["scale"] != 1.0:
s += ", scale={scale}"
s = s.format(**self.parameters)
return f"Triangular({s})"
— Reply to this email directly, view it on GitHubhttps://github.com/SURGroup/UQpy/issues/262#issuecomment-2761742788, or unsubscribehttps://github.com/notifications/unsubscribe-auth/A66BPNSD5VIVAF3V5V2OGND2WVVOZAVCNFSM6AAAAABZSZ65VOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDONRRG42DENZYHA. You are receiving this because you authored the thread.Message ID: @.***>