Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default VBA module/function to generate random numbers with specified mean and SD

Hi all,

As basis for a school assignment I need to generate 20 random numbers that
have a prespecified mean and standard deviation ( I don't believe they have
to be normally distrubted).

Can anyone help?

The output would preferably be to Worksheets("Sheet1").Range("A1:A20")
though an array would also work.

Thanks.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default VBA module/function to generate random numbers with specified mean and SD

BTW - the generated numbers have to be = 0 (positive numbers)


"Robert Reid" wrote in message
...
Hi all,

As basis for a school assignment I need to generate 20 random numbers that
have a prespecified mean and standard deviation ( I don't believe they
have to be normally distrubted).

Can anyone help?

The output would preferably be to Worksheets("Sheet1").Range("A1:A20")
though an array would also work.

Thanks.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default VBA module/function to generate random numbers with specified mean and SD

Robert Reid -

=NORMINV(RAND(),mean,stdev)

Caveat: Both NormInv and Rand may return numerically inaccurate results in
pre-2003 Excel.

- Mike
www.mikemiddleton.com


"Robert Reid" wrote in message
...
Hi all,

As basis for a school assignment I need to generate 20 random numbers that
have a prespecified mean and standard deviation ( I don't believe they
have to be normally distrubted).

Can anyone help?

The output would preferably be to Worksheets("Sheet1").Range("A1:A20")
though an array would also work.

Thanks.



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default VBA module/function to generate random numbers with specified mean and SD

Thanks for the response Mike,

I'm not sure how I would use the excel function to generate 20 numbers that
have a prespecified SD and mean using VBA.

Can you clarify.

"Mike Middleton" wrote in message
...
Robert Reid -

=NORMINV(RAND(),mean,stdev)

Caveat: Both NormInv and Rand may return numerically inaccurate results in
pre-2003 Excel.

- Mike
www.mikemiddleton.com


"Robert Reid" wrote in message
...
Hi all,

As basis for a school assignment I need to generate 20 random numbers
that have a prespecified mean and standard deviation ( I don't believe
they have to be normally distrubted).

Can anyone help?

The output would preferably be to Worksheets("Sheet1").Range("A1:A20")
though an array would also work.

Thanks.





  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default VBA module/function to generate random numbers with specified mean and SD

Robert Reid -

The worksheet functions =NORMINV(RAND(),mean,stdev) with appropriate
numerical values for mean and stdev entered in worksheet cells will generate
such numbers.

If for some reason you must use VBA, either (1) write VBA code that enters
the above into cells or (2) write VBA code with
Application.WorksheetFunction.NormInv and VBA's RND function to generate the
values and then write VBA code to insert the values into worksheet cells.

- Mike

"Robert Reid" wrote in message
...
Thanks for the response Mike,

I'm not sure how I would use the excel function to generate 20 numbers
that have a prespecified SD and mean using VBA.

Can you clarify.

"Mike Middleton" wrote in message
...
Robert Reid -

=NORMINV(RAND(),mean,stdev)

Caveat: Both NormInv and Rand may return numerically inaccurate results
in pre-2003 Excel.

- Mike
www.mikemiddleton.com


"Robert Reid" wrote in message
...
Hi all,

As basis for a school assignment I need to generate 20 random numbers
that have a prespecified mean and standard deviation ( I don't believe
they have to be normally distrubted).

Can anyone help?

The output would preferably be to Worksheets("Sheet1").Range("A1:A20")
though an array would also work.

Thanks.









  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default VBA module/function to generate random numbers with specified mean and SD


With Worksheets("Sheet1").Range("A1:A20")
.formula = "=NORMINV(RAND(),150,10)"
.Formula = .Value
End With

--
Regards,
Tom Ogilvy




"Robert Reid" wrote in message
...
Thanks for the response Mike,

I'm not sure how I would use the excel function to generate 20 numbers

that
have a prespecified SD and mean using VBA.

Can you clarify.

"Mike Middleton" wrote in message
...
Robert Reid -

=NORMINV(RAND(),mean,stdev)

Caveat: Both NormInv and Rand may return numerically inaccurate results

in
pre-2003 Excel.

- Mike
www.mikemiddleton.com


"Robert Reid" wrote in message
...
Hi all,

As basis for a school assignment I need to generate 20 random numbers
that have a prespecified mean and standard deviation ( I don't believe
they have to be normally distrubted).

Can anyone help?

The output would preferably be to Worksheets("Sheet1").Range("A1:A20")
though an array would also work.

Thanks.







  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default VBA module/function to generate random numbers with specified mean and SD

Thanks to you all.


"Robert Reid" wrote in message
...
Thanks for the response Mike,

I'm not sure how I would use the excel function to generate 20 numbers
that have a prespecified SD and mean using VBA.

Can you clarify.

"Mike Middleton" wrote in message
...
Robert Reid -

=NORMINV(RAND(),mean,stdev)

Caveat: Both NormInv and Rand may return numerically inaccurate results
in pre-2003 Excel.

- Mike
www.mikemiddleton.com


"Robert Reid" wrote in message
...
Hi all,

As basis for a school assignment I need to generate 20 random numbers
that have a prespecified mean and standard deviation ( I don't believe
they have to be normally distrubted).

Can anyone help?

The output would preferably be to Worksheets("Sheet1").Range("A1:A20")
though an array would also work.

Thanks.







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
Generate random numbers cawhitaker Excel Discussion (Misc queries) 3 September 27th 07 09:01 PM
Generate Random numbers from a pre-defined set frankjh19701 Excel Worksheet Functions 0 January 11th 07 05:20 PM
generate a random number and use if function to generate new data Dogdoc1142 Excel Worksheet Functions 4 April 26th 06 03:44 AM
Generate random numbers between two values and with a given mean pinosan Excel Worksheet Functions 2 March 7th 05 02:04 PM
generate random numbers Jules Excel Worksheet Functions 6 November 2nd 04 05:57 PM


All times are GMT +1. The time now is 10:54 PM.

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"