|
9 | 9 | from pysatl_criterion.statistics.common import KSStatistic |
10 | 10 | from pysatl_criterion.statistics.goodness_of_fit import AbstractGoodnessOfFitStatistic |
11 | 11 | from pysatl_criterion.statistics.graph_goodness_of_fit import ( |
| 12 | + AbstractGraphTestStatistic, |
12 | 13 | GraphAverageDegreeTestStatistic, |
| 14 | + GraphCliqueNumberTestStatistic, |
13 | 15 | GraphConnectedComponentsTestStatistic, |
14 | 16 | GraphEdgesNumberTestStatistic, |
| 17 | + GraphIndependenceNumberTestStatistic, |
15 | 18 | GraphMaxDegreeTestStatistic, |
16 | 19 | ) |
17 | 20 |
|
@@ -810,73 +813,78 @@ def execute_statistic(self, rvs, **kwargs): |
810 | 813 | return hg |
811 | 814 |
|
812 | 815 |
|
813 | | -class GraphEdgesNumberExponentialityGofStatistic( |
814 | | - AbstractExponentialityGofStatistic, GraphEdgesNumberTestStatistic |
| 816 | +class AbstractGraphExponentialityGofStatistic( |
| 817 | + AbstractExponentialityGofStatistic, AbstractGraphTestStatistic |
815 | 818 | ): |
816 | 819 | @staticmethod |
817 | 820 | @override |
818 | 821 | def code(): |
819 | | - super_class = AbstractExponentialityGofStatistic |
820 | | - parent_code = super(super_class, super_class).code() |
821 | | - return f"EdgesNumber_{parent_code}" |
| 822 | + parent_code = AbstractExponentialityGofStatistic.code() |
| 823 | + return f"GRAPH_{parent_code}" |
822 | 824 |
|
823 | 825 | @staticmethod |
824 | 826 | @override |
825 | 827 | def _compute_dist(rvs): |
826 | | - super_class = GraphEdgesNumberTestStatistic |
827 | | - parent_code = super(super_class, super_class)._compute_dist(rvs) |
828 | | - return parent_code / np.mean(rvs) |
| 828 | + base_dist = AbstractGraphTestStatistic._compute_dist(rvs) |
| 829 | + mean = np.mean(rvs) |
| 830 | + return base_dist / mean if mean != 0 else base_dist |
829 | 831 |
|
830 | 832 |
|
831 | | -class GraphMaxDegreeExponentialityGofStatistic( |
832 | | - AbstractExponentialityGofStatistic, GraphMaxDegreeTestStatistic |
| 833 | +class GraphEdgesNumberExponentialityGofStatistic( |
| 834 | + AbstractGraphExponentialityGofStatistic, GraphEdgesNumberTestStatistic |
833 | 835 | ): |
834 | 836 | @staticmethod |
835 | 837 | @override |
836 | 838 | def code(): |
837 | | - super_class = AbstractExponentialityGofStatistic |
838 | | - parent_code = super(super_class, super_class).code() |
839 | | - return f"MaxDegree_{parent_code}" |
| 839 | + parent_code = AbstractGraphExponentialityGofStatistic.code() |
| 840 | + return f"{GraphEdgesNumberExponentialityGofStatistic.get_stat_name()}_{parent_code}" |
840 | 841 |
|
| 842 | + |
| 843 | +class GraphMaxDegreeExponentialityGofStatistic( |
| 844 | + AbstractGraphExponentialityGofStatistic, GraphMaxDegreeTestStatistic |
| 845 | +): |
841 | 846 | @staticmethod |
842 | 847 | @override |
843 | | - def _compute_dist(rvs): |
844 | | - super_class = GraphMaxDegreeTestStatistic |
845 | | - parent_code = super(super_class, super_class)._compute_dist(rvs) |
846 | | - return parent_code / np.mean(rvs) |
| 848 | + def code(): |
| 849 | + parent_code = AbstractGraphExponentialityGofStatistic.code() |
| 850 | + return f"{GraphMaxDegreeExponentialityGofStatistic.get_stat_name()}_{parent_code}" |
847 | 851 |
|
848 | 852 |
|
849 | 853 | class GraphAverageDegreeExponentialityGofStatistic( |
850 | | - AbstractExponentialityGofStatistic, GraphAverageDegreeTestStatistic |
| 854 | + AbstractGraphExponentialityGofStatistic, GraphAverageDegreeTestStatistic |
851 | 855 | ): |
852 | 856 | @staticmethod |
853 | 857 | @override |
854 | 858 | def code(): |
855 | | - super_class = AbstractExponentialityGofStatistic |
856 | | - parent_code = super(super_class, super_class).code() |
857 | | - return f"AverageDegree_{parent_code}" |
| 859 | + parent_code = AbstractGraphExponentialityGofStatistic.code() |
| 860 | + return f"{GraphAverageDegreeExponentialityGofStatistic.get_stat_name()}_{parent_code}" |
| 861 | + |
858 | 862 |
|
| 863 | +class GraphConnectedComponentsExponentialityGofStatistic( |
| 864 | + AbstractGraphExponentialityGofStatistic, GraphConnectedComponentsTestStatistic |
| 865 | +): |
859 | 866 | @staticmethod |
860 | 867 | @override |
861 | | - def _compute_dist(rvs): |
862 | | - super_class = GraphAverageDegreeTestStatistic |
863 | | - parent_dist = super(super_class, super_class)._compute_dist(rvs) |
864 | | - return parent_dist / np.mean(rvs) |
| 868 | + def code(): |
| 869 | + parent_code = AbstractGraphExponentialityGofStatistic.code() |
| 870 | + return f"{GraphConnectedComponentsExponentialityGofStatistic.get_stat_name()}_{parent_code}" |
865 | 871 |
|
866 | 872 |
|
867 | | -class GraphConnectedComponentsExponentialityGofStatistic( |
868 | | - AbstractExponentialityGofStatistic, GraphConnectedComponentsTestStatistic |
| 873 | +class GraphCliqueNumberExponentialityGofStatistic( |
| 874 | + AbstractGraphExponentialityGofStatistic, GraphCliqueNumberTestStatistic |
869 | 875 | ): |
870 | 876 | @staticmethod |
871 | 877 | @override |
872 | 878 | def code(): |
873 | | - super_class = AbstractExponentialityGofStatistic |
874 | | - parent_code = super(super_class, super_class).code() |
875 | | - return f"ConnectedComponents_{parent_code}" |
| 879 | + parent_code = AbstractGraphExponentialityGofStatistic.code() |
| 880 | + return f"{GraphCliqueNumberExponentialityGofStatistic.get_stat_name()}_{parent_code}" |
876 | 881 |
|
| 882 | + |
| 883 | +class GraphIndependenceNumberExponentialityGofStatistic( |
| 884 | + AbstractGraphExponentialityGofStatistic, GraphIndependenceNumberTestStatistic |
| 885 | +): |
877 | 886 | @staticmethod |
878 | 887 | @override |
879 | | - def _compute_dist(rvs): |
880 | | - super_class = GraphConnectedComponentsTestStatistic |
881 | | - parent_dist = super(super_class, super_class)._compute_dist(rvs) |
882 | | - return parent_dist / np.mean(rvs) |
| 888 | + def code(): |
| 889 | + parent_code = AbstractGraphExponentialityGofStatistic.code() |
| 890 | + return f"{GraphIndependenceNumberExponentialityGofStatistic.get_stat_name()}_{parent_code}" |
0 commit comments