# For a sequence of n values, that produces an expected value curve, overlay the distribution associated with each value horizontally

Howdy, so I have a small code which for a value n produces the mean value from a list of samples, and produces the domain (x_n) and range values (y_n) of a kernel density estimate for given n value. I was curious if it is possible for a given value n, I can plot the kernel density estimate on the y axis - I have seen using orientation = :horizontal, but that doesn’t seem to work.

Any suggestions would be great.

``````using Random, Distributions
using LinearAlgebra
using KernelDensity
using Distributions
using KernelDensityEstimate
using Plots

function generate_kde(data)

U=kde(data)

return (U,U.x,U.density)

end

function problem_n(n,sample_num)

dist = Uniform(10^-n, 10^(-n+1))
x = rand(dist, sample_num)
mu = mean(x)
min_val = minimum(x)
max_val=maximum(x)
(U,x_1,y_1) = generate_kde(x)
return (mu,x_1,y_1)

end

max_n = 7
n_list=[]
avg_list=[]
x1_list = []
x2_list=[]
sample_num=1000
for k=1:max_n
k = float(k)
append!(n_list,[k])
(mu,x1,x2)= problem_n(k,sample_num)
append!(x1_list,[x1])
append!(x2_list,[x2])
append!(avg_list,[mu])

end
y_min = 10^-6.0
y_max = 10^0.0
Plots.plot(n_list,avg_list,yaxis=:log10,ylim=(y_min,y_max))
#Plots.plot!(n_list,x2_list,orientation = :horizontal)
Plots.savefig("test\$(max_n).png")
``````