Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2006
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2006

[Date Index] [Thread Index] [Author Index]

Search the Archive

Random numbers according to a rule / function

  • To: mathgroup at smc.vnet.net
  • Subject: [mg68933] Random numbers according to a rule / function
  • From: "bd satish" <bdsatish at gmail.com>
  • Date: Wed, 23 Aug 2006 04:41:38 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

Hi buddies ,

               I want to write a module / program that generates random
numbers according to some rule (or function).

Say , "A number that is divisible by 13 & 19" or "A prime number whose sum
of digits is exactly 10" , etc.

Let me call this module as RandomRule[ f ].   Everytime I evaluate this
function , I must get a number 'x' such that f [x] is True.

For different invokes , RandomRule[ f ] must give different values.  There
are no restrictions on the function ' f ' .

For simplicity, let ' x '  be an integer.

            This is what I tried :

"A number that is divisible by 13 and 19"

     I put the command

              (Mod [ # , 14 ] == 0  &&  Mod[ # , 19 ] ==0  )&
Random[Integer,{100,1000}]

 in a Do loop until the above statement returns True. And returned the value
of Random[Integer,{100,1000}]
that made this statement True.

 My problem is , how can I generalize this to include ANY function ' f ' ?


  • Prev by Date: Re: reading all the files in one directory
  • Next by Date: pattern match and formatting challenge
  • Previous by thread: Re: Graph inside another graph
  • Next by thread: Re: Random numbers according to a rule / function