@@ -486,25 +486,62 @@ def _more_tags(self):
486
486
}
487
487
488
488
489
- _average_path_length_small = np .array ((
490
- 0.0 , 0.0 , 1.0 ,
491
- 1.6666666666666666667 , 2.1666666666666666667 , 2.5666666666666666667 ,
492
- 2.9000000000000000000 , 3.1857142857142857143 , 3.4357142857142857143 ,
493
- 3.6579365079365079365 , 3.8579365079365079365 , 4.0397546897546897547 ,
494
- 4.2064213564213564214 , 4.3602675102675102675 , 4.5031246531246531247 ,
495
- 4.6364579864579864580 , 4.7614579864579864580 , 4.8791050452815158698 ,
496
- 4.9902161563926269809 , 5.0954793142873638230 , 5.1954793142873638230 ,
497
- 5.2907174095254590611 , 5.3816265004345499702 , 5.4685830221736804049 ,
498
- 5.5519163555070137383 , 5.6319163555070137383 , 5.7088394324300906613 ,
499
- 5.7829135065041647354 , 5.8543420779327361640 , 5.9233075951741154743 ,
500
- 5.9899742618407821410 , 6.0544903908730402055 , 6.1169903908730402055 ,
501
- 6.1775964514791008116 , 6.2364199808908655175 , 6.2935628380337226603 ,
502
- 6.3491183935892782159 , 6.4031724476433322699 , 6.4558040265907006910 ,
503
- 6.5070860778727519730 , 6.5570860778727519730 , 6.6058665656776300218 ,
504
- 6.6534856132966776409 , 6.6999972412036543850 , 6.7454517866581998396 ,
505
- 6.7898962311026442840 , 6.8333744919722095014 , 6.8759276834615712036 ,
506
- 6.9175943501282378702 , 6.9584106766588501151 , 6.9984106766588501151 ,
507
- 7.0376263629333599190 ))
489
+ _average_path_length_small = np .array (
490
+ (
491
+ 0.0 ,
492
+ 0.0 ,
493
+ 1.0 ,
494
+ 1.6666666666666666667 ,
495
+ 2.1666666666666666667 ,
496
+ 2.5666666666666666667 ,
497
+ 2.9000000000000000000 ,
498
+ 3.1857142857142857143 ,
499
+ 3.4357142857142857143 ,
500
+ 3.6579365079365079365 ,
501
+ 3.8579365079365079365 ,
502
+ 4.0397546897546897547 ,
503
+ 4.2064213564213564214 ,
504
+ 4.3602675102675102675 ,
505
+ 4.5031246531246531247 ,
506
+ 4.6364579864579864580 ,
507
+ 4.7614579864579864580 ,
508
+ 4.8791050452815158698 ,
509
+ 4.9902161563926269809 ,
510
+ 5.0954793142873638230 ,
511
+ 5.1954793142873638230 ,
512
+ 5.2907174095254590611 ,
513
+ 5.3816265004345499702 ,
514
+ 5.4685830221736804049 ,
515
+ 5.5519163555070137383 ,
516
+ 5.6319163555070137383 ,
517
+ 5.7088394324300906613 ,
518
+ 5.7829135065041647354 ,
519
+ 5.8543420779327361640 ,
520
+ 5.9233075951741154743 ,
521
+ 5.9899742618407821410 ,
522
+ 6.0544903908730402055 ,
523
+ 6.1169903908730402055 ,
524
+ 6.1775964514791008116 ,
525
+ 6.2364199808908655175 ,
526
+ 6.2935628380337226603 ,
527
+ 6.3491183935892782159 ,
528
+ 6.4031724476433322699 ,
529
+ 6.4558040265907006910 ,
530
+ 6.5070860778727519730 ,
531
+ 6.5570860778727519730 ,
532
+ 6.6058665656776300218 ,
533
+ 6.6534856132966776409 ,
534
+ 6.6999972412036543850 ,
535
+ 6.7454517866581998396 ,
536
+ 6.7898962311026442840 ,
537
+ 6.8333744919722095014 ,
538
+ 6.8759276834615712036 ,
539
+ 6.9175943501282378702 ,
540
+ 6.9584106766588501151 ,
541
+ 6.9984106766588501151 ,
542
+ 7.0376263629333599190 ,
543
+ )
544
+ )
508
545
509
546
510
547
def _average_path_length (n_samples_leaf ):
@@ -533,7 +570,8 @@ def _average_path_length(n_samples_leaf):
533
570
not_mask = ~ mask_small
534
571
535
572
average_path_length [mask_small ] = _average_path_length_small [
536
- n_samples_leaf [mask_small ]]
573
+ n_samples_leaf [mask_small ]
574
+ ]
537
575
538
576
# Average path length equals 2*(H(n)-1), with H(n) the nth harmonic number.
539
577
# For the harmonic number calculation,
@@ -546,11 +584,11 @@ def _average_path_length(n_samples_leaf):
546
584
# Wang, W. Harmonic Number Expansions of the Ramanujan Type.
547
585
# Results Math 73, 161 (2018). https://doi.org/10.1007/s00025-018-0920-8
548
586
549
- tmp = 1.0 / np .square (n_samples_leaf [not_mask ])
587
+ tmp = 1.0 / np .square (n_samples_leaf [not_mask ])
550
588
average_path_length [not_mask ] = (
551
589
2.0 * (np .log (n_samples_leaf [not_mask ]) - 1.0 + np .euler_gamma )
552
- + 1.0 / n_samples_leaf [not_mask ]
553
- - tmp * (1.0 / 6.0 - tmp * (1.0 / 60.0 - tmp / 126.0 ))
590
+ + 1.0 / n_samples_leaf [not_mask ]
591
+ - tmp * (1.0 / 6.0 - tmp * (1.0 / 60.0 - tmp / 126.0 ))
554
592
)
555
593
556
594
return average_path_length .reshape (n_samples_leaf_shape )
0 commit comments