Link to home
Create AccountLog in
Avatar of imad imad
imad imad

asked on

Produce random number using normal distribution

I have a csv File that looks like :
subjects,       WeightedAverage,     WeightedStandardDev,    NumberofExams,
MathMark,              1.5,                 0.2,                   5,
PhysicMark,            1.6,                 0.4,                  10,
EnglishMark,            3,                  1.2,                  8,
PhiloMark,             8.2,                 1.5,                  9,
Others                 9.2,                 3.2,                  5,   

Open in new window

I have another file where I need to generate data this way for each subject above :

For example for the subject MathMark the corresponding table should be :

NumberofExams                                     Mark                                                                              1                         =NORMINV(RAND(),WeightedAverage=1.5,WeightedStandardDev=0.2)
2                         =NORMINV(RAND(),WeightedAverage=1.5,WeightedStandardDev=0.2)
3                         =NORMINV(RAND(),WeightedAverage=1.5,WeightedStandardDev=0.2)
4                         =NORMINV(RAND(),WeightedAverage=1.5,WeightedStandardDev=0.2)
5                         =NORMINV(RAND(),WeightedAverage=1.5,WeightedStandardDev=0.2)

Open in new window

For example for the subject EnglishMark the corresponding table should be :

NumberofExams                                   Mark                                                                                            
1                          =NORMINV(RAND(),WeightedAverage=3,WeightedStandardDev=1.2)                                                2                           =NORMINV(RAND(),WeightedAverage=3,WeightedStandardDev=1.2)                                              3                          =NORMINV(RAND(),WeightedAverage=3,WeightedStandardDev=1.2)                               
4                          =NORMINV(RAND(),WeightedAverage=3,WeightedStandardDev=1.2)                                  
5                          =NORMINV(RAND(),WeightedAverage=3,WeightedStandardDev=1.2)             
6                          =NORMINV(RAND(),WeightedAverage=3,WeightedStandardDev=1.2)   
7                          =NORMINV(RAND(),WeightedAverage=3,WeightedStandardDev=1.2)
8                          =NORMINV(RAND(),WeightedAverage=3,WeightedStandardDev=1.2)

Open in new window

want to produce NumberofExams random numbers with normal distribution (with WeightedAverage, WeightedStandardDev) . How can I get these informations from another csv and calculate the wanted random numbers in Excel . Any formula or Macro is welcomed
Avatar of Martin Liss
Martin Liss
Flag of United States of America image

Link to home
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
I'm sorry but I don't follow your presentation of the problem or the objective.
It appears to be Excel but it isn't.   Perhaps it's just a bit too terse.

For example:
What is this?:
It's not an Excel formula or even a set of them separated by commas.
So, what is it?  A specification?  Pretty slim specification.....
Avatar of imad imad
imad imad


@Fred Marshall YEAH IT S just a specification not a correct a formula , a way to generate a random value depending on a normal distribution of a couple of <average,stdev> that should be extracted from other file (csv)
@Martin Liss  how can I add this macro using excel 2010 ?
In Excel, Press Alt+F11 to open the Visual Basic Editor (VBE)

Right-click on your workbook name in the "Project-VBAProject" pane (at the top left corner of the editor window). If you don’t see an existing module then select Insert -> Module from the context menu. Otherwise just select the module.

Copy the macro (you can use the ‘Select All’ button if you like) and paste it into the right-hand pane of the VBA editor ("Module1" window)

Press Alt+F11 again to go back to Excel

Optionally, press Alt+F8 to open the "Macro" dialog window. Select the macro, click ‘Options…’,  hold down the Shift key and type the letter A (or any other letter) and click ‘OK’. Then anytime you want to run the macro press Ctrl+Shift+A.

When you close the workbook you will need to save it as an xlsm or xls file if it’s not already one of those.
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.