+ Reply to Thread
Results 1 to 12 of 12

simulation to pick from normal distribution

  1. #1
    Registered User
    Join Date
    02-20-2018
    Location
    wales
    MS-Off Ver
    ms office 365 subscription
    Posts
    92

    simulation to pick from normal distribution

    hi. I am having trouble incorporating results from a normal distribution into a simulation. I:4 is correctly using a random number from a normal distribution with the mean from E:4 and sd from A:6. in my simulation the trouble is it is currently using the same number for every simulation instead of a random one each time. if the page is refreshed the number changes but it is still that same number in every simulation. would the way to go be to make a data set like i started in d:15? any help to solve this would be great
    thanks
    Attached Files Attached Files

  2. #2
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,819

    Re: simulation to pick from normal distribution

    I'm not sure I understand the question. When I open your file, I can press F9, which generates new random numbers for I4:I7 and in D15:D58. I don't know what you mean by "refreshing" the page or what constitutes a single simulation, but it looks like it is working just fine to me. I am not familiar with office 365, so maybe there is something different in the way 365 handles these volatile functions (I am not aware of any differences)? Or perhaps it is just knowing how to trigger Excel to recalculate the worksheet (because the RAND() function should generate a new number every time the worksheet is calculated)?
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  3. #3
    Registered User
    Join Date
    02-20-2018
    Location
    wales
    MS-Off Ver
    ms office 365 subscription
    Posts
    92

    Re: simulation to pick from normal distribution

    hi shorty. thanks for quick reply. i added some new cells K4:L8 to hopefully make it more clear. i realize its not a proper sim yet but hopefully it explains better. you can see L4:L8 all have the same number, and when i refresh they all change. my goal to have them as 5 different numbers(5 random numbers from the distribution) not the same number 5 times. eventually the sim will be more complex but i just wanted to learn how to do this first.
    Attached Files Attached Files

  4. #4
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,819

    Re: simulation to pick from normal distribution

    L4:L8 all contain the formula =I4, so I am not at all surprised that they all contain the same number. What I don't understand is, if you want 5 different random numbers, why you don't have =NORMINV(RAND(),$E$4,$A$6) in L4:L8? That's what I would have expected. Or maybe =NORMINV(RAND(),$E4,$A$6) in L4, copy across to P4 (to get 5 simulations for dave), then copy down to get 5 random numbers for each of dom, Eric, and Elias. In the end, if you want 5 copies of the same random number, then you use something like =I4 like you have now. If you want 5 different random numbers, you have a separate RAND() function for each random number.

  5. #5
    Registered User
    Join Date
    02-20-2018
    Location
    wales
    MS-Off Ver
    ms office 365 subscription
    Posts
    92

    Re: simulation to pick from normal distribution

    this is the spreadsheet my question was hoping to help. on sheet 2 column c if we look under dave. it is selecting scores from E4: P4. under dave im getting the same scores over and over. the same 12 results for all 1000 rows. on the snip we can see 86 being used for every sim but i want it to be a different number from the distribution each time. hopefully i haven't just gone and confused things
    Attached Images Attached Images
    Attached Files Attached Files

  6. #6
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,819

    Re: simulation to pick from normal distribution

    I am not sure what you intend to do. Here's what I see (if you are unfamiliar with the evaluate formula tool, you might follow along in your own copy of Excel: https://support.office.com/en-us/art...6-a70aa409b8a7 ):

    =INDEX(
    range argument for INDEX() (looks okay): PointsTable[[wins pts]:[loses r5]],
    row# argument (looks okay): MATCH(C$1,PointsTable[name],0),
    column# argument (looks okay here, but problem in sheet1): MATCH(B2,OFFSET(HelperProb[[#Headers],[winspts]],MATCH(C$1,HelperProb[name],0),0,1,12)))

    add the same small fraction to each entry for some reason: +0.000001*COLUMN()

    The problem I see with the column# argument is that, for dave and dom, the lookup range returned by the OFFSET() function (AJ4:AU4) is all 0's. The MATCH() function here is set to use a binary search. The random number being used for the lookup value will always (or almost always) be greater than 0, so this lookup always returns the last column # in the search range. So, for dave and dom, this will always return the same value from the range argument. I'm not sure what you intend to be happening here, but it looks like you need to figure out why sheet1!AJ4:AU4 is all 0s rather than a set of increasing values (looks like it should go from 0 to 1).

    The final part of the function, that adds a small fraction to each entry, seems to be an attempt to make sure each entry is unique. Your source table only has 12 values, so it is inevitable that you will get some duplicate values returned from the table. However, for a given name, the column is the same all the way down, so this will always add the same fraction. I wonder if you intended to use ROW() instead of column so that this will add a unique value to each entry under a given name.

    I have not gone through it in more detail than that.

  7. #7
    Registered User
    Join Date
    02-20-2018
    Location
    wales
    MS-Off Ver
    ms office 365 subscription
    Posts
    92

    Re: simulation to pick from normal distribution

    ah really sorry. all those 0 were not meant to be there. i thought i had changed them back. but yes having 0 probability in cells U4:AF4 results in the same number due to that like you mentioned. i have put the probabilities back in there now and i get the same 12 numbers from the source table over and over again. with the probabilities put back in dave has 12% chance to win r2. so over 1000 rows on sheet 2 im currently getting g4 in the results approx 120 times. rather than get the same number 120 times i want 120 different numbers normally distributed around the mean. the means for the source table are in the table below. the snip for example shows 86 multiple times. instead of the 86 result 120 times im after 120 different results which are normally distributed around a mean of 86. thanks for taking the time to look and apologies again for making it more confusing than it needed to be with the 0 for probabilities left in
    Attached Files Attached Files

  8. #8
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,819

    Re: simulation to pick from normal distribution

    I am not sure what you are trying to do here. The algorithm as I see it right now:

    1) Make a collection of 12 random numbers for each name on sheet1 -- along with some other stuff necessary for selecting one of these 12 random numbers.
    2) On sheet 2, feed a random number into a lookup function to randomly return one of the 12 random numbers computed on sheet1.
    3) Repeat step 2 multiple times to perform the simulation. Of course, with only 12 random numbers to choose from, it is inevitable that there will be some duplicate results.

    At this point I am not sure what to recommend, because I am not sure what is supposed to be happening between sheet1 and sheet2. Clearly the random numbers on sheet 1 are supposed to figure into the random numbers generated on sheet2, but it is not clear to me what you intend. It seems clear that "randomly choose one of the 12 numbers" is not what you want. If you can help us understand what you are trying to do when you generate a random number on sheet2 from the random numbers in sheet1, we should be able to help you program that into Excel.

    On edit: After a little more looking, is step 2 supposed to be:
    2a) Randomly choose a mean from the 12 means in row 21 (for dave) of sheet1.
    2b) Choose a random normal from that randomly chosen mean and a standard deviation of 10 (=NORMINV($B2,formula to randomly choose mean similar to current formula,10)
    Trying this in your sheet, I get all unique numbers for dave in sheet2 column2. Your number formatting is set to display to the nearest integer, so it looks like some of the numbers are duplicates, but they are not exactly the same number.
    Last edited by MrShorty; 05-09-2018 at 11:50 AM.

  9. #9
    Registered User
    Join Date
    02-20-2018
    Location
    wales
    MS-Off Ver
    ms office 365 subscription
    Posts
    92

    Re: simulation to pick from normal distribution

    hi shorty. i think what you said on edit is correct. i will explain the sheet in more detail.

    sheet 1, S1:AF13 we have 5 contests. Dave v dom, Eric v Elias etc. this table shows the probability of the outcomes. we are using rand i believe with the helper table to pick the result of each contest.

    if the result selected was dave wins r1. the result also has to be dom loses r1. now we go look to the scores in the table at C:20. this is a table of the mean scores expected the the result. so for the result above of Dave wins r1 and dom losing r1 we have 111 and 5 as the respective mean scores. now on sheet 3 rather than 111 and 5 appear in sim 1 i was after a normally distributed random number around those means instead. in sim 2 i want another random number around the means that were picked. currently every time Dave wins r1 is chosen in the simulation im getting the same random number. i need a different one every time Dave wins r1.

    anyways. i think this i what you said but i thought a bit more background info about the numbers couldn't hurt.

  10. #10
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,819

    Re: simulation to pick from normal distribution

    Try this:

    1) In sheet1, copy E21:P30 and paste over E4:P13
    2) In sheet2, edit C2 to make this a random normal based on returned mean: =NORMINV(B2,current formula in C2,10). If desired use a cell reference instead of the hardcoded 10 for the standard deviation argument.
    3) copy C2 and paste over the rest of column C.
    4) Evaluate results to see if this is what you are trying to do with dave's column.
    5) If that works closer to correctly, then I would expect dom's column in sheet2 to be the same change =NORMINV(B2,current formula in D2,10).

    Is that getting closer?

  11. #11
    Registered User
    Join Date
    02-20-2018
    Location
    wales
    MS-Off Ver
    ms office 365 subscription
    Posts
    92

    Re: simulation to pick from normal distribution

    it was really close. i think i have it now from using your formula. i made one change that seems to work and im hoping doesn't alter anything. i had to use a different rand for both fighters as they were getting matching results using the same. for example dave scores 109 pts dom would score 36. dom would score 36 everytime dave scored 109. swapping to 2 different rands has solved that i think.

    thanks for coming up with a solution. has really helped me out.

  12. #12
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,819

    Re: simulation to pick from normal distribution

    I am glad that is working out.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Poisson distribution - simulation
    By Hjahren in forum Excel Programming / VBA / Macros
    Replies: 22
    Last Post: 08-14-2021, 09:09 AM
  2. Replies: 14
    Last Post: 11-19-2019, 09:17 AM
  3. ways to determine a normal or log normal distribution in excel
    By aprildu in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 10-29-2016, 06:32 PM
  4. Monte Carlo Simulation with skewed distribution
    By alleco in forum Excel Programming / VBA / Macros
    Replies: 24
    Last Post: 12-20-2015, 07:37 PM
  5. Replies: 9
    Last Post: 07-24-2015, 03:40 PM
  6. Log-Normal Simulation
    By Sam_BB in forum Excel General
    Replies: 1
    Last Post: 06-01-2011, 01:20 PM
  7. Replies: 5
    Last Post: 01-31-2011, 12:21 AM

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