From: Susan on 10 Mar 2010 14:34 I have created a simple system which generates 2 random numbers that always add to 1. I did this by using 2 uniform random number generators and an adder which sums the results together. I took the sum and ran it into 2 dividers so that each divider was dividing the original random number by the sum of the 2 random numbers to get 2 random numbers that add to one. I hooked a scope up to the dividers and realized I was not getting a single random number. This random number generator is a subsystem of a bigger system which can only use 1 value. I'm wondering if the random number generator is the wrong block. It seems the only thing I can change is the range of numbers, seed and sample time. Can anyone help me with this?
From: dpb on 10 Mar 2010 14:45 Susan wrote: > I have created a simple system which generates 2 random numbers that > always add to 1. I did this by using 2 uniform random number generators > and an adder which sums the results together. I took the sum and ran it > into 2 dividers so that each divider was dividing the original random > number by the sum of the 2 random numbers to get 2 random numbers that > add to one. I hooked a scope up to the dividers and realized I was not > getting a single random number. This random number generator is a > subsystem of a bigger system which can only use 1 value. I'm wondering > if the random number generator is the wrong block. It seems the only > thing I can change is the range of numbers, seed and sample time. > > Can anyone help me with this? Why not simply take the first rnv and generate the second by subtracting the first from one? I don't follow the problem as stated in "and realized I was not getting a single random number". What, specifically, does that mean? Think need more detail if above suggestion doesn't suit. Actually, I think I realize I don't understand what the actual desired result is when combine first sentence and the statement about the larger system of which this is a subsystem.... --
From: Susan on 10 Mar 2010 15:40 > > > > Can anyone help me with this? > > Why not simply take the first rnv and generate the second by subtracting > the first from one? > > > I don't follow the problem as stated in "and realized I was not getting > a single random number". What, specifically, does that mean? > > Think need more detail if above suggestion doesn't suit. > > Actually, I think I realize I don't understand what the actual desired > result is when combine first sentence and the statement about the larger > system of which this is a subsystem.... > > -- > a single random number". What, specifically, does that mean? > > Think need more detail if above suggestion doesn't suit. > > Actually, I think I realize I don't understand what the actual desired > result is when combine first sentence and the statement about the larger > system of which this is a subsystem.... I actually have 4 random number generators so simple subtraction will not work. I was trying a simpler version first to get it to work. I connected a display to the output of each divider and the final number generated for each divider adds to one. I want the random number to be constant over the sampling time. The random number generator changes values over the sampling time. Ignore the part about the subsystem, it is not important.
From: John D'Errico on 10 Mar 2010 17:22 "Susan " <susanreneemueller(a)gmail.com> wrote in message <hn903k$8l6$1(a)fred.mathworks.com>... > I actually have 4 random number generators so simple subtraction will not work. I was trying a simpler version first to get it to work. I connected a display to the output of each divider and the final number generated for each divider adds to one. > > I want the random number to be constant over the sampling time. The random number generator changes values over the sampling time. > So why not tell us from the start what your problem is? Scaling the total by dividing by the sum is not a good way to generate uniform random numbers subject to a constraint. In fact, they won't have a true uniform distribution. You can download randfixedsum from the file exchange to give you the result you desire. http://www.mathworks.com/matlabcentral/fileexchange/9700-random-vectors-with-fixed-sum John
From: Susan on 10 Mar 2010 19:19 What I'm doing is kind of hard to explain, but I'll try. I have 4 air chambers, 4 solenoid valves, and 4 sensors. I'm modeling each chamber, valve, and sensor as an independent system so a total of 4 subsystems. Each subsystem has a chamber, pressure sensor, and a solenoid valve. Each of the 4 subsystems is modeled as a transfer function. The 4 transfer functions are run in parallel b/c they can be inflated and deflated without affecting each other. The 4 subsystems each share the air from 1 pump. These chambers are independent of each other and at any given time have varying ratios of there actually pressure to their desired pressure set in the software that determines when to open and close a solenoid valve. Let's assume for now that the desired pressure for each chamber is the same: 1 psi. The air from the pump runs to a manifold where all the solenoids are located. So if all the chambers are less than their desired pressure at any given point in time, all the solenoids will be open. However in my model it is not accurate to assume each chamber is getting 1/4 of the air from the pump b/c the air will travel the path of least resistance. Here's where the random number come into play. I want to model a random percentage of 1 based on the "worst" case situation that all solenoids are open at the same time. I know there are some inaccuracies with this model: as the pressure fills in one chamber the percentage of the total amount of air will not be constant. I'm ignoring this issue and others for now. I don't want as much critique on the process as I on how to generate a single random value which will be constant for the entire simulation time. So instead of a ramp input or step input which would evenly divide the air 4 ways, I'm trying to generate a random number 0 and 1(I don't care if it's uniform) my adder and divider accurately create 4 random numbers that add to 1. So all this to ask just one simple question. Let's assume I just want to run a random number into a scope that will be the same random number for 10 seconds. Can I do this? I know how to do the rest. Thanks for the help.
|
Next
|
Last
Pages: 1 2 Prev: Resample Data to Match X-values Next: Sliding window implementation and exceer variable size |