In [1]:
using Distributions
using Plots
d = Bernoulli(1/3)
nmax, ntrials = 2^10, 5
n = 1:nmax
a = cumsum(rand(d, nmax, ntrials))./n
y = -(a*log(d.p) + (1-a)*log(1-d.p))
plot(y)
Out[1]:
200 400 600 800 1000 0.5 0.6 0.7 0.8 0.9 1.0 y1 y2 y3 y4 y5
In [2]:
using Distributions
using Plots
gr()
ENV["PLOTS_TEST"] = "true"

d = Bernoulli(1/3)
@show S = entropy(d)
@show sum(-pdf(d,k)*logpdf(d,k) for k in support(d))

srand(4)
nmax, ntrials = 2^10, 5
n = 1:nmax
a = cumsum(rand(d, nmax, ntrials))./n
y = -(a*log(d.p) + (1 - a)*log(1 - d.p))

p = plot(size=(500,350), ylim=(S-0.3, S+0.4))
plot!(y)
plot!([1,nmax], [S, S], color=:black, ls=:dash, label="entropy")
S = entropy(d) = 0.6365141682948128
sum((-(pdf(d, k)) * logpdf(d, k) for k = support(d))) = 0.6365141682948128
Out[2]:
200 400 600 800 1000 0.4 0.5 0.6 0.7 0.8 0.9 1.0 y1 y2 y3 y4 y5 entropy
In [3]:
using Plots
pyplot(legend=false)
X = cumsum(randn(2^14,3))
plot(X[:,1], X[:,2], X[:,3], lw=0.3)
Out[3]:
In [4]:
using Plots
plotlyjs(legend=false)
X = cumsum(randn(2^14,3))
plot(X[:,1], X[:,2], X[:,3], size=(800,600))