0
$\begingroup$

If customer 1 will buy a product with a probability of 0.6 and every following customer 0.7, how can I simulate a system with n customers?

The result should show which customers bought and which didn't.

Maybe use a uniform distribution between 0 and 1 and see if the value is below the probability?

$\endgroup$

2 Answers 2

1
$\begingroup$

Let $i=1,...,n$ and $X_i =1$ is customer $i$ buys and $X_i=0$ if not. Let $X_i \sim Bernoulli(p_i)$ with $p_1=0.7$ and $p_i=0.6$ for $i>1$.

You can simulate it by constructing the vector $p = (p_1,...,p_n)$ then draw $U=(U_1,...,U_n)$ uniform [0,1] variables and for each $i$ let

$$X_i = I[U_i<p_i]$$

which will have the property of being 1 with probability $p_i$ following from $Pr(U_i \leq r) = \int_0^r dt = r$.

You can do this in R for example

N <- 100
p <- c(0.7,rep(0.6,N-1))
x <- as.numeric(runif(N)<p)
$\endgroup$
1
$\begingroup$

Generate $n$ independent uniformly distributed random variables between 0 and 1. If each variable is below the corresponding threshold, record this as a purchase. If it is above the threshold, no purchase.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.