[docs]classPareto(TransformedDistribution):r""" Samples from a Pareto Type 1 distribution. Example:: >>> # xdoctest: +IGNORE_WANT("non-deterinistic") >>> m = Pareto(torch.tensor([1.0]), torch.tensor([1.0])) >>> m.sample() # sample from a Pareto distribution with scale=1 and alpha=1 tensor([ 1.5623]) Args: scale (float or Tensor): Scale parameter of the distribution alpha (float or Tensor): Shape parameter of the distribution """arg_constraints={"alpha":constraints.positive,"scale":constraints.positive}def__init__(self,scale,alpha,validate_args=None):self.scale,self.alpha=broadcast_all(scale,alpha)base_dist=Exponential(self.alpha,validate_args=validate_args)transforms=[ExpTransform(),AffineTransform(loc=0,scale=self.scale)]super().__init__(base_dist,transforms,validate_args=validate_args)
@propertydefmean(self):# mean is inf for alpha <= 1a=self.alpha.clamp(min=1)returna*self.scale/(a-1)@propertydefmode(self):returnself.scale@propertydefvariance(self):# var is inf for alpha <= 2a=self.alpha.clamp(min=2)returnself.scale.pow(2)*a/((a-1).pow(2)*(a-2))@constraints.dependent_property(is_discrete=False,event_dim=0)defsupport(self):returnconstraints.greater_than_eq(self.scale)
To analyze traffic and optimize your experience, we serve cookies on this site. By clicking or navigating, you agree to allow our usage of cookies. As the current maintainers of this site, Facebook’s Cookies Policy applies. Learn more, including about available controls: Cookies Policy.