1 from numbers
import Number
13 Creates a Fisher-Snedecor distribution parameterized by :attr:`df1` and :attr:`df2`. 17 >>> m = FisherSnedecor(torch.tensor([1.0]), torch.tensor([2.0])) 18 >>> m.sample() # Fisher-Snedecor-distributed with df1=1 and df2=2 22 df1 (float or Tensor): degrees of freedom parameter 1 23 df2 (float or Tensor): degrees of freedom parameter 2 25 arg_constraints = {
'df1': constraints.positive,
'df2': constraints.positive}
26 support = constraints.positive
29 def __init__(self, df1, df2, validate_args=None):
30 self.df1, self.
df2 = broadcast_all(df1, df2)
34 if isinstance(df1, Number)
and isinstance(df2, Number):
35 batch_shape = torch.Size()
37 batch_shape = self.df1.size()
38 super(FisherSnedecor, self).__init__(batch_shape, validate_args=validate_args)
40 def expand(self, batch_shape, _instance=None):
42 batch_shape = torch.Size(batch_shape)
43 new.df1 = self.df1.expand(batch_shape)
44 new.df2 = self.df2.expand(batch_shape)
45 new._gamma1 = self._gamma1.expand(batch_shape)
46 new._gamma2 = self._gamma2.expand(batch_shape)
47 super(FisherSnedecor, new).__init__(batch_shape, validate_args=
False)
53 df2 = self.df2.clone()
55 return df2 / (df2 - 2)
59 df2 = self.df2.clone()
61 return 2 * df2.pow(2) * (self.df1 + df2 - 2) / (self.df1 * (df2 - 2).pow(2) * (df2 - 4))
63 def rsample(self, sample_shape=torch.Size(())):
67 X1 = self._gamma1.rsample(sample_shape).view(shape)
68 X2 = self._gamma2.rsample(sample_shape).view(shape)
69 tiny = torch.finfo(X2.dtype).tiny
75 def log_prob(self, value):
80 ct3 = self.df1 / self.
df2 81 t1 = (ct1 + ct2).lgamma() - ct1.lgamma() - ct2.lgamma()
82 t2 = ct1 * ct3.log() + (ct1 - 1) * torch.log(value)
83 t3 = (ct1 + ct2) * torch.log1p(ct3 * value)
def _get_checked_instance(self, cls, _instance=None)
def _extended_shape(self, sample_shape=torch.Size())
def _validate_sample(self, value)