<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/265205</link>
    <title>MATLAB Central Newsreader - Randomization_same number</title>
    <description>Feed for thread: Randomization_same number</description>
    <language>en-us</language>
    <copyright>&amp;copy;1994-2012 by MathWorks, Inc.</copyright>
    <webmaster>webmaster@mathworks.com</webmaster>
    <generator>MATLAB Central Newsreader</generator>
    <docs>http://blogs.law.harvard.edu/tech/rss</docs>
    <ttl>60</ttl>
    <image>
      <title>MathWorks</title>
      <url>http://www.mathworks.com/images/membrane_icon.gif</url>
    </image>
    <item>
      <pubDate>Fri, 06 Nov 2009 21:26:02 -0500</pubDate>
      <title>Randomization_same number</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/265205#692795</link>
      <author>Kostas </author>
      <description>Hi all,&lt;br&gt;
&lt;br&gt;
I am trying to present 4 different numbers 120 times in a vector, in a randomized order. But the thing is that I try to avoid repeating the same number twice in a row, and in the same time to keep the repetition frequency of each number the same (= 30). &lt;br&gt;
&lt;br&gt;
Do you have any ideas? &lt;br&gt;
&lt;br&gt;
Thanks</description>
    </item>
    <item>
      <pubDate>Fri, 06 Nov 2009 21:58:02 -0500</pubDate>
      <title>Re: Randomization_same number</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/265205#692800</link>
      <author>Luigi Giaccari</author>
      <description>&quot;Kostas &quot; &amp;lt;eclipse_dsotm@hotmail.com&amp;gt; wrote in message &amp;lt;hd249a$im2$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; Hi all,&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; I am trying to present 4 different numbers 120 times in a vector, in a randomized order. But the thing is that I try to avoid repeating the same number twice in a row, and in the same time to keep the repetition frequency of each number the same (= 30). &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Do you have any ideas? &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Thanks&lt;br&gt;
&lt;br&gt;
BUild the 120 element vector in a sorted order than use &quot;randperm&quot;&lt;br&gt;
&lt;br&gt;
The &quot;randperm&quot; will help you, but you need to postprocess the data to change duplicate values on a single row. A swap should be good.&lt;br&gt;
&lt;br&gt;
&lt;a href=&quot;http://www.advancedmcode.org/&quot;&gt;http://www.advancedmcode.org/&lt;/a&gt;</description>
    </item>
    <item>
      <pubDate>Fri, 06 Nov 2009 22:10:03 -0500</pubDate>
      <title>Re: Randomization_same number</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/265205#692805</link>
      <author>Kostas </author>
      <description>&amp;gt;BUild the 120 element vector in a sorted order than use &quot;randperm&quot;&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt;The &quot;randperm&quot; will help you, but you need to postprocess the data to change duplicate &amp;gt;values on a single row. A swap should be good.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt;&lt;a href=&quot;http://www.advancedmcode.org/&quot;&gt;http://www.advancedmcode.org/&lt;/a&gt;&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
Thanks for your reply. I think I should have mentioned that I must generate this vector a lot of times in the future, so it must me always different. :)&lt;br&gt;
&lt;br&gt;
Thanks again</description>
    </item>
    <item>
      <pubDate>Fri, 06 Nov 2009 23:04:01 -0500</pubDate>
      <title>Re: Randomization_same number</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/265205#692816</link>
      <author>John D'Errico</author>
      <description>&quot;Kostas &quot; &amp;lt;eclipse_dsotm@hotmail.com&amp;gt; wrote in message &amp;lt;hd26rr$q78$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &amp;gt;BUild the 120 element vector in a sorted order than use &quot;randperm&quot;&lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt;The &quot;randperm&quot; will help you, but you need to postprocess the data to change duplicate &amp;gt;values on a single row. A swap should be good.&lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt;&lt;a href=&quot;http://www.advancedmcode.org/&quot;&gt;http://www.advancedmcode.org/&lt;/a&gt;&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Thanks for your reply. I think I should have mentioned that I must generate this vector a lot of times in the future, so it must me always different. :)&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Thanks again&lt;br&gt;
&lt;br&gt;
So? Then be efficient in your code. Randperm is&lt;br&gt;
fast. It takes little effort to test to see if elements&lt;br&gt;
are consecutive. Use diff to do the test.&lt;br&gt;
&lt;br&gt;
John</description>
    </item>
    <item>
      <pubDate>Fri, 06 Nov 2009 23:48:01 -0500</pubDate>
      <title>Re: Randomization_same number</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/265205#692823</link>
      <author>D </author>
      <description>&amp;gt; So? Then be efficient in your code. Randperm is&lt;br&gt;
&amp;gt; fast. It takes little effort to test to see if elements&lt;br&gt;
&amp;gt; are consecutive. Use diff to do the test.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; John&lt;br&gt;
&lt;br&gt;
Thanks John. I do use the randperm function, but of course i have same trials in a row. I can find where (using diff as well), but still cannot solve the problem. &lt;br&gt;
&lt;br&gt;
I created a mask to get rid of all the numbers i've used, but i am not sure if it is efficient and worth trying -i am new in matlab. And besides, it doesn't work properly.&lt;br&gt;
&lt;br&gt;
Thanks</description>
    </item>
    <item>
      <pubDate>Sat, 07 Nov 2009 01:30:07 -0500</pubDate>
      <title>Re: Randomization_same number</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/265205#692834</link>
      <author>John D'Errico</author>
      <description>&quot;D &quot; &amp;lt;eclipse_dsotm@hotmail.com&amp;gt; wrote in message &amp;lt;hd2cjh$evv$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &amp;gt; So? Then be efficient in your code. Randperm is&lt;br&gt;
&amp;gt; &amp;gt; fast. It takes little effort to test to see if elements&lt;br&gt;
&amp;gt; &amp;gt; are consecutive. Use diff to do the test.&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; John&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Thanks John. I do use the randperm function, but of course i have same trials in a row. I can find where (using diff as well), but still cannot solve the problem. &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; I created a mask to get rid of all the numbers i've used, but i am not sure if it is efficient and worth trying -i am new in matlab. And besides, it doesn't work properly.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Thanks&lt;br&gt;
&lt;br&gt;
So use randperm. Then set up a loop. Scan through&lt;br&gt;
the sequence. If the ith element is equal to the previous&lt;br&gt;
element, then swap it with the next element in the&lt;br&gt;
sequence which is not equal to it. Continue this&lt;br&gt;
operation until done. If you get to the end without&lt;br&gt;
success, then wrap around to the beginning.&lt;br&gt;
&lt;br&gt;
This will be fast.&lt;br&gt;
&lt;br&gt;
John</description>
    </item>
  </channel>
</rss>

