Absolute value of Normal distribution function (H(x)) using Excel

  • Thread starter Hard work and determination always wins
  • Start date
H

Hard work and determination always wins

Hi all,

I am new to this group and I want your help in clearing one of my queries in
evaluating Normal distribution value H(x) for multiple cells using Microsoft
excel VBA.

H(x) = NORMINV(RAND(),u(x),standard deviation(p(x) ).

The code that I am using up for generating H(x) in multiple cells for
multiple iterations is written below. Actually while

executing the code for multiple iterations I am getting negative values of
H(x) in some of the cells. I want to get the absolute values in all the
cells.



Sub Macro12()
For N = 1 To 100
ActiveCell.FormulaR1C1 = "=NORMINV(RAND(),R[-4]C,R[-4]C[4])"
Range("A5").Select
Selection.AutoFill Destination:=Range("A5:C5"), Type:=xlFillDefault
Range("A5:C5").Select
Selection.AutoFill Destination:=Range("A5:C7"), Type:=xlFillDefault
Range("A5:C7").Select
Calculate
Next N
End
End Sub



After executing the above code the values of H(x) that i am getting in
mutiple cells in excel is:

11.43882 21.64152 -0.3367
39.54251 19.52808 4.830327
19.66224 19.8019 7.046292




Please have a look and let me know how to get the absolute values of H(x) in
all the cells (no negative values). Do we need to modify my code to remove
the negative signs. Thanks for the help.



Thanks and Regards,

Subrat Kumar Swain.
 
G

Gary''s Student

Hi Hard work:

How about:

Sub Macro12()
For N = 1 To 100
s = "NORMINV(RAND(),R[-4]C,R[-4]C[4])"
ActiveCell.FormulaR1C1 = "=ABS(" & s & ")"
Range("A5").Select
Selection.AutoFill Destination:=Range("A5:C5"), Type:=xlFillDefault
Range("A5:C5").Select
Selection.AutoFill Destination:=Range("A5:C7"), Type:=xlFillDefault
Range("A5:C7").Select
Calculate
Next N
End
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top