+ Reply to Thread
Results 1 to 8 of 8

Probability Distribution VBA function

  1. #1
    Registered User
    Join Date
    12-01-2011
    Location
    Ironton, Ohio
    MS-Off Ver
    Excel 2007
    Posts
    4

    Probability Distribution VBA function

    Hi, I am having a lot of trouble with this function code I am trying to complete. the basis of the function is: to draw a random number from a normal distribution with mean M and standard deviation S; then return the sum of these drawings that occurred N times. I am brand new to this so please bare with me. I have attempted the function, but got nowhere. Any help would be appreciated. Here is what I have so far: (most likely completely wrong)


    Please Login or Register  to view this content.
    Last edited by excelmaniac; 12-02-2011 at 04:50 PM.

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Help With VBA Function Code

    After you sort out you code tags and thread title, ...

    Assuming this is classwork, you need to back up a little bit. How do you intend to generate a normally-distributed random variable?
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Registered User
    Join Date
    12-01-2011
    Location
    Ironton, Ohio
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Probablility Distribution VBA function

    Well the code for the probability distribution would be something in the range of

    Please Login or Register  to view this content.
    but I cannot seem to figure out exactly how to go about adding the code to include the sum.

  4. #4
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Probability Distribution VBA function

    Declare a variable to accumulate the sum. In each iteration of the loop, add the new random variate to the sum.

  5. #5
    Registered User
    Join Date
    12-01-2011
    Location
    Ironton, Ohio
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Probability Distribution VBA function

    I tried working through your helpful steps. This is what I have so far, but it is still not working. I must be doing something wrong.

    Please Login or Register  to view this content.

  6. #6
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Probability Distribution VBA function

    Please Login or Register  to view this content.
    That's a literal string -- you want to pass variables to the function, right?

  7. #7
    Registered User
    Join Date
    12-01-2011
    Location
    Ironton, Ohio
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Probability Distribution VBA function

    Very true! I removed the parentheses and it seems to be giving me reasonable numbers, but I really can't think of a way to check it. Anyway, Thanks a lot!!!! I'll mark as solved.

  8. #8
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Probability Distribution VBA function

    The values returned for large N should be very close to N*M, right?
    Last edited by shg; 12-03-2011 at 12:50 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1