Re: Solution from Reduce as boundaries for Distribution
- To: mathgroup at smc.vnet.net
- Subject: [mg60025] Re: Solution from Reduce as boundaries for Distribution
- From: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>
- Date: Sun, 28 Aug 2005 23:14:36 -0400 (EDT)
- Organization: The Open University, Milton Keynes, U.K.
- References: <dernnq$s1o$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
On 8/28/05, Kristoph Steikert <kristophs.post at web.de> wrote: > > > not exactly, because I ´have to do more than 10.000 calculations for different equations I'm looking for a less time consuming way. > > I just need, the lower bound (1/16) and the upper bound (9/16) als values so I can proceed the data automaticly. So the probelm remains, solving the equation (Reduce[...]) and use the solution as an upper and lower bound for further calculations. > > thanks for help > > kristoph Hi Kristoph, I hope that, this time, I have understood correctly what you want to do :-) First, we load the package that contains *UniformDistribution*, write the expression to be solved and solve it using *Reduce*. In[1]:= Needs["Statistics`ContinuousDistributions`"] In[2]:= expr = 15/16 + x - Mod[15/16 + x, 1/2] == 1 Out[2]= 15/16 + x - Mod[15/16 + x, 1/2] == 1 In[3]:= sol = Reduce[expr && 0 <= x <= 1, x] Out[3]= Inequality[1/16, LessEqual, x, Less, 9/16] Then, we change the head of the above expression *Inequality* by the head *List* thanks to the function *Apply* (shorthand: @@ ) In[4]:= List @@ sol Out[4]= {1/16, LessEqual, x, Less, 9/16} Now that we have a plain list, we can select some of its elements, say whatever is a number, by the mean of the function *Select* In[5]:= bnds = Select[List @@ sol, NumberQ] Out[5]= {1/16, 9/16} Finally, we can use the lower and upper bounds as below: In[6]:= data = RandomArray[UniformDistribution[bnds[[1]], bnds[[2]]], 10] Out[6]= {0.326131,0.138645,0.258452,0.0687888,0.271912,0.236189,0.223916,0.468673,0.\ 316609,0.280229} Hope this helps this time! /J.M.