@@ -1496,6 +1496,7 @@ def test_pow(self):
1496
1496
sample = Y .sample (10 )
1497
1497
assert np .all (sample > 0 )
1498
1498
1499
+ class TestOrderStatistic :
1499
1500
@pytest .mark .fail_slow (20 ) # Moments require integration
1500
1501
def test_order_statistic (self ):
1501
1502
rng = np .random .default_rng (7546349802439582 )
@@ -1539,6 +1540,33 @@ def test_order_statistic(self):
1539
1540
with pytest .raises (ValueError , match = message ):
1540
1541
stats .order_statistic (X , n = 1.5 , r = r )
1541
1542
1543
+ def test_support_gh22037 (self ):
1544
+ # During review of gh-22037, it was noted that the `support` of
1545
+ # an `OrderStatisticDistribution` returned incorrect results;
1546
+ # this was resolved by overriding `_support`.
1547
+ Uniform = stats .make_distribution (stats .uniform )
1548
+ X = Uniform ()
1549
+ Y = X * 5 + 2
1550
+ Z = stats .order_statistic (Y , r = 3 , n = 5 )
1551
+ assert_allclose (Z .support (), Y .support ())
1552
+
1553
+ def test_composition_gh22037 (self ):
1554
+ # During review of gh-22037, it was noted that an error was
1555
+ # raised when creating an `OrderStatisticDistribution` from
1556
+ # a `TruncatedDistribution`. This was resolved by overriding
1557
+ # `_update_parameters`.
1558
+ Normal = stats .make_distribution (stats .norm )
1559
+ TruncatedNormal = stats .make_distribution (stats .truncnorm )
1560
+ a , b = [- 2 , - 1 ], 1
1561
+ r , n = 3 , [[4 ], [5 ]]
1562
+ x = [[[- 0.3 ]], [[0.1 ]]]
1563
+ X1 = Normal ()
1564
+ Y1 = stats .truncate (X1 , a , b )
1565
+ Z1 = stats .order_statistic (Y1 , r = r , n = n )
1566
+ X2 = TruncatedNormal (a = a , b = b )
1567
+ Z2 = stats .order_statistic (X2 , r = r , n = n )
1568
+ np .testing .assert_allclose (Z1 .cdf (x ), Z2 .cdf (x ))
1569
+
1542
1570
1543
1571
class TestFullCoverage :
1544
1572
# Adds tests just to get to 100% test coverage; this way it's more obvious
0 commit comments