The probability mass function (PMF) of a Bernoulli distribution can be calculated in MATLAB using the bernpdf function. The function takes two input arguments: the value to evaluate the PMF at (x), and the probability of success (p). The output is the probability of observing the value x, given the probability p.
main.m270 chars11 lines
This code calculates and displays the probabilities of observing X = 0 and X = 1 for a Bernoulli distribution with p = 0.3. The output will be:
main.m66 chars3 lines
gistlibby LogSnag