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
imad imadAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Martin LissOlder than dirtCommented:
This probably isn't the complete solution but it should give us a starting point. It assumes that the csv file data was imported into columns A to D. This macro which is included in the workbook generated the values in column F and the formulas in column G.

Sub Q28702695()

Dim lngLastRow As Long
Dim lngRow As Long
Dim lngExam As Long
Dim lngNR As Long


lngNR = 1
lngLastRow = Range("A1048576").End(xlUp).Row

For lngRow = 2 To lngLastRow
    Cells(lngNR, "F") = Cells(lngRow, "A")
    For lngExam = 2 To Cells(lngRow, "D")
        lngNR = lngNR + 1
        Cells(lngNR, "F") = lngExam
        Cells(lngNR, "G").Formula = "=NORMINV(RAND(),B" & lngRow & ",C" & lngRow & ")"
    Next
    lngNR = lngNR + 2
Next
End Sub

Open in new window

28702695.xlsm
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Fred MarshallPrincipalCommented:
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?:
=NORMINV(RAND(),WeightedAverage=3,WeightedStandardDev=1.2)  
It's not an Excel formula or even a set of them separated by commas.
So, what is it?  A specification?  Pretty slim specification.....
0
imad imadAuthor Commented:
@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)
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

imad imadAuthor Commented:
@Martin Liss  how can I add this macro using excel 2010 ?
0
Martin LissOlder than dirtCommented:
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.
0
Martin LissOlder than dirtCommented:
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Math / Science

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.