Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
random values

Subject: random values

From: Artur Racu

Date: 26 May, 2010 15:30:21

Message: 1 of 11

hy all,

could anyone help me on this problem...i have 100 different random values which i want to inject in a system during 15 seconds, the simple way i can do is to inject each value with the step 0.15s, but the ideea is that i want to inject them dynamicaly, so for this i need small randoms times, so thats why i want random values with sum 15 ) could anyone help me on this?

Thank you,

Artur

Subject: random values

From: Sean

Date: 26 May, 2010 15:54:06

Message: 2 of 11

"Artur Racu" <arturracu@yahoo.com> wrote in message <htjeqd$s1a$1@fred.mathworks.com>...
> hy all,
>
> could anyone help me on this problem...i have 100 different random values which i want to inject in a system during 15 seconds, the simple way i can do is to inject each value with the step 0.15s, but the ideea is that i want to inject them dynamicaly, so for this i need small randoms times, so thats why i want random values with sum 15 ) could anyone help me on this?
>
> Thank you,
>
> Artur

%Random 100 long vector
rvec = rand(1,100);

%time to wait between insertion
tvec = (rvec/sum(rvec))*15; %find percentages then multiply by total time

%Time relative to start
trel = cumsum(tvec);

Subject: random values

From: Artur Artur

Date: 26 May, 2010 21:40:20

Message: 3 of 11

"Sean " <sean.dewolski@nospamplease.umit.maine.edu> wrote in message <htjg6u$14o$1@fred.mathworks.com>...
> "Artur Racu" <arturracu@yahoo.com> wrote in message <htjeqd$s1a$1@fred.mathworks.com>...
> > hy all,
> >
> > could anyone help me on this problem...i have 100 different random values which i want to inject in a system during 15 seconds, the simple way i can do is to inject each value with the step 0.15s, but the ideea is that i want to inject them dynamicaly, so for this i need small randoms times, so thats why i want random values with sum 15 ) could anyone help me on this?
> >
> > Thank you,
> >
> > Artur
>
> %Random 100 long vector
> rvec = rand(1,100);
>
> %time to wait between insertion
> tvec = (rvec/sum(rvec))*15; %find percentages then multiply by total time
>
> %Time relative to start
> trel = cumsum(tvec);

thanks a lot Sean it really help

Subject: random values

From: Roger Stafford

Date: 26 May, 2010 22:39:06

Message: 4 of 11

"Artur Artur" <arturracu@yahoo.com> wrote in message <htk4g4$rel$1@fred.mathworks.com>...
> "Sean " <sean.dewolski@nospamplease.umit.maine.edu> wrote in message <htjg6u$14o$1@fred.mathworks.com>...
> > "Artur Racu" <arturracu@yahoo.com> wrote in message <htjeqd$s1a$1@fred.mathworks.com>...
> > > hy all,
> > >
> > > could anyone help me on this problem...i have 100 different random values which i want to inject in a system during 15 seconds, the simple way i can do is to inject each value with the step 0.15s, but the ideea is that i want to inject them dynamicaly, so for this i need small randoms times, so thats why i want random values with sum 15 ) could anyone help me on this?
> > >
> > > Thank you,
> > >
> > > Artur
> >
> > %Random 100 long vector
> > rvec = rand(1,100);
> >
> > %time to wait between insertion
> > tvec = (rvec/sum(rvec))*15; %find percentages then multiply by total time
> >
> > %Time relative to start
> > trel = cumsum(tvec);
>
> thanks a lot Sean it really help

  The trouble with that kind of solution is that it packs points more densely in towards the center of the available space. To see this try the following:

 n = 8000;
 p = rand(3,n);
 p = p./repmat(sum(p,1),3,1)*15; % Now each column of p has the sum 15
 plot(p(1,:),p(2,:),p(3,:),'y.')

As you can see, the points are bunched more densely towards the center of the triangle.

  In the Wikipedia site below there is a section on "random sampling" or "simplex point picking" which shows two methods of providing a uniform packing of points within your simplex - that is, within the space of points whose sum is the desired 15 in your case.

 http://en.wikipedia.org/wiki/Simplex

Roger Stafford

Subject: random values

From: kk KKsingh

Date: 27 May, 2010 02:26:04

Message: 5 of 11

"Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid> wrote in message <htk7ua$a64$1@fred.mathworks.com>...
> "Artur Artur" <arturracu@yahoo.com> wrote in message <htk4g4$rel$1@fred.mathworks.com>...
> > "Sean " <sean.dewolski@nospamplease.umit.maine.edu> wrote in message <htjg6u$14o$1@fred.mathworks.com>...
> > > "Artur Racu" <arturracu@yahoo.com> wrote in message <htjeqd$s1a$1@fred.mathworks.com>...
> > > > hy all,
> > > >
> > > > could anyone help me on this problem...i have 100 different random values which i want to inject in a system during 15 seconds, the simple way i can do is to inject each value with the step 0.15s, but the ideea is that i want to inject them dynamicaly, so for this i need small randoms times, so thats why i want random values with sum 15 ) could anyone help me on this?
> > > >
> > > > Thank you,
> > > >
> > > > Artur
> > >
> > > %Random 100 long vector
> > > rvec = rand(1,100);
> > >
> > > %time to wait between insertion
> > > tvec = (rvec/sum(rvec))*15; %find percentages then multiply by total time
> > >
> > > %Time relative to start
> > > trel = cumsum(tvec);
> >
> > thanks a lot Sean it really help
>
> The trouble with that kind of solution is that it packs points more densely in towards the center of the available space. To see this try the following:
>
> n = 8000;
> p = rand(3,n);
> p = p./repmat(sum(p,1),3,1)*15; % Now each column of p has the sum 15
> plot(p(1,:),p(2,:),p(3,:),'y.')
>
> As you can see, the points are bunched more densely towards the center of the triangle.
>
> In the Wikipedia site below there is a section on "random sampling" or "simplex point picking" which shows two methods of providing a uniform packing of points within your simplex - that is, within the space of points whose sum is the desired 15 in your case.
>
> http://en.wikipedia.org/wiki/Simplex
>
> Roger Stafford

SInce Rand is comming in question ! I am just wondering how can i generate same random number every time i run the program !

Thanks

Subject: random values

From: us

Date: 27 May, 2010 04:37:03

Message: 6 of 11

"kk KKsingh"
> SInce Rand is comming in question ! I am just wondering how can i generate same random number every time i run the program !
>
> Thanks

a hint:
- peruse the great stuff that you see after typing this at the command prompt...

     doc randstream;

us

Subject: random values

From: Artur Artur

Date: 27 May, 2010 06:10:22

Message: 7 of 11

"Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid> wrote in message <htk7ua$a64$1@fred.mathworks.com>...
> "Artur Artur" <arturracu@yahoo.com> wrote in message <htk4g4$rel$1@fred.mathworks.com>...
> > "Sean " <sean.dewolski@nospamplease.umit.maine.edu> wrote in message <htjg6u$14o$1@fred.mathworks.com>...
> > > "Artur Racu" <arturracu@yahoo.com> wrote in message <htjeqd$s1a$1@fred.mathworks.com>...
> > > > hy all,
> > > >
> > > > could anyone help me on this problem...i have 100 different random values which i want to inject in a system during 15 seconds, the simple way i can do is to inject each value with the step 0.15s, but the ideea is that i want to inject them dynamicaly, so for this i need small randoms times, so thats why i want random values with sum 15 ) could anyone help me on this?
> > > >
> > > > Thank you,
> > > >
> > > > Artur
> > >
> > > %Random 100 long vector
> > > rvec = rand(1,100);
> > >
> > > %time to wait between insertion
> > > tvec = (rvec/sum(rvec))*15; %find percentages then multiply by total time
> > >
> > > %Time relative to start
> > > trel = cumsum(tvec);
> >
> > thanks a lot Sean it really help
>
> The trouble with that kind of solution is that it packs points more densely in towards the center of the available space. To see this try the following:
>
> n = 8000;
> p = rand(3,n);
> p = p./repmat(sum(p,1),3,1)*15; % Now each column of p has the sum 15
> plot(p(1,:),p(2,:),p(3,:),'y.')
>
> As you can see, the points are bunched more densely towards the center of the triangle.
>
> In the Wikipedia site below there is a section on "random sampling" or "simplex point picking" which shows two methods of providing a uniform packing of points within your simplex - that is, within the space of points whose sum is the desired 15 in your case.
>
> http://en.wikipedia.org/wiki/Simplex
>
> Roger Stafford

dear Roger,

i'm sorry if i wasn' clear, this is not i want...so...i have 100 random values which i want to inject in a power system so i can disturb it, the time for this incident is 15 seconds, the way i am doing now is this:
0.15s-first rand value
0.3s-second rand value
0.45s-third rand value
..........................
14.45s-99-th rand value
15s-100 rand value

so, if i am doing in this way i will have a liniar time disturbance that's way i want 100 random values for this 15s

thank you

Artur

Subject: random values

From: Roger Stafford

Date: 27 May, 2010 07:26:06

Message: 8 of 11

"Artur Artur" <arturracu@yahoo.com> wrote in message <htl2ce$2gk$1@fred.mathworks.com>...
> dear Roger,
>
> i'm sorry if i wasn' clear, this is not i want...so...i have 100 random values which i want to inject in a power system so i can disturb it, the time for this incident is 15 seconds, the way i am doing now is this:
> 0.15s-first rand value
> 0.3s-second rand value
> 0.45s-third rand value
> ..........................
> 14.45s-99-th rand value
> 15s-100 rand value
>
> so, if i am doing in this way i will have a liniar time disturbance that's way i want 100 random values for this 15s
>
> thank you
>
> Artur

  Well then what's all this about "i want random values with sum 15" and "for this i need small randoms times?" Why must they have a sum of 15? What is "random times" about events that are spaced evenly apart by .15 seconds each? That was certainly misleading. It sounded just as though you wanted the total time spam of the 100 successive events to be 15 seconds but that the timing was otherwise random.

Roger Stafford

Subject: random values

From: Artur Artur

Date: 27 May, 2010 10:28:06

Message: 9 of 11

"Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid> wrote in message <htl6qe$gfb$1@fred.mathworks.com>...
> "Artur Artur" <arturracu@yahoo.com> wrote in message <htl2ce$2gk$1@fred.mathworks.com>...
> > dear Roger,
> >
> > i'm sorry if i wasn' clear, this is not i want...so...i have 100 random values which i want to inject in a power system so i can disturb it, the time for this incident is 15 seconds, the way i am doing now is this:
> > 0.15s-first rand value
> > 0.3s-second rand value
> > 0.45s-third rand value
> > ..........................
> > 14.45s-99-th rand value
> > 15s-100 rand value
> >
> > so, if i am doing in this way i will have a liniar time disturbance that's way i want 100 random values for this 15s
> >
> > thank you
> >
> > Artur
>
> Well then what's all this about "i want random values with sum 15" and "for this i need small randoms times?" Why must they have a sum of 15? What is "random times" about events that are spaced evenly apart by .15 seconds each? That was certainly misleading. It sounded just as though you wanted the total time spam of the 100 successive events to be 15 seconds but that the timing was otherwise random.
>
> Roger Stafford

yes Roger i have 100 successive events to generate in 15 seconds and i would like to have random times as i describe above

thanks

Subject: random values

From: Jonas Lundgren

Date: 27 May, 2010 10:56:05

Message: 10 of 11

"Artur Artur" <arturracu@yahoo.com> wrote in message <htlhfm$o5d$1@fred.mathworks.com>...
> "Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid> wrote in message <htl6qe$gfb$1@fred.mathworks.com>...
> > "Artur Artur" <arturracu@yahoo.com> wrote in message <htl2ce$2gk$1@fred.mathworks.com>...
> > > dear Roger,
> > >
> > > i'm sorry if i wasn' clear, this is not i want...so...i have 100 random values which i want to inject in a power system so i can disturb it, the time for this incident is 15 seconds, the way i am doing now is this:
> > > 0.15s-first rand value
> > > 0.3s-second rand value
> > > 0.45s-third rand value
> > > ..........................
> > > 14.45s-99-th rand value
> > > 15s-100 rand value
> > >
> > > so, if i am doing in this way i will have a liniar time disturbance that's way i want 100 random values for this 15s
> > >
> > > thank you
> > >
> > > Artur
> >
> > Well then what's all this about "i want random values with sum 15" and "for this i need small randoms times?" Why must they have a sum of 15? What is "random times" about events that are spaced evenly apart by .15 seconds each? That was certainly misleading. It sounded just as though you wanted the total time spam of the 100 successive events to be 15 seconds but that the timing was otherwise random.
> >
> > Roger Stafford
>
> yes Roger i have 100 successive events to generate in 15 seconds and i would like to have random times as i describe above
>
> thanks

Wy not 15*sort(rand(100,1)) ?
/Jonas

Subject: random values

From: Roger Stafford

Date: 27 May, 2010 22:06:03

Message: 11 of 11

"Jonas Lundgren" <jonas.lundgren@saabgroup.com> wrote in message <htlj45$b1j$1@fred.mathworks.com>...
> Wy not 15*sort(rand(100,1)) ?
> /Jonas

  Yes, that is the second of the two methods I mentioned earlier in the Wikipedia website at:

  http://en.wikipedia.org/wiki/Simplex

for uniform "simplex point picking", except that steps 1. and 4. below are not needed in this case.

Roger Stafford

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us