lib/rubystats/binomial_distribution.rb
# Probability density function of a binomial distribution (equivalent
# to R dbinom function).
# _x should be an integer
# returns the probability that a stochastic variable x has the value _x,
# i.e. P(x = _x)
Probability density function of a binomial distribution (equivalent
to R dbinom function).
_x should be an integer
returns the probability that a stochastic variable x has the value _x,
i.e.
Probability density function of a binomial distribution ( equivalent to R dbinom function ) . _x should be an integer returns the probability that a stochastic variable x has the value _x i . e .
def pdf(_x)
      if _x.class == Array
        pdf_vals = []
        for i in (0 ... _x.length)
          check_range(_x[i], 0.0, @n)
          pdf_vals[i] = binomial(@n, _x[i]) * (1-@p)**(@n-_x[i])
        end
        return pdf_vals
      else
        check_range(_x, 0.0, @n)
        return binomial(@n, _x) * @p**_x * (1-@p)**(@n-_x)
      end
    end
def pdf ( _x ) if _x . class == Array pdf_vals = [ ] for i in ( 0 ... _x . length ) check_range ( _x [ i ] , 0.0 , @n ) pdf_vals [ i ] = binomial ( @n , _x [ i ] ) * ( 1 - @p ) ** ( @n - _x [ i ] ) end return pdf_vals else check_range ( _x , 0.0 , @n ) return binomial ( @n , _x ) * @p ** _x * ( 1 - @p ) ** ( @n - _x ) end end
Probability density function of a binomial distribution (equivalent
to R dbinom function).
Probability density function of a binomial distribution ( equivalent to R dbinom function ) .
_x
<not_specific>