# Solve ${\rm BinomialDistribution}(x;\,n_1,\,p_1) = {\rm BinomialDistribution}(a-x;\,n_2,\,p_2)$ in terms of $x$ [closed]

I'm totally a novice with Wolfram software, so please forgive me if the question is nonsense.

I want to solve the following equation in terms of $x$:

$\quad \quad {\rm BinomialDistribution}(x;\,n_1,\,p_1) = {\rm BinomialDistribution}(a-x;\,n_2,\,p_2)$

Of course,

$\quad \quad {\rm BinomialDistribution}(x;\,n,\,p) = \binom{n}{p}p^{x}(1-p)^{n-x}$

I tried the following statement on Wolfram|Alpha, but nothing shown:

Solve[
Binomial[b, x] a^x (1-a)^(b-x) - Binomial[e, d-x] c^(d-x) (1-c)^(e-(d-x)) == 0,
x]


although the following one seems to show a solution:

Solve[a^x (1-a)^(b-x) == c^(d-x) (1-c)^(e-(d-x)), x].


## Update

I replaced binomial coefficient with the Gamma function and tried the following:

(Gamma[1+b]/(Gamma[1+x] Gamma[1-x+b])) a^x (1-a)^(b-x) -
(Gamma[1+e]/(Gamma[1+d-x] Gamma[1-(d-x)+e])) c^(d-x) (1-c)^(e-(d-x))


The above shows a reasonable result, but below show still nothing.

Solve[
(Gamma[1+b]/(Gamma[1+x] Gamma[1-x+b])) a^x (1-a)^(b-x) -
(Gamma[1+e]/(Gamma[1+d-x] Gamma[1-(d-x)+e])) c^(d-x) (1-c)^(e-(d-x)) == 0,
x]

-

## closed as off-topic by bbgodfrey, MarcoB, belisarius, blochwave, ubpdqnJun 2 at 8:21

This question appears to be off-topic. The users who voted to close gave this specific reason:

• "This question cannot be answered without additional information. Questions on problems in code must describe the specific problem and include valid code to reproduce it. Any data used for programming examples should be embedded in the question or code to generate the (fake) data must be included." – bbgodfrey, MarcoB, belisarius, blochwave, ubpdqn
If this question can be reworded to fit the rules in the help center, please edit the question.

The syntax is incorrect. Read the documentation for Solve. –  bbgodfrey Jun 1 at 1:17
@bbgodfrey Thank you, I checked this (reference.wolfram.com/language/ref/Solve.html) and update the statement to solve[ binomial(b,x) a^x (1-a)^(b-x) - binomial(e,d-x) c^(d-x) (1-c)^(e-(d-x)) == 0 , x]. However, nothing changed. –  rkjt50r983 Jun 1 at 1:25
The first letter of Solve, and all Mathematica functions (such as Binomial), is capitalized. The argument list of Binomial should be enclosed in [ ]. You really need to read the documentation for all functions you use. Also, as you improve your syntax, please edit your question to show your most current version. –  bbgodfrey Jun 1 at 1:36
@bbgodfrey, thanks, and I updated my question. But the point you mentioned does not change the result. –  rkjt50r983 Jun 1 at 1:51
I presume that you really mean, Solve[(Gamma[1 + b]/(Gamma[1 + x] Gamma[1 - x + b])) a^x (1 - a)^(b - x) - (Gamma[1 + e]/(Gamma[1 + d - x] Gamma[1 - (d - x) + e])) c^(d - x) (1 - c)^(e - (d - x)) == 0, x] instead of what you have in the question. If so, you probably received the message, Solve::nsmet: This system cannot be solved with the methods available to Solve. >>, which means just what it says. Not all equations can be solved symbolically. You may wish to give numerical values to your constants and use NSolve to obtain a numerical answer. –  bbgodfrey Jun 1 at 1:58

As a rule, before going into Detail, it is a good idea to get first an overview over the situation, preferrably graphical. You could proceed like this.

The problem can be formulated as follows: find the zeroes in x of the function

$$f = p^x \binom{n}{x} (1-p)^{n-x}-q^x \binom{m}{a-x} (1-q)^{m-(a-x)}$$

In Mathematica define f as

f[n_, p_, m_, q_, a_, x_] :=
Binomial[n, x] p^x (1 - p)^(n - x) -
Binomial[m, a - x] q^(a - x ) (1 - q)^(m - (a - x))


Since there are 5 parameters in the problem we use apropriate random values.

The parameter a is assumed to be real and uniformly distributed between -1 and +1

ra := RandomReal[{-1, 1}]


For p and q we take real numbers uniformly distributed between 0 and +1

rp := RandomReal[{0, 1}]


and n and m are integers, assumed here between 0 and, say, 5

ri := RandomInteger[{0, 5}]


Now let's call the function with an set of randomly chosen parameters and make a plot.

A random set of parameters (with x appended to simplify what folllows) is

pars = {ri, rp, ri, rp, ra, x}

(*
Out[78]= {2, 0.332205, 0, 0.157944, -0.15634, x}
*)


The function f with these parameters is given by

fr = f @@ pars

(*
Out[79]= -0.157944^(-0.15634 - x) 0.842056^(0.15634 + x) Binomial[0, -0.15634 - x] +
0.332205^x 0.667795^(2 - x) Binomial[2, x]
*)


Plotting it gives

Plot[fr, {x, -5, 5}]
(* 150601_plot_fBinom1.jpg *)


You should repeat the next lines in order to see which type of zeroes might arise

pars = {ri, rp, ri, rp, ra, x}
Plot[fr = f @@ pars, {x, -5, 5}]
(* 150601_plot _fBinom2.jpg *)

(*
{5, 0.554662, 1, 0.773222, 0.437614, x}
*)


In many cases there are infinitely many zeroes, in others only a few. For a given set of parameters you can then use FindRoot[] in the vicinity of a root you see in the graph.

In order to get more precise information you need to specify the parameter ranges, and - even better - pose the original problem.

-