Typen Unverträglichkeit
06.06.2015 05:45:34
Fabian
bin gerade dabei die Schnittmenge von zwei Verteilungen zu approximieren. Leider wird mir als Fehler eine Typenunverträglichkeit (Variablen i, j) angezeigt. Bei anderen Verteilungen funktioniert es bereits. Nachdem zuerst ein ByRef Fehler kam, habe ich vor die betroffenen Variablen ein ByVal geschrieben. Leider finde ich keinen Fehler. Ich hoffe ihr könnt mir helfen.
Sub main()
Dim s(2) As Double
s(1) = 100
s(2) = 101
MsgBox TriSchnittmenge(80, 20, 69, 80, 101, s)
End Sub
Function TriSchnittmenge(mittelwert As Double, standardabw As Double, min As Double, most As _
Double, tmax As Double, VorperiodeDaten() As Double) As Double
Dim z As Double
Dim step As Double
Dim max As Double
max = WorksheetFunction.max(VorperiodeDaten)
step = 1
i = min
z = 0
Do Until (i > max)
If WorksheetFunction.Norm_Dist(ByVal i, mittelwert, standardabw, False) >= TriDist(ByVal i, _
_
min, most, tmax, False) Then
For j = i To max
If WorksheetFunction.Norm_Dist(ByVal j, mittelwert, standardabw, False) max - step Or 0 = TriDist(ByVal j, min, most, tmax, _
False) Or 0 = WorksheetFunction.Norm_Dist(ByVal j, mittelwert, standardabw, False) Then
If z = 0 Then
j = j - step
x = TriDist(ByVal j, min, most, tmax, True)
i = j
Exit For
Else
j = j - step
x = x + TriDist(ByVal j, min, most, tmax, True) - TriDist(z, min, most, _
tmax, True)
i = j
Exit For
End If
End If
Next j
Else
For j = i To max
If WorksheetFunction.Norm_Dist(ByVal j, mittelwert, standardabw, False) >= TriDist( _
_
ByVal j, min, most, tmax, False) Or j > max - step Or 0 = TriDist(ByVal j, min, most, tmax, _
False) Or 0 = WorksheetFunction.Norm_Dist(ByVal j, mittelwert, standardabw, False) Then
j = j - step
x = x + WorksheetFunction.Norm_Dist(ByVal j, mittelwert, standardabw, True) - _
_
WorksheetFunction.Norm_Dist(z, mittelwert, standardabw, True)
i = j
Exit For
End If
Next j
End If
z = i
i = i + step
If i > max Then
Exit Do
End If
Loop
TriSchnittmenge = x
End Function
Function TriDist(x As Double, min As Double, most As Double, max As Double, kum As Boolean) As _
_
Double
Dim k As Integer
Dim result As Double
If kum = True Then
For k = min To x
If min