<?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: Vector parameters behaving as scalars in RANDGEN for Binomial distribution in SAS/IML Software and Matrix Computations</title>
    <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Vector-parameters-behaving-as-scalars-in-RANDGEN-for-Binomial/m-p/313505#M3096</link>
    <description>&lt;P&gt;Read &lt;A href="http://support.sas.com/documentation/cdl/en/imlug/68150/HTML/default/viewer.htm#imlug_langref_sect339.htm" target="_self"&gt;the documenation for the RANDGEN subroutine,&lt;/A&gt; which states:&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;All parameters must be the same length. You cannot specify a scalar for one parameter and a vector for another. If you pass in parameter vectors that do not satisfy one of the above conditions, then the first element of each parameter is used.&amp;nbsp;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc iml;
call randseed(123);
x = j(&amp;amp;N,&amp;amp;M);
p = {.1 .2 .5}; /*Probability*/
N = repeat(&amp;amp;N, 1, &amp;amp;M);
call randgen(x, "Binomial", p, N);
x=x/&amp;amp;N;
mean=mean(x);
print p, mean;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 22 Nov 2016 15:56:54 GMT</pubDate>
    <dc:creator>Rick_SAS</dc:creator>
    <dc:date>2016-11-22T15:56:54Z</dc:date>
    <item>
      <title>Vector parameters behaving as scalars in RANDGEN for Binomial distribution</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Vector-parameters-behaving-as-scalars-in-RANDGEN-for-Binomial/m-p/313500#M3095</link>
      <description>&lt;P&gt;Although the RANDGEN function should work on a vector of parameters, it doesn't give me the intended results. Even after generating a full matrix of parameter p&amp;nbsp;&lt;SPAN&gt;in the code below&amp;nbsp;&lt;/SPAN&gt;by repeating the row&amp;nbsp;vector (effectively a &lt;SPAN&gt;N*M matrix)&lt;/SPAN&gt;, the results clearly suggest that p is being taken as a scalar i.e. only the first element of p=0.1 from the matrix is used for whole matrix. I want to generate random numbers from a different distribution in each column.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;%let N = 100;&lt;BR /&gt;%let M= 3;&lt;BR /&gt;proc iml;&lt;BR /&gt;call randseed(123);&lt;BR /&gt;x = j(&amp;amp;N,&amp;amp;M);&lt;BR /&gt;y = j(&amp;amp;N,&amp;amp;M);&lt;BR /&gt;p= j(1, &amp;amp;M);/*specify row vector*/&lt;BR /&gt;p= {.1 .2 .5}; /*Probability*/&lt;BR /&gt;p_mat = repeat(p, &amp;amp;N); /*Repeat probability parameter for j(&amp;amp;N,&amp;amp;M) matrix*/&lt;BR /&gt;call randgen(x, "Binomial",p_mat,&amp;amp;N );&lt;BR /&gt;x=x/&amp;amp;N;&lt;BR /&gt;mean=mean(x);&lt;BR /&gt;max=max(x);&lt;BR /&gt;print p,mean,max;&lt;BR /&gt;Quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;RESULT:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;p&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;0.1&lt;/TD&gt;&lt;TD&gt;0.2&lt;/TD&gt;&lt;TD&gt;0.5&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;mean&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;0.1014&lt;/TD&gt;&lt;TD&gt;0.1001&lt;/TD&gt;&lt;TD&gt;0.1075&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;max&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;0.2&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
      <pubDate>Tue, 22 Nov 2016 15:41:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Vector-parameters-behaving-as-scalars-in-RANDGEN-for-Binomial/m-p/313500#M3095</guid>
      <dc:creator>abbaskashif</dc:creator>
      <dc:date>2016-11-22T15:41:39Z</dc:date>
    </item>
    <item>
      <title>Re: Vector parameters behaving as scalars in RANDGEN for Binomial distribution</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Vector-parameters-behaving-as-scalars-in-RANDGEN-for-Binomial/m-p/313505#M3096</link>
      <description>&lt;P&gt;Read &lt;A href="http://support.sas.com/documentation/cdl/en/imlug/68150/HTML/default/viewer.htm#imlug_langref_sect339.htm" target="_self"&gt;the documenation for the RANDGEN subroutine,&lt;/A&gt; which states:&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;All parameters must be the same length. You cannot specify a scalar for one parameter and a vector for another. If you pass in parameter vectors that do not satisfy one of the above conditions, then the first element of each parameter is used.&amp;nbsp;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc iml;
call randseed(123);
x = j(&amp;amp;N,&amp;amp;M);
p = {.1 .2 .5}; /*Probability*/
N = repeat(&amp;amp;N, 1, &amp;amp;M);
call randgen(x, "Binomial", p, N);
x=x/&amp;amp;N;
mean=mean(x);
print p, mean;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 22 Nov 2016 15:56:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Vector-parameters-behaving-as-scalars-in-RANDGEN-for-Binomial/m-p/313505#M3096</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2016-11-22T15:56:54Z</dc:date>
    </item>
    <item>
      <title>Re: Vector parameters behaving as scalars in RANDGEN for Binomial distribution</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Vector-parameters-behaving-as-scalars-in-RANDGEN-for-Binomial/m-p/313519#M3098</link>
      <description>&lt;P&gt;Thanks a million. It worked.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 22 Nov 2016 16:40:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Vector-parameters-behaving-as-scalars-in-RANDGEN-for-Binomial/m-p/313519#M3098</guid>
      <dc:creator>abbaskashif</dc:creator>
      <dc:date>2016-11-22T16:40:41Z</dc:date>
    </item>
  </channel>
</rss>

