alirezausefi
alirezausefi

Reputation: 121

plot the probability distribution function of set of data in julia

I have a set of data in matrix columns, I want to plot PDF, CDF and ect. of each column in julia. what can i do? I use this

a=maximum(porosity)
b=minimum(porosity)
xs1=a:0.001:b
Plots.plot(xs1, pdf(porosity, xs), legend=nothing)

but

ERROR: MethodError: no method matching pdf(::Matrix{Float64}, ::StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}, Int64}).

porosity is n*1 matrix

Upvotes: 1

Views: 1008

Answers (1)

Bogumił Kamiński
Bogumił Kamiński

Reputation: 69949

If you want to plot KDE of PDF use density from StatsPlots.jl.

If you want to plot ECDF use ecdfplot from StatsPlots.jl.

using StatsPlots
density(porosity) # plot KDE of PDF
p = ecdfplot(porosity[:, 1]); # ECDF of first column
foreach(i -> ecdfplot!(p, porosity[:, i]), 2:size(porosity, 2)); # add the rest of ECDFs
p # display

Upvotes: 3

Related Questions