For Programmers: Free Programming Magazines  


Home > Archive > Matlab > June 2007 > Re: matlab random generator with conditions









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: matlab random generator with conditions
oscar

2007-06-20, 7:20 pm

A mathematica software user
propose this formula , that apply some conditions to a serie of 100 number
of a crap.
In[1]:=freq={{1,0.17},{2,0.17},{3,0.17},{4,0.17},{5,0.17},{6,0.15}};

In[2]:=data=MapThread[Table[#1,{Floor[10
0#2]}]&,Transpose[freq]]//
Flatten

Out[2]={1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,
2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,
4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,
5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
6,6,6,6,6,6,6,6,6,6,6,6,6,6,6}

In[3]:=Do[Print[data[[Random[Integer,{1,
100}]]]] ,{10}]
1
3
1
5
4
6
3
3
3
4
..
..
..

v.a.


How whe can write in matlab?




"oscar selogni" <diavolololo@alice.it> ha scritto nel messaggio
news:ef5b2c1.-1@webcrossing.raydaftYaTP...
>i have a problem with roulette simulation...
>
> numbers = floor(37*rand(1000000,1))
>
> with this command, i generate a random serie of numbers from 0
> to 36.
> But if i want to impose some conditions on numbers serie ?
> How i can insert?
> For example
> if i want to generate a serie of random numbers with some conditions
> as:
>
> frequence,delay etc?
> In example i want to have on 1000.000 numbers 27927 numbers 1,
> with max delay from last sort of 550 boules, and other numerical
> conditions...
> how can i impose this conditions to generation process?
>
> Thanks in advance



Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com