# Computing success percentage

#### Chatman100

##### New member
Hello dear friends,
I need your help with this probability problem.
I have random variable x1 which is normally distributed with mean m1 and standard deviation sigma1.
The vector of random variables X0 is of N elements, where each element is normally distributed with zero mean and standard deviation sigma0.
Now we do an experiment. In each experiment we cast x1 and X0. Then we compare x1 to the elements of X0. If x1 is greater than all the elements in X0 the experiment is successful, otherwise it is a failure. This experiment is repeated K times.
I would like to calculate the probability of success.
Below is the code of the MATLAB simulation:

m0 = 0; %Mean of the elements in X0
sigma0 = 1; %Standard deviation of the elements in X0
m1 = 4.3; %Mean of the elements in x1
sigma1 = 1.2; %Standard deviation of the elements in x1

N = 1000; %Number of elements in X0
K = 800; %Number of experiments
X0 = randn(K, N)*sigma0 + m0;
x1 = randn(K, 1)*sigma1 + m1;

success_flag = zeros(K, 1); %Allocation
for k = 1:K
success_flag(k) = sum(x1(k) > X0( k, : )) == N;
end
success_percentage = 100 * sum(success_flag) / K;
disp(['Success percentage sim: ' num2str(success_percentage)]);

#### steep

##### Member
Hello dear friends,
I need your help with this probability problem.
I have random variable x1 which is normally distributed with mean m1 and standard deviation sigma1.
The vector of random variables X0 is of N elements, where each element is normally distributed with zero mean and standard deviation sigma0.
Now we do an experiment. In each experiment we cast x1 and X0. Then we compare x1 to the elements of X0. If x1 is greater than all the elements in X0 the experiment is successful, otherwise it is a failure. This experiment is repeated K times.
I would like to calculate the probability of success.
I didn't see anything about dependencies between $x_1$ and components of the random vector, and whether said components are independent of each other. Note there isn't a nice closed form expression for the CDF of gaussians so you may need to fall back on numerical integration or some kind of approximation in order to "calculate" the probability of success.

the most conceptually straightforward approach is to calculate the orderstatistics for the maximum component of the random vector, call the CDF $\Phi$ and do $\int_{-\infty}^\infty \Phi(t)\cdot f(t) dt$ where $f(t)$ is the density of the random variable $x_1$. Technically the integral here may be messy, and adjustments are needed if $x_1$ is not independent from $\mathbf x$ .
= = = =

Supposing they are independent (or at least $\mathbf x$ and $x_1$ are jointly normally distributed as an N+1 dimensional vector) a sneakier approach would be to calculate $\mathbf y := \mathbf x - x_1 \mathbf 1$ which is a new $n$ dimensional jointly normal random vector with the same means as $\mathbf x$ but shifted down by the mean of $x_1$ in each case (so means of $-4.3$ for each component of $\mathbf y$ if I read your post right). The variances add if $x_1$ is independent from components of $\mathbf y$, otherwise a covariance correction is needed. This is another reason why you need to be careful about dependencies.

The end game then is to calculate the probability the $\mathbf y$ is non-postive (or the complementary item of it being non-negative). You can numerically try to do the integrals here, though if you are doing estimates/ approximations I have some clever adjustments in mind.
= = = =
That's for the probability of success associated with one experiment. After that we can do adjustments for $k$ experiments (presumably they are independent and you get a binomial distribution of successes)

#### Chatman100

##### New member
Thank you for your answer. I will think carefully and will try to understand the things you wrote.
Most appreciated.