gostevehoward / confseq

Confidence sequences and uniform boundaries
MIT License
54 stars 3 forks source link

Argument num_successes in bernoulli_confidence_interval only accepts ints #2

Closed halflearned closed 3 years ago

halflearned commented 3 years ago

The documentation of function bernoulli_confidence_interval implies that argument num_successes could take real values:

* `num_successes`: number of "successful" Bernoulli trials seen so far,
      or more generally, sum of observed outcomes.

However, the code seems to allow only integer-valued arguments. In python

y = np.random.uniform(size=100)
boundaries.bernoulli_confidence_interval(  
    num_successes=np.sum(y),  # Argument is float
    num_trials=100, 
    alpha=0.1, 
    t_opt=100, 
    alpha_opt=0.1)

leads to this error:

TypeError: bernoulli_confidence_interval(): incompatible function arguments. The following argument types are supported:
    1. (num_successes: int, num_trials: int, alpha: float, t_opt: float, alpha_opt: float = 0.05) -> Tuple[float, float]
Invoked with: kwargs: num_successes=51.445863688932626, num_trials=100, alpha=0.1, t_opt=100, alpha_opt=0.1

The message disappears if we replace e.g., np.sum(y) by int(np.sum(y)).