Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 23
Default Discrete random numbers into an array?

I'm using the analysis toolpack random function to generate a list of
randoms with a discrete probability
[Application.Run "ATPVBAEN.XLA!Random", ActiveSheet.Range("f30"), 1,
10000, 7, , ActiveSheet.Range("b25", "c54")]

When I try to get the output to go to an array however, it doesn't
work. I get an error saying something to the effect of macro " can't be
found. Does anyone know of a way to get the output of the random
function directly into an array?

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Discrete random numbers into an array?

it won't output directly to an array.

You will need to write your own generator.

--
Regards,
Tom Ogilvy


"festdaddy" wrote:

I'm using the analysis toolpack random function to generate a list of
randoms with a discrete probability
[Application.Run "ATPVBAEN.XLA!Random", ActiveSheet.Range("f30"), 1,
10000, 7, , ActiveSheet.Range("b25", "c54")]

When I try to get the output to go to an array however, it doesn't
work. I get an error saying something to the effect of macro " can't be
found. Does anyone know of a way to get the output of the random
function directly into an array?


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 837
Default Discrete random numbers into an array?

Use the VBA Rnd() function to roll your own. Unfortunately, VBA cannot call
the worksheet function RAND(), since in Excel 2003 or later it is a much
better random number generator than either Rnd() or the ATP Random function.

Jerry

"festdaddy" wrote:

I'm using the analysis toolpack random function to generate a list of
randoms with a discrete probability
[Application.Run "ATPVBAEN.XLA!Random", ActiveSheet.Range("f30"), 1,
10000, 7, , ActiveSheet.Range("b25", "c54")]

When I try to get the output to go to an array however, it doesn't
work. I get an error saying something to the effect of macro " can't be
found. Does anyone know of a way to get the output of the random
function directly into an array?


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 23
Default Discrete random numbers into an array?

Thanks all for your responses. Jerry, I'm not sure how I could use Rnd
to make a discrete distribution. Any suggestions would be appreciated.

Jerry W. Lewis wrote:
Use the VBA Rnd() function to roll your own. Unfortunately, VBA cannot call
the worksheet function RAND(), since in Excel 2003 or later it is a much
better random number generator than either Rnd() or the ATP Random function.

Jerry

"festdaddy" wrote:

I'm using the analysis toolpack random function to generate a list of
randoms with a discrete probability
[Application.Run "ATPVBAEN.XLA!Random", ActiveSheet.Range("f30"), 1,
10000, 7, , ActiveSheet.Range("b25", "c54")]

When I try to get the output to go to an array however, it doesn't
work. I get an error saying something to the effect of macro " can't be
found. Does anyone know of a way to get the output of the random
function directly into an array?



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 837
Default Discrete random numbers into an array?

Invert the cumulative probability function.

Suppose A1:B5 is the input range to the ATP Random function, then A1:A5 are
the possible values with with B1:B5 their probabilities of occurance
(SUM(B1:B5) should be 1). Instead of B1:B5, use C1:C5 where C5 contains the
formula =SUM(B$1:B5)which you copy/paste over the range
r=rnd
For i = 4 To 1 Step -1
If r Cell(i, 3) Then
rNum = Cell(i + 1, 1)
Exit For
End If
Next c
If i = 0 Then rNum = Cell(1, 1)

Jerry

"festdaddy" wrote:

Thanks all for your responses. Jerry, I'm not sure how I could use Rnd
to make a discrete distribution. Any suggestions would be appreciated.

Jerry W. Lewis wrote:
Use the VBA Rnd() function to roll your own. Unfortunately, VBA cannot call
the worksheet function RAND(), since in Excel 2003 or later it is a much
better random number generator than either Rnd() or the ATP Random function.

Jerry

"festdaddy" wrote:

I'm using the analysis toolpack random function to generate a list of
randoms with a discrete probability
[Application.Run "ATPVBAEN.XLA!Random", ActiveSheet.Range("f30"), 1,
10000, 7, , ActiveSheet.Range("b25", "c54")]

When I try to get the output to go to an array however, it doesn't
work. I get an error saying something to the effect of macro " can't be
found. Does anyone know of a way to get the output of the random
function directly into an array?




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Making a list of discrete numbers (names?) and occurences of each partsman_ba New Users to Excel 10 August 22nd 09 03:02 PM
Can Excel pick random numbers from 1-300 and not repeat numbers? Julian Excel Discussion (Misc queries) 1 June 7th 06 07:17 AM
Filling Array with uniqur random numbers Myles[_48_] Excel Programming 5 March 6th 06 10:13 AM
Non-random numbers generated by excel's data analysis random gener Allie Excel Worksheet Functions 10 September 17th 05 06:19 AM
Non-random numbers generated by excel's data analysis random gener Harlan Grove Excel Discussion (Misc queries) 2 September 13th 05 04:06 PM


All times are GMT +1. The time now is 12:24 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"