Dim NumSamples As Integer
Dim I As Integer
Set CurrentSheet = Application.ActiveSheet
Dim Row As Integer
Dim Column As Integer
Dim X As Double
Dim U As Double
Dim V As Double
Dim P As Double
Dim Q As Double
Dim R As Double
Dim Y As Double
Dim Mean As Double
Dim Variance As Double
Dim StdDev As Double
NumSamples = _
CInt(InputBox("Number
of Houses?", "Run Simulation"))
If (NumBulbs < 0) Then
NumBulbs = 0
End If
If (NumBulbs > 200) Then
NumBulbs = 200
End If
Mean = _
CDbl(InputBox("Mean
Price (in thousands of dollars)?", "Mean"))
StdDev = _
CDbl(InputBox("Standard
Deviation in Price (in thousands of dollars)?", "Standard Deviation"))
Variance = StdDev * StdDev
CurrentSheet.Cells(4, 2) = Mean
CurrentSheet.Cells(5, 2) = Variance
CurrentSheet.Cells(6, 2) = StdDev
Row = 0
Column = 0
Randomize
For I = 1 To NumSamples
Line1:
U = Rnd
V = Rnd
P = 2 * U - 1
Q = 2 * V - 1
R = P * P + Q * Q
If R > 1 Then GoTo Line1
Y = Sqr(-2 * Log(R)
/ R) * P
X = 500 * Int(2 * (Mean
+ StdDev * Y))
CurrentSheet.Cells(Row
+ 4, Column + 4) = X
Row = Row + 1
If (Row > 19) Then
Row = 0
Column = Column + 1
End If
Next I
End Sub