<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Modify a discrete distribution to yield given expected value in SAS/IML Software and Matrix Computations</title>
    <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Modify-a-discrete-distribution-to-yield-given-expected-value/m-p/196603#M2016</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This seems to be a completely appropriate question for the IML forum.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 31 May 2015 16:07:33 GMT</pubDate>
    <dc:creator>Rick_SAS</dc:creator>
    <dc:date>2015-05-31T16:07:33Z</dc:date>
    <item>
      <title>Modify a discrete distribution to yield given expected value</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Modify-a-discrete-distribution-to-yield-given-expected-value/m-p/196600#M2013</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Suppose X = 1,2,3,4,5,6,7 and P(X=x)=0.009, 0.001, 0.036, 0.027, 0.145 0.309, 0.473 resulting in E(X)=6.117. We can simulate from this distribution using &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;%let p=0.009 0.001 0.036 0.027 0.145 0.309 0.473;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;%let seed=123456;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;%let samplesize=1000;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;%let delta=0.7; *mean difference;&lt;BR /&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;data sample(keep= id x group);&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;call streaminit(&amp;amp;seed);&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;array p[6] (0.009 0.001 0.036 0.027 0.145 0.309); *p of the last category (7) is left out ;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;do ID = 1 to &amp;amp;samplesize;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp; x = rand("Table", of p&lt;/EM&gt;&lt;LI&gt;&lt;EM&gt;);&lt;/EM&gt;&lt;/LI&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp; group=1;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp; output;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;end;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;run;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;BR /&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;OR&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;BR /&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;proc iml;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;x = 1:7;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;ExpVal=sum(x#{&amp;amp;p});&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;call randseed(&amp;amp;seed);&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;group1 = sample(x, &amp;amp;samplesize, "Replace", {&amp;amp;p});&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;quit;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My questions are the following;&lt;/P&gt;&lt;P&gt;(1) How can I modify P(X=x) such that E(X) is e.g., 5.5 (from 6.117) for group 1, assuming equal variances? So a shift of E(X) downwards.&lt;/P&gt;&lt;P&gt;(2) If I have a second group (group=2), how can I adapt the above code to result in a mean difference (delta=0.3 or 0.7) with group 2 always being higher, considering boundary limitations towards the last category (X=7)? A shift of E(X) &lt;SPAN style="font-size: 13.3333330154419px; line-height: 1.5em;"&gt;upwards&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 31 May 2015 04:47:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Modify-a-discrete-distribution-to-yield-given-expected-value/m-p/196600#M2013</guid>
      <dc:creator>KGeorge</dc:creator>
      <dc:date>2015-05-31T04:47:46Z</dc:date>
    </item>
    <item>
      <title>Re: Modify a discrete distribution to yield given expected value</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Modify-a-discrete-distribution-to-yield-given-expected-value/m-p/196601#M2014</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;When you say "assuming equal variances" do you mean that the new probabilities give rise to a variance that is the same as for this example?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Define&lt;/P&gt;&lt;P&gt;p = {&amp;amp;p}`;&lt;/P&gt;&lt;P&gt;The variance is sum(x## # p) - ExpVal##2 = 1.277.;&lt;/P&gt;&lt;P&gt;The p vector is a 7-element vector with 6 free parameters (since sum(p)=1).&lt;/P&gt;&lt;P&gt;It looks like the problem is linear in the parameters p, so I would attempt to solve this as a linear programming problem.&lt;/P&gt;&lt;P&gt;The constraints are p[1]&amp;gt;0, ..., p[7]&amp;gt;0, sum(p)=1, mean=5.5, and Variance=1.277.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you are using a recent version of SAS/IML, you can use the &lt;A href="http://support.sas.com/documentation/cdl/en/imlug/66845/HTML/default/viewer.htm#imlug_langref_sect236.htm"&gt;LPSOLVE call&lt;/A&gt; to solve LP problems. For older versions of IML, use the LP call.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think there might be infinitely many solutions to your problem.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 31 May 2015 10:12:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Modify-a-discrete-distribution-to-yield-given-expected-value/m-p/196601#M2014</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2015-05-31T10:12:59Z</dc:date>
    </item>
    <item>
      <title>Re: Modify a discrete distribution to yield given expected value</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Modify-a-discrete-distribution-to-yield-given-expected-value/m-p/196602#M2015</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;HoHo. You seems to do some linear program . You should post it at OR forum , and I think there should be lots of solution .&lt;/P&gt;&lt;P&gt;The following is the solution from IML.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;proc iml;
