Questions tagged [bernoulli-probability]

Anything related to Bernoulli in the field of probability, such as Bernoulli random variables, Bernoulli probability distribution, Bernoulli random processes, etc.

Anything related to Bernoulli in the field of probability, such as Bernoulli random variables, Bernoulli probability distribution, Bernoulli random processes, etc.

The Bernoulli distribution is a discrete distribution parametrized by a "success" probability $p$. For a Bernoulli distributed random variable $x$, the probability mass function (pmf) takes a value of $p$ at $x=1$, and $(1-p)$ for $x=0$. A concise representation of the pmf is:

enter image description here

The Bernoulli distribution is a special case of the binomial distribution with a single trial ($n=1$).

See, for example, Wikipedia on:

Tag usage

Questions on should be about implementation and programming problems, not about the statistical or theoretical properties of the technique. Consider whether your question might be better suited to Cross Validated, the StackExchange site for statistics and machine learning.

73 questions
3
votes
3 answers

Binomial distributions (Bernoulli trials) with different probabilities

I want to speed up the code below - namely the for loop. Is there a way to do it in numpy? import numpy as np # define seend and random state rng = np.random.default_rng(0) # num of throws N = 10**1 # max number of trials total_n_trials = 10 #…
My Work
  • 2,143
  • 2
  • 19
  • 47
3
votes
0 answers

Why does Tensorflow Bernoulli distribution always return 0?

I am working on classifying texts based on word occurrences. One of the steps is to estimate the probability of a particular text for each possible class. To do this, I am given NSAMPLES of texts from a vocabulary of NFEATURES words, each labelled…
3
votes
1 answer

Generate a Bernoulli variable from vector with probabilities [r]

I'm having some issues with a quite basic issue. I tried to find any threads who is having the same issue but couldn't find any. I'm trying to figure out how to generate a Bernoulli variable (y) which is based on probabilities (z) I have generated…
ecl
  • 369
  • 1
  • 15
3
votes
2 answers

Bernoulli Prior in R STAN

I am fitting a logistic model in STAN (rstan library). My response variable does not have any missing values, however one of my covariates "HB" is binary and has missing entries. Thus the goal is to impute at each iteration the missing entries in…
Neodyme
  • 557
  • 1
  • 9
  • 20
3
votes
1 answer

Making an animation of the Bernoulli distribution using gganimate and getting an unexpected jump at p = 0.5

I'm practicing using gganimate and want to create something similar to this Shiny app but animated. I've had some success, but am getting a really weird error that I honestly cannot explain and was hoping someone could help me out. The rest of this…
Julian
  • 451
  • 5
  • 14
3
votes
1 answer

How to decompose efficiently dpoibin into its summands in R?

The Poisson-Binomial distribution concerns the probability of the number of successes in a sequence of independent Bernoulli trials with different probabilities of success. This is a generalization of the Binomial distribution. With the command…
3
votes
2 answers

How to get the detailed results (probability tree) of executing a bernoulli experiment a large number of times

Supposing the following experiment : Execute the same bernoulli trial (with the probability of success P) N number of times I need the following information : All the possible sequences of success/failure with its probability to happen. Example : A…
Bruno
  • 4,685
  • 7
  • 54
  • 105
2
votes
2 answers

Numpy generating array from repeated function

I'm trying to generate an numpy array with randomly generated elements (it's similar like bernouilli distribution. The thing is I want to achieve it without using numpy.random.binomial function). Only function that fits after searching documentation…
newone
  • 23
  • 6
2
votes
1 answer

coverage probability for confidence interval

From the Bernoulli(p), I want to calculate the coverage probability for various sample sizes (n= 10, 15, 20, 25, 30, 50, 100, 150, 200), and for each sample size at p = 0.01, 0.4, and 0.8. this is my attempt but shows 0 everywhere except for…
2
votes
1 answer

Simulation test for Bernoulli trials for increasing sample size in R

In R software, I am trying to generate a simulation plot for bernoulli trial for different sample sizes as below I have generated the proportions for given sample size and repeated the process 1000 times. But I dont understand, how to plot the…
Bilal Para
  • 65
  • 1
  • 8
2
votes
1 answer

Laplace Smoothing for Bernoulli model for naive bayes classifier

I have to implement a naive bayes classifier for classifying a document to a class. So, in getting the conditional probability for a term belonging to class, along with laplace smoothing, we have: prob(t | c) = Num(Word occurences in the docs of the…
2
votes
2 answers

Generating random value for number of people alive and how to transpose data in R

I have a question on generating a random sample. I am very new to R and have tried to do my own simulation but im not sure whether it is correct. Really hope someone can assist me. For example, currently there are 100 people alive. Basically, each…
NSAA
  • 175
  • 1
  • 3
  • 14
1
vote
2 answers

The distribution of p-values is not uniform when applying t-test to random coin flips from Python's random.randint(0,1)

Theoretically, p-values are uniformly distributed under the null hypothesis. Therefore, I would expect p-values from G-test or Chi-square test to test equal proportions to provide uniformly distributed p-values when I apply it to some random coin…
Niek Tax
  • 841
  • 1
  • 11
  • 30
1
vote
3 answers

bernoulli_distribution vs uniform_int_distribution

In comparing bernoulli_distribution's default constructor (50/50 chance of true/false) and uniform_int_distribution{0, 1} (uniform likely chance of 0 or 1) I find that bernoulli_distributions are at least 2x and upwards of 6x slower than…
1
vote
1 answer

Is there an efficient way to create a binomial experiment of N bernoulli trials in a numpy array?

Suppose I have a coin with that lands on heads with probability P. The experiment to be performed is to continue flipping the coin x number of times. This experiment is to be repeated 1000 times. Question Is there an efficient/vectorized approach to…
phntm
  • 511
  • 2
  • 11
1
2 3 4 5