I'm testing different parametrization of the CDF of the logistic function and comparing the results and the effect on the curve of the different parameters.
using Distributions
# Vector of x to test the different functions
x = collect(0:20)
Logis = Logistic(10, 1) # PDF of Logistic function in Julia
y = cdf(Logis, x) # CDF of Logistic function in Julia
# This is a standard representation of the CDF for Logistic
LogisticV1(x, μ=10, θ=1) = 1 / ( 1 + e^-((x-μ)/θ))
y1 = LogisticV1.(x)
# This is another representation of the CDF for Logistic
LogisticV2(x, μ=10, θ=1) = 1/2 + 1/2 * tanh((x-μ)/2*θ)
y2 = LogisticV2.(x)
The plots of all three functions are identical, as expected. The type of all three y vectors is also the same (Array{Float64,1}) and the three y vectors also appear to be identical.
show(y)
[4.53979e-5, 0.000123395, 0.00033535, 0.000911051, 0.00247262, 0.00669285, 0.0179862, 0.0474259, 0.119203, 0.268941, 0.5, 0.731059, 0.880797, 0.952574, 0.982014, 0.993307, 0.997527, 0.999089, 0.999665, 0.999877, 0.999955]
show(y1)
[4.53979e-5, 0.000123395, 0.00033535, 0.000911051, 0.00247262, 0.00669285, 0.0179862, 0.0474259, 0.119203, 0.268941, 0.5, 0.731059, 0.880797, 0.952574, 0.982014, 0.993307, 0.997527, 0.999089, 0.999665, 0.999877, 0.999955]
show(y2)
[4.53979e-5, 0.000123395, 0.00033535, 0.000911051, 0.00247262, 0.00669285, 0.0179862, 0.0474259, 0.119203, 0.268941, 0.5, 0.731059, 0.880797, 0.952574, 0.982014, 0.993307, 0.997527, 0.999089, 0.999665, 0.999877, 0.999955]
However:
y == y1 # true
y == y2 # false
y1 == y2 # false
Why is this happening? I assume this has something to do with floating point variations introduced by the tanh function in LogisticV2, but I'm not sure. I appreciate any insight into this.
EDIT: Fixed some typos to make code runnable