p={0.009 0.001&amp;nbsp; 0.036&amp;nbsp; 0.027&amp;nbsp; 0.145&amp;nbsp; 0.309&amp;nbsp; 0.473};
x=1:7;
mean=(p#x)[+];
var=(p#((x-mean)##2))[+];
print mean var;

v=(x-5.5)##2; /*calculated var coefficient*/
print v[f=best8.];




/*Start Solution*/
object = { 1 1 1 1 1 1 1 };
coef = {1 2 3 4 5 6 7, /*mean */
&amp;nbsp; 20.25&amp;nbsp; 12.25&amp;nbsp; 6.25&amp;nbsp; 2.25&amp;nbsp;&amp;nbsp; 0.25&amp;nbsp;&amp;nbsp; 0.25 2.25 , /* var coefficient e.g row vector V */
&amp;nbsp; 1 1 1 1 1 1 1 /* sum of p is 1 */
};
b = { 5.5 ,1.277311,1 };
l = { 0.01 0.01 0.01 0.01 0.01 0.01 0.01};
u = { 0.9 0.9 0.9 0.9 0.9 0.9 0.9};
rowsense = {'E','E','E'};
cntl= -1;
call lpsolve (rc,objv,solution,dual,rd,object,coef,b,cntl,rowsense,,l,u);
print&amp;nbsp; solution ;
quit;



&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Xia Keshan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 31 May 2015 10:48:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Modify-a-discrete-distribution-to-yield-given-expected-value/m-p/196602#M2015</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2015-05-31T10:48:20Z</dc:date>
    </item>
    <item>
      <title>Re: Modify a discrete distribution to yield given expected value</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Modify-a-discrete-distribution-to-yield-given-expected-value/m-p/196603#M2016</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This seems to be a completely appropriate question for the IML forum.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 31 May 2015 16:07:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Modify-a-discrete-distribution-to-yield-given-expected-value/m-p/196603#M2016</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2015-05-31T16:07:33Z</dc:date>
    </item>
    <item>
      <title>Re: Modify a discrete distribution to yield given expected value</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Modify-a-discrete-distribution-to-yield-given-expected-value/m-p/196604#M2017</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Rick and Xia.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rick, Indeed I meant that the new probabilities would give rise to the same variance.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Xia, the solution you provide is what I needed for part 1 of my question (which is to obtain E(X)=5.5). I modified your code to include the sampling for the two groups. Many thanks.&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;However, for part 2 of my question, if for example, E(X) should become 6.867 (which would be a shift upwards of 0.75), the lpsolve call returns 0's for the solution. I think this is because the desired E(X)=6.867 is too close to the maximum score (7) inducing boundary problems. Are there any alternatives to dealing with this?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;%let seed=123456;&lt;/P&gt;&lt;P&gt;%let samplesize=1000000;&lt;/P&gt;&lt;P&gt;%let delta=0.75; * mean difference or shift ;&lt;/P&gt;&lt;P&gt;proc iml;&lt;/P&gt;&lt;P&gt;p={0.009 0.001&amp;nbsp; 0.036&amp;nbsp; 0.027&amp;nbsp; 0.145&amp;nbsp; 0.309&amp;nbsp; 0.473};&lt;/P&gt;&lt;P&gt;x=1:7;&lt;/P&gt;&lt;P&gt;mean=(p#x)[+];&lt;/P&gt;&lt;P&gt;var=(p#((x-mean)##2))[+];&lt;/P&gt;&lt;P&gt;print mean var;&lt;/P&gt;&lt;P&gt;expectmean=mean + &amp;amp;delta; * mean shifted by delta ;&lt;/P&gt;&lt;P&gt;v=(x-expectmean)##2; /*calculated var coefficient*/&lt;/P&gt;&lt;P&gt;print expectmean, v[f=best8.];&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/*Start Solution*/&lt;/P&gt;&lt;P&gt;object = { 1 1 1 1 1 1 1 };&lt;/P&gt;&lt;P&gt;coef=x//v//object;&lt;/P&gt;&lt;P&gt;print coef;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;b = expectmean // var // {1};&lt;/P&gt;&lt;P&gt;l = { 0.00001 0.00001 0.00001 0.00001 0.00001 0.00001 0.00001};&lt;/P&gt;&lt;P&gt;u = { 0.9999 0.9999 0.9999 0.9999 0.9999 0.9999 0.9999};&lt;/P&gt;&lt;P&gt;rowsense = {'E','E','E'};&lt;/P&gt;&lt;P&gt;cntl= -1;&lt;/P&gt;&lt;P&gt;call lpsolve (rc,objv,solution,dual,rd,object,coef,b,cntl,rowsense,,l,u);&lt;/P&gt;&lt;P&gt;print&amp;nbsp;&amp;nbsp; solution ;&lt;/P&gt;&lt;P&gt;mean2=(solution`#x)[+];&lt;/P&gt;&lt;P&gt;var2=(solution`#((x-mean2)##2))[+];&lt;/P&gt;&lt;P&gt;print mean var mean2 var2;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/* Sampling for the two groups */&lt;/P&gt;&lt;P&gt;call randseed(&amp;amp;seed);&lt;/P&gt;&lt;P&gt;group1 = sample(x, &amp;amp;samplesize, "Replace", p);&lt;/P&gt;&lt;P&gt;group2 = sample(x, &amp;amp;samplesize, "Replace", solution);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;print (mean(group1`))[label="Sample mean group 1"]&amp;nbsp; (var(group1`))[label="Sample Variance Group 1"],&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (mean(group2`))[label="Sample mean group 2"]&amp;nbsp; (var(group2`))[label="Sample variance group 2"];&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 01 Jun 2015 08:07:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Modify-a-discrete-distribution-to-yield-given-expected-value/m-p/196604#M2017</guid>
      <dc:creator>KGeorge</dc:creator>
      <dc:date>2015-06-01T08:07:54Z</dc:date>
    </item>
    <item>
      <title>Re: Modify a discrete distribution to yield given expected value</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Modify-a-discrete-distribution-to-yield-given-expected-value/m-p/196605#M2018</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;For you second question, I don't understand "&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;considering boundary limitations towards the last category (X=7)" , you want only change P(x=7) and keep other the same ? But if others have been settled ,then P(x=7) is all settled .&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;If you only want change E(X) = &lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;E(X)+0.3 =6.417, that would be easy .&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc iml;&lt;/P&gt;&lt;P&gt;p={0.009 0.001&amp;nbsp; 0.036&amp;nbsp; 0.027&amp;nbsp; 0.145&amp;nbsp; 0.309&amp;nbsp; 0.473};&lt;/P&gt;&lt;P&gt;x=1:7;&lt;/P&gt;&lt;P&gt;mean=(p#x)[+] ; &lt;/P&gt;&lt;P&gt;var=(p#((x-mean)##2))[+];&lt;/P&gt;&lt;P&gt;print mean var;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;v=(x-6.417 /*Delta is 0.3*/)##2; /*calculated var coefficient*/&lt;/P&gt;&lt;P&gt;print v[f=best8.];&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/*Start Solution*/&lt;/P&gt;&lt;P&gt;object = { 1 1 1 1 1 1 1 };&lt;/P&gt;&lt;P&gt;coef = {1 2 3 4 5 6 7}//v//{1 1 1 1 1 1 1};&lt;/P&gt;&lt;P&gt;b = { 6.417 /*Delta is 0.3*/}//var//{1};&lt;/P&gt;&lt;P&gt;l = { 0.01 0.01 0.01 0.01 0.01 0.01 0.01};&lt;/P&gt;&lt;P&gt;u = { 0.9 0.9 0.9 0.9 0.9 0.9 0.9};&lt;/P&gt;&lt;P&gt;rowsense = {'E','E','E'};&lt;/P&gt;&lt;P&gt;cntl= -1;&lt;/P&gt;&lt;P&gt;call lpsolve (rc,objv,solution,dual,rd,object,coef,b,cntl,rowsense,,l,u);&lt;/P&gt;&lt;P&gt;print&amp;nbsp; solution ;&lt;/P&gt;&lt;P&gt;mean=(solution`#x)[+] ; &lt;/P&gt;&lt;P&gt;var=(solution`#((x-mean)##2))[+];&lt;/P&gt;&lt;P&gt;print mean var;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Xia Keshan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 01 Jun 2015 12:30:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Modify-a-discrete-distribution-to-yield-given-expected-value/m-p/196605#M2018</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2015-06-01T12:30:09Z</dc:date>
    </item>
    <item>
      <title>Re: Modify a discrete distribution to yield given expected value</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Modify-a-discrete-distribution-to-yield-given-expected-value/m-p/196606#M2019</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;if E(X) should become 6.867, I am kind of get feeling LPSOLVE() can't do that , unless sum of p could greater than 1.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;or you could post it at OR forum , and see if somebody have a better method .&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 01 Jun 2015 12:48:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Modify-a-discrete-distribution-to-yield-given-expected-value/m-p/196606#M2019</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2015-06-01T12:48:15Z</dc:date>
    </item>
    <item>
      <title>Re: Modify a discrete distribution to yield given expected value</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Modify-a-discrete-distribution-to-yield-given-expected-value/m-p/196607#M2020</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hope so . Rick .&amp;nbsp; &lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 01 Jun 2015 12:50:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Modify-a-discrete-distribution-to-yield-given-expected-value/m-p/196607#M2020</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2015-06-01T12:50:01Z</dc:date>
    </item>
    <item>
      <title>Re: Modify a discrete distribution to yield given expected value</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Modify-a-discrete-distribution-to-yield-given-expected-value/m-p/196608#M2021</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Xia &lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px; background-color: #ffffff;"&gt;Keshan!&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px; background-color: #ffffff;"&gt;Indeed, everything works well when newExpectedValue=E(X) + delta as long as delta is less than or equal to 0.66 (leading to newExpectedValue=6.77). T&lt;/SPAN&gt;he second question is simply a need to shift E(X) from 6.11 to 6.86 (delta=0.75).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 01 Jun 2015 12:50:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Modify-a-discrete-distribution-to-yield-given-expected-value/m-p/196608#M2021</guid>
      <dc:creator>KGeorge</dc:creator>
      <dc:date>2015-06-01T12:50:12Z</dc:date>
    </item>
    <item>
      <title>Re: Modify a discrete distribution to yield given expected value</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Modify-a-discrete-distribution-to-yield-given-expected-value/m-p/196609#M2022</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Lots of thanks though!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 01 Jun 2015 12:52:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Modify-a-discrete-distribution-to-yield-given-expected-value/m-p/196609#M2022</guid>
      <dc:creator>KGeorge</dc:creator>
      <dc:date>2015-06-01T12:52:30Z</dc:date>
    </item>
    <item>
      <title>Re: Modify a discrete distribution to yield given expected value</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Modify-a-discrete-distribution-to-yield-given-expected-value/m-p/196610#M2023</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi. If you allow a little offset , you could try this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="x.png" class="jive-image" src="https://communities.sas.com/legacyfs/online/10698_x.png" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;proc iml;
p={0.009 0.001&amp;nbsp; 0.036&amp;nbsp; 0.027&amp;nbsp; 0.145&amp;nbsp; 0.309&amp;nbsp; 0.473};
x=1:7;
mean=(p#x)[+] ; 
var=(p#((x-mean)##2))[+];
print mean var;

 
v=(x-6.867)##2; /*calculated var coefficient*/
print v[f=best8.];



/*Start Solution*/

object = { 0 0 0 0 0 0 0 };
coef = {1 2 3 4 5 6 7}//v//{1 1 1 1 1 1 1};
b = { 6.867}//var//{1};
l = {0 0 0 0 0 0 0 };
u = {1 1 1 1 1 1 1 };
rowsense = {'E','E','G'} ;
cntl= -1;
call lpsolve (rc,objv,solution,dual,rd,object,coef,b,cntl,rowsense,,l,u);
print&amp;nbsp; solution ,(solution[+])[label='sum of p'];
mean=(solution`#x)[+] ; 
var=(solution`#((x-mean)##2))[+];
print mean var;
quit;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Xia Keshan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Jun 2015 02:24:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Modify-a-discrete-distribution-to-yield-given-expected-value/m-p/196610#M2023</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2015-06-02T02:24:54Z</dc:date>
    </item>
    <item>
      <title>Re: Modify a discrete distribution to yield given expected value</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Modify-a-discrete-distribution-to-yield-given-expected-value/m-p/196611#M2024</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Xia, &lt;/P&gt;&lt;P&gt;I would prefer not to have an offset. But am so thankful for your efforts. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Jun 2015 12:16:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Modify-a-discrete-distribution-to-yield-given-expected-value/m-p/196611#M2024</guid>
      <dc:creator>KGeorge</dc:creator>
      <dc:date>2015-06-02T12:16:39Z</dc:date>
    </item>
  </channel>
</rss>

