In [1]:
using Plots, ApproxFun
In [2]:
f = abs(Fun(sin,[-5,5]))
r = ApproxFun.sample(f,10000)
plot(f/sum(f))
histogram!(r;normed=true,nbins=100)
Out[2]:
In [3]:
x=Fun(identity)
f = exp(x)*sqrt(1-x^2)
r = ApproxFun.sample(f,10000)
plot(f/sum(f))
histogram!(r;normed=true,nbins=100)
Out[3]:
In [4]:
x=Fun(identity)
f = exp(x)/sqrt(1-x^2)
r = ApproxFun.sample(f,10000)
plot(f/sum(f);ylims=(0.,5.))
histogram!(r;normed=true,nbins=100)
Out[4]:
In [5]:
x=Fun(identity)
f = exp(x)*(1-x)^0.123*(1+x)^(-0.234)
r = ApproxFun.sample(f,10000)
plot(f/sum(f))
histogram!(r;normed=true,nbins=100)
Out[5]:
In [6]:
f=Fun(x->(1+sech(x))/(1+x^2),[-Inf,Inf])
r=ApproxFun.sample(f,10000)
plot(-15.:.01:15.,f/sum(f))
histogram!(filter!(r->abs(r)<15,r);normed=true,nbins=100)
Out[6]:
In [7]:
f=Fun(x->(exp(-x)+1)/(1+x^2),[0,Inf])
r=ApproxFun.sample(f,10000)
plot(0:.05:15,f/sum(f))
histogram!(filter!(r->0<r<15,r);normed=true,nbins=100)
Out[7]: