From: Corey Adrian on 12 Jul 2010 12:59 I am trying to create a random number array given a minimum, maximum, and mean value. Is there any way to do this? Thanks, Corey
From: Steven Lord on 12 Jul 2010 13:11 "Corey Adrian" <uryguitarist777(a)yahoo.com> wrote in message news:i1fhko$rsc$1(a)fred.mathworks.com... >I am trying to create a random number array given a minimum, maximum, and >mean value. Is there any way to do this? Sure, just write a function that errors if the specified mean value is less than the specified minimum or greater than the specified maximum value and otherwise returns your mean value. http://dilbert.com/strips/comic/2001-10-25/ If you want your numbers distributed differently in the interval between your minimum and maximum than "centered at the mean value", you need to provide a description of your desired distribution. -- Steve Lord slord(a)mathworks.com comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ To contact Technical Support use the Contact Us link on http://www.mathworks.com
From: Roger Stafford on 12 Jul 2010 17:36 "Corey Adrian" <uryguitarist777(a)yahoo.com> wrote in message <i1fhko$rsc$1(a)fred.mathworks.com>... > I am trying to create a random number array given a minimum, maximum, and mean value. Is there any way to do this? > > Thanks, > Corey - - - - - - - - How about using the beta distribution? Let a = minimum, b = maximum, and c = mean. Of course, it is assumed that a < c < b here. Then do: x = a+(b-a)*betarnd((c-a)/(b-a),(b-c)*(b-a),m,n); to get an m by n array x of such random numbers. You can multiply the first two arguments of betarnd by any common factor to change the distribution's variance at your pleasure without affecting the mean. By making this factor very large you can approach Steven's interesting suggestion. Roger Stafford
From: Roger Stafford on 12 Jul 2010 17:40 Oops! I meant x = a+(b-a)*betarnd((c-a)/(b-a),(b-c)/(b-a),m,n); Roger Stafford
From: Corey Adrian on 12 Jul 2010 18:30 "Roger Stafford" <ellieandrogerxyzzy(a)mindspring.com.invalid> wrote in message <i1g240$rho$1(a)fred.mathworks.com>... > Oops! I meant > > x = a+(b-a)*betarnd((c-a)/(b-a),(b-c)/(b-a),m,n); > > Roger Stafford Thanks Roger that is exactly what I needed! Corey Adrian
|
Pages: 1 Prev: Orthorectification of an aerial image Next: Struct command Problem |