Transformadas das distribuições de probabilidade

It is possible to define a PDF

I’ve made this by hand, then I’m checking whether it is correctly normalized

2/(d-a+c-b)Integrate[ Piecewise[{{(x-a)/(b-a),a<x<b},{1,b≤x≤c},{1-(x-c)/(d-c),c<x<d}},0],{x,-Infinity,Infinity},Assumptions->0<a<b<c<d ]//FullSimplify

trapezoidalDistribution[x_,a_,b_,c_,d_]:=Module[{n=2/(d-a+c-b)},ProbabilityDistribution[ Piecewise[{{n(x-a)/(b-a),a<x<b},{n,b≤x≤c},{n-n(x-c)/(d-c),c<x<d}},0],{x,a,d}] ]/;0<a<b<c<d

u=RandomVariate[ trapezoidalDistribution[x,1,2,5,9],100000];

Histogram[u]

Mean[ trapezoidalDistribution[x,1,2,5,9] ]

Sequence[ ] unfolds a list giving a sequence of parameters. Useful different sets of parameters are used along the program

p=Sequence[1,2,5,9]

m=Mean[ trapezoidalDistribution[x,p] ]

σ=StandardDeviation[trapezoidalDistribution[x,p] ]

Test functions

NormalDistribution[m,σ]

CauchyDistribution[m,σ]

Plot[{PDF[ NormalDistribution[m,σ],x ],PDF[ CauchyDistribution[m,σ],x],PDF[trapezoidalDistribution[x,p],x]},{x,-2,12}]

Função característica

ϕN=CharacteristicFunction[ NormalDistribution[x0,σ0] ,t]

CharacteristicFunction[ NormalDistribution[m,σ] ,t]

ϕC=CharacteristicFunction[ CauchyDistribution[μ,γ],t]

CharacteristicFunction[ CauchyDistribution[m,σ],t]

ϕt=CharacteristicFunction[ trapezoidalDistribution[x,p],t]//FullSimplify

Cumulants

Series[ Log[ϕt],{t,0,5}]

CumulantGeneratingFunction[ NormalDistribution[m,σ] ,t]

CumulantGeneratingFunction[ NormalDistribution[x0,σ0] ,t]

CumulantGeneratingFunction[ CauchyDistribution[μ,γ],t]

ct=CumulantGeneratingFunction[trapezoidalDistribution[x,p],t]

Series[ct,{t,0,5}]

Cumulant[NormalDistribution[m,σ],4]

Cumulant[CauchyDistribution[m,σ],2]

Cumulant[trapezoidalDistribution[x,p],5]

Relation between central moments and cumulants

MomentConvert[Cumulant[2],"Moment"]

MomentConvert[Cumulant[2],"Moment"]//TraditionalForm

MomentConvert[Cumulant[4],"Moment"]//TraditionalForm

MomentConvert[Cumulant[4],"CentralMoment"]//TraditionalForm

MomentConvert[CentralMoment[4],"Cumulant"]//TraditionalForm

MomentConvert[Moment[4],"Cumulant"]//TraditionalForm

Miscelaneous

Series[ Exp[I t/2 - t^2/(24ν)],{t,0,5}]

GeneratingFunction[ μ^n Exp[-μ]/n!,n,x]

GeneratingFunction[PDF[ PoissonDistribution[μ],n],n,x]

PDF[ PoissonDistribution[μ],n]

gf=GeneratingFunction[ PDF[BinomialDistribution[number,prob],n],n,x]

dx2=TransformedDistribution[x^2,x\[Distributed]NormalDistribution[10.0,1.0] ]

pdx2=Table[{x,PDF[ dx2,x]},{x,90.,110,1.}]

ListPlot[%]

dx22=TransformedDistribution[x^2,x\[Distributed]NormalDistribution[10.0,2.0] ] (* \[Distributed] é o mesmo que Distributed[x,NormalDistribution[10,2] ] *)

pdx22=Table[{x,PDF[ dx22,x]},{x,80.,110,1.}]

ListPlot[pdx22]

trup=EmpiricalDistribution[u]

Histogram[ RandomVariate[trup,100000] ]

pseno=TransformedDistribution[Sin[x]/2,x\[Distributed]UniformDistribution[{0,Pi}]]

Histogram[ RandomVariate[pseno,10000] ]