Coverage for src/serums/enums.py: 88%

32 statements  

« prev     ^ index     » next       coverage.py v7.6.4, created at 2024-11-11 16:43 +0000

1"""Enumerations used by SERUMS.""" 

2import enum 

3 

4 

5@enum.unique 

6class GSMTypes(enum.Enum): 

7 """Gaussian Scale Mixture Types.""" 

8 

9 STUDENTS_T = enum.auto() 

10 """Student's t-distribution.""" 

11 

12 CAUCHY = enum.auto() 

13 """Cauchy distribution.""" 

14 

15 SYMMETRIC_A_STABLE = enum.auto() 

16 r"""Symmetric :math:`\alpha`-stable distribution.""" 

17 

18 def __str__(self): 

19 """Return the enum name for strings.""" 

20 return self.name 

21 

22 

23@enum.unique 

24class SingleObjectDistance(enum.Enum): 

25 """Enumeration for distance methods.""" 

26 

27 MANHATTAN = enum.auto() 

28 r"""The Manhattan/taxicab/:math:`L_1` distance. 

29 

30 Notes 

31 ----- 

32 Uses the form 

33 

34 .. math:: 

35 d(x, y) = \Sigma_i \vert x_i - y_i \vert 

36 """ 

37 

38 EUCLIDEAN = enum.auto() 

39 r"""The euclidean distance between two points. 

40 

41 Notes 

42 ----- 

43 Uses the form :math:`d(x, y) = \sqrt{(x-y)^T(x-y)}`. 

44 """ 

45 

46 HELLINGER = enum.auto() 

47 r"""The hellinger distance between two probability distributions. 

48 

49 Notes 

50 ----- 

51 It is at most 1, and for Gaussian distributions it takes the form 

52 

53 .. math:: 

54 d_H(f,g) &= 1 - \sqrt{\frac{\sqrt{\det{\left[\Sigma_x \Sigma_y\right]}}} 

55 {\det{\left[0.5\Sigma\right]}}} \exp{\epsilon} \\ 

56 \epsilon &= \frac{1}{4}(x - y)^T\Sigma^{-1}(x - y) \\ 

57 \Sigma &= \Sigma_x + \Sigma_y 

58 """ 

59 

60 MAHALANOBIS = enum.auto() 

61 r"""The Mahalanobis distance between a point and a distribution. 

62 

63 Notes 

64 ----- 

65 Uses the form :math:`d(x, y) = \sqrt{(x-y)^T\Sigma_y^{-1}(x-y)}`. 

66 """ 

67 

68 def __str__(self): 

69 """Return the enum name for strings.""" 

70 return self.name 

71 

72 

73@enum.unique 

74class MultiObjectDistance(enum.Enum): 

75 """Enumeration of multi-object distance types.""" 

76 

77 OSPA = enum.auto() 

78 """The Optimal Sub-Pattern Assignment distance between two point processes.""" 

79 

80 OSPA2 = enum.auto() 

81 """The Optimal Sub-Pattern Assignment(2)` distance.""" 

82 

83 def __str__(self): 

84 """Return the enum name for strings.""" 

85 return self.name 

86 

87 

88# @enum.unique 

89# class GoodnessOfFitTest(enum.Enum): 

90# """Enumeration of Goodness of Fit Tests for distribution parameter estimation.""" 

91 

92# CRAMER_VON_MISES = enum.auto() 

93# """Cramer von Mises criterion for goodness of fit of a distribution to a set of samples.""" 

94 

95# KOLMOGOROV_SMIRNOV = enum.auto() 

96# """Kolmogorov Smirnov test for goodness of fit of a distribution to a set of samples.""" 

97 

98# ANDERSON_DARLING = enum.auto() 

99# """Anderson-Darling test for goodness of fit of two sets of samples. 

100# This test puts higher emphasis on the tails of the distribution.""" 

101 

102# def __str__(self): 

103# """Return the enum name for strings.""" 

104# return self.name 

105 

106 

107@enum.unique 

108class DistEstimatorMethod(enum.Enum): 

109 """Enumeration of distribution estimator methods.""" 

110 

111 CRAMER_VON_MISES = enum.auto() 

112 """Cramer von Mises criterion for goodness of fit of a distribution to a set of samples.""" 

113 

114 KOLMOGOROV_SMIRNOV = enum.auto() 

115 """Kolmogorov Smirnov test for goodness of fit of a distribution to a set of samples.""" 

116 

117 ANDERSON_DARLING = enum.auto() 

118 """Anderson-Darling test for goodness of fit of two sets of samples. This test puts higher emphasis on the tails of the distribution.""" 

119 

120 GRIMSHAW_MLE = enum.auto() 

121 """Grimshaw's MLE method for GPD parameter estimation.""" 

122 

123 METHOD_OF_MOMENTS = enum.auto() 

124 """Estimate distribution parameters using the Method of Moments.""" 

125 

126 PROBABILITY_WEIGHTED_MOMENTS = enum.auto() 

127 """Estimate distribution parameters using the method of Probability-Weighted Moments.""" 

128 

129 def __str__(self): 

130 """Return the enum name for strings.""" 

131 return self.name