       • To: mathgroup at smc.vnet.net
• From: "mike" <mike at hus.parkingspa.com>
• Date: Fri, 2 Jun 2006 04:09:12 -0400 (EDT)
• References: <e1ijuv\$3oh\$1@smc.vnet.net>
• Sender: owner-wri-mathgroup at wolfram.com

```"rjmachado3" <rjmachado3 at portugalmail.pt> wrote in message
news:e1ijuv\$3oh\$1 at smc.vnet.net...
>I need to know the formula for the random function that return random
> numbers in a range of a and b integers [a,b] but that obey on a custom
> probability (possibly different!) for each integer number on this [a,b]
> range (of course the sum of all integer number probabilities are = 1!).
> Finally, what i want is the general function formula that simulate the
> random behavior (based on a custom probability value for each integer
>
> what i know so far is that the function formula for generating a "pure"
> random number between [a,b] range is:
>
> rand()*(b-a)+a
>
> where rand() return a random number between 0 and 1.
>
>

If I understand your problem correctly it is similar to one I have had to
solve.

I have a vector with over 15 million integers in the range of -3500 to +
3300.  Zero and +1 and -1 occur more often than +/- 2 which are more
frequent than +/- 3 etc.   However some integers occur much more frequently
than the next smaller value and there is no known function defining the
frequency of all integers.

I need to be able to randomly generate arbitrary numbers of additional
integers with the same frequency as found in the original vector.

I solved this by simply using the built-in random function to generate an
index into the original vector and returned what ever value was found.

I hope this helps.

Mike Sicilian

```

• Prev by Date: Re: Problem with Limit
• Next by Date: Re: Homotopic algorithm to solve a system of equations
• Previous by thread: Re: how to iterate
• Next by thread: Re: Memory Leak