Statistics

Problem Statement for "ExpectedMinimumPowerDiv2"

Problem Statement

You are given two positive ints: n and x.



You are going to choose x distinct integers, each between 1 and n, inclusive. The choice will be made uniformly at random. That is, each of the possible x-element subsets of the integers 1 to n is equally likely to be chosen.



Let S be the smallest integer among the x chosen ones. Compute and return the expected value of 2^S. In other words, determine the average value of 2 to the power of S, where the average is taken over all possible choices of the x distinct integers.

Definition

Class:
ExpectedMinimumPowerDiv2
Method:
findExp
Parameters:
int, int
Returns:
double
Method signature:
double findExp(int n, int x)
(be sure your method is public)

Notes

  • Your answer will be accepted if the absolute or relative error is at most 1e-9.

Constraints

  • n will be between 1 and 50, inclusive.
  • x will be between 1 and n, inclusive.

Examples

  1. 4

    4

    Returns: 2.0

    The only possible situation is that you will choose (1, 2, 3, 4). In this case, the minimum is 1, and the expected value is 2^1 = 2.

  2. 3

    2

    Returns: 2.6666666666666665

    There are three equally likely scenarios: you will select either {1,2} or {1,3} or {2,3}. The corresponding values of S are 1, 1, and 2, respectively. Thus, the average value of 2^S is (2^1 + 2^1 + 2^2) / 3 = 8 / 3 = 2.6666666

  3. 3

    1

    Returns: 4.666666666666667

  4. 10

    4

    Returns: 8.076190476190476

  5. 50

    25

    Returns: 9.906688596554163

  6. 50

    1

    Returns: 4.503599627370492E13

  7. 48

    20

    Returns: 30.38473179316371

  8. 44

    1

    Returns: 7.996448202006818E11

  9. 33

    14

    Returns: 17.874097960794778

  10. 19

    2

    Returns: 6131.789473684211

  11. 47

    5

    Returns: 1.8349815495872915E8

  12. 25

    15

    Returns: 4.356095889572802

  13. 15

    15

    Returns: 2.0

  14. 39

    34

    Returns: 2.320173267541689

  15. 43

    9

    Returns: 31195.47977138576

  16. 40

    17

    Returns: 21.459452348143305

  17. 43

    24

    Returns: 5.960055627427291

  18. 46

    42

    Returns: 2.1993075343934834

  19. 37

    17

    Returns: 12.863263871611304

  20. 48

    14

    Returns: 1165.9509802430277

  21. 42

    7

    Returns: 326042.46566621907

  22. 23

    20

    Returns: 2.3128176171654435

  23. 13

    1

    Returns: 1260.1538461538462

  24. 32

    15

    Returns: 10.654500717241834

  25. 36

    5

    Returns: 364566.94053985237

  26. 36

    2

    Returns: 2.1815706888571432E8

  27. 12

    4

    Returns: 15.34141414141414

  28. 43

    23

    Returns: 6.966713022856075

  29. 26

    9

    Returns: 41.33387335776351

  30. 45

    10

    Returns: 22057.14731310105

  31. 48

    32

    Returns: 3.6581649199398822

  32. 20

    4

    Returns: 432.2910216718266

  33. 45

    21

    Returns: 13.505501744483768

  34. 44

    41

    Returns: 2.1496526729084837

  35. 37

    1

    Returns: 7.429132620054054E9

  36. 41

    33

    Returns: 2.582753100279344

  37. 24

    15

    Returns: 3.9451198619660075

  38. 40

    28

    Returns: 3.264771873702332

  39. 45

    13

    Returns: 962.6883827166131

  40. 47

    1

    Returns: 5.988829291716043E12

  41. 49

    23

    Returns: 13.815579312933682

  42. 32

    23

    Returns: 3.0719298508314075

  43. 12

    12

    Returns: 2.0

  44. 37

    37

    Returns: 2.0

  45. 48

    18

    Returns: 74.72293857908535

  46. 29

    23

    Returns: 2.617220327565155

  47. 31

    26

    Returns: 2.4291305448146394

  48. 50

    27

    Returns: 7.000825657968384

  49. 39

    19

    Returns: 9.976346137897622

  50. 13

    2

    Returns: 209.69230769230768

  51. 25

    11

    Returns: 11.861136985686723

  52. 39

    31

    Returns: 2.6277734574948224

  53. 29

    18

    Returns: 4.111122345131654

  54. 46

    9

    Returns: 127743.26183065468

  55. 35

    32

    Returns: 2.1928189457601217

  56. 23

    8

    Returns: 32.62379617959105

  57. 50

    50

    Returns: 2.0


This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2024, TopCoder, Inc. All rights reserved.
This problem was used for: