Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

I am trying to define an AI domain in which I need to define the probability $p_i,$ of a variable $v_i$ having a value 1 or 0. $p_i$ may range anywhere from 0 to 100%. In my problem i goes from 1 to 83. $p_i$ has the following restriction:

I want on average for 47 of the variables $v_i$ to take value 1, so

$$\sum_{i=1}^{83} p_i=47.$$

And they need to have an extra characteristic due to my domain which is obeying this formula:


Any thoughts on how do I solve this?

(For reference, here is the original link.)

EDIT (from comments):

I am trying to define an AI domain, those are probabilities (p_i) of several variables being 1 or 0. But I have to have more 1's on smaller i's and more 0's on larger ones. On average, I should have 47 1's, meaning that the sum of their probability should be 47.

I will actually be varying the values of the 80% and the 47, but I thought it would be easier to post it like that.

share|improve this question
I texed your equations. Please check if I introduced any errors in doing so. –  M Turgeon Aug 15 '12 at 19:59
The first is not a linear equation, so the tag (linear-algebra) should be changed. –  Shaun Ault Aug 15 '12 at 20:07
I changed the tag to (algebra-precalculus); if someone thinks of a more suitable tag feel free to change it. –  Alex Becker Aug 15 '12 at 20:19
Ok, Great, thank you three –  Monica Aug 15 '12 at 20:24
Consider one specific i and j, being i<j (NOT v_i<v_j, i really mean i<j), I have a p_i*(1-p_j) (probability v_i=1 and v_j=0) over (p_i(1-p_j)+(1-p_i)*p_j)...and I want the average of that over all i's and j's to be 80% –  Monica Aug 15 '12 at 20:48

1 Answer 1

Since you have $81$ more variables than equations, typically there will be $81$ degrees of freedom in the solutions. I doubt that you'll get a closed-form solution. One approximate numerical solution I found was $$\matrix{p[1]=0.9936010879\cr p[2]=0.9949598390\cr p[3]=0.9988145696\cr p[4]=0.9970419766\cr p[5]=0.9967779997\cr p[6]=0.9973747621\cr p[7]=0.9979315968\cr p[8]=0.9982231336\cr p[9]=0.9981696879\cr p[10]=0.9922669675\cr p[11]=0.9917904561\cr p[12]=0.9838146901\cr p[13]=0.9848249116\cr p[14]=0.9917898198\cr p[15]=0.9767770505\cr p[16]=0.9598615358\cr p[17]=0.9426460162\cr p[18]=0.9253550297\cr p[19]=0.9080518577\cr p[20]=0.8907556300\cr p[21]=0.8734717325\cr p[22]=0.8562009141\cr p[23]=0.8389423521\cr p[24]=0.8216947619\cr p[25]=0.8044568099\cr p[26]=0.7872272601\cr p[27]=0.7700050176\cr p[28]=0.7527891303\cr p[29]=0.7355787758\cr p[30]=0.7183732445\cr p[31]=0.7011719221\cr p[32]=0.6839742739\cr p[33]=0.6667798318\cr p[34]=0.6495881825\cr p[35]=0.6323989575\cr p[36]=0.6152118254\cr p[37]=0.5980264849\cr p[38]=0.5808426580\cr p[39]=0.5636600855\cr p[40]=0.5464785218\cr p[41]=0.5292977308\cr p[42]=0.5121174814\cr p[43]=0.4949375437\cr p[44]=0.4777576850\cr p[45]=0.4605776649\cr p[46]=0.4433972314\cr p[47]=0.4262161150\cr p[48]=0.4090340228\cr p[49]=0.3918506313\cr p[50]=0.3746655777\cr p[51]=0.3574784488\cr p[52]=0.3402887674\cr p[53]=0.3230959752\cr p[54]=0.3058994099\cr p[55]=0.2886982750\cr p[56]=0.2714916005\cr p[57]=0.2542781875\cr p[58]=0.2370565322\cr p[59]=0.2198247182\cr p[60]=0.2025802589\cr p[61]=0.1853198636\cr p[62]=0.1680390765\cr p[63]=0.1507317014\cr p[64]=0.1333888453\cr p[65]=0.1159972422\cr p[66]=0.0985361229\cr p[67]=0.0809708670\cr p[68]=0.1956764307\cr p[69]=0.3485961405\cr p[70]=0.4325779559\cr p[71]=0.4153325481\cr p[72]=0.3980828793\cr p[73]=0.3808283238\cr p[74]=0.3635681850\cr p[75]=0.3463016797\cr p[76]=0.3290279190\cr p[77]=0.3117458849\cr p[78]=0.2944544007\cr p[79]=0.2771520935\cr p[80]=0.2598373465\cr p[81]=0.2425082357\cr p[82]=0.2251624475\cr p[83]=0.2079185926\cr }$$

EDIT: Here is one way to get a solution (probably not the same one) in Maple:

e1:= add(add(p[i]*(1-p[j])/(p[i]*(1-p[j])+(1-p[i])*p[j])/(83*82/2),
      j=i+1..83),i=1..83) - 8/10:
e2:= add(p[i],i=1..83)-47:
P0:= Optimization[Minimize](e1^2,{e2=0},seq(p[i]=0.001 .. 0.999, i=1..83))[2];
X0:= eval(<seq(p[i],i=1..83)>,P0);
# this is a pretty good solution, but can be improved
M:= Matrix([eval([seq(diff(e1,p[i]),i=1..83)],P0), [seq(1,i=1..83)]]);
E:= eval(<e1,e2>,P0);
X1:= X0 - LinearAlgebra[MatrixInverse](M).E;
share|improve this answer
Can you tell me how so I can replicate? Thank you so much –  Monica Aug 15 '12 at 21:05
I will actually have to vary the 47 and 80% and solve again, knowing how will really help me. ;) –  Monica Aug 15 '12 at 21:06
You can (generally) solve the two equations by picking anything you like for 81 variables and solving for the last 2. If the numbers you pick for 81 of them are close to your approximate solution, then the remaining two should be within $[0,1]$ as well. –  Hurkyl Aug 15 '12 at 21:11
Great, thanks ;) –  Monica Aug 15 '12 at 21:38

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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