r - Generate t distribution density plot with pre-specified mean -
i create student's t distribution density plot mean of 0.02 instead of 0. possible do?
the distribtion should have 2 degrees of freedom.
is possible do?
i tried following:
x<-rnorm(100000,mean=0.02, sd=(1/sqrt(878))) pop.mean<-mean(x) t<-sapply(1:10000, function(x) (mean(sample(x,100))-pop.mean)/(1/sqrt(878))) plot(density(t))
is approach correct?
if correct, how can real densities, not approximation?
your statement , example contradict each other somewhat.
do want non-central t distribution based on normal mean 0.02? example suggests, note non-central t not shifted t, skewed.
if want non-central t can plot command like:
curve(dt(x,2,0.02), from=-5, to=6)
or, want shifted t distribution? distribution symmetric around 0.02 shape of t distribution?
you can plot curve shifted using command like:
curve(dt(x-0.02,2), from=-5, to=6 )
the curve
function has add
argument use plot both on same plot if want compare them (not difference in case), changing color on 1 of them suggested.
Comments
Post a Comment