0
$\begingroup$

I want to visualize to any distribution with two or three parameter

dist = ProbabilityDistribution[λ Exp[λ (1 - x)], {x, 1, Infinity}, Assumptions -> λ > 0]
data = {1.4, 5.1, 1.7, 1.6, 1.1, 3.9, 2.2, 1.3, 2., 1.5};

param = FindDistributionParameters[data, dist]

Plot[
 LogLikelihood[dist, data], {λ, .1, 2},
 Epilog -> {PointSize[Medium], Red, 
            Point[{λ, LogLikelihood[dist, data]} /. param]}
]

image for illustration

$\endgroup$
3
  • $\begingroup$ What is your question here? $\endgroup$
    – MarcoB
    Commented Mar 31, 2021 at 14:32
  • $\begingroup$ I want to draw the image for three parameters(image for each parameters) but I don't know how i write it? $\endgroup$
    – A Day
    Commented Mar 31, 2021 at 14:43
  • $\begingroup$ if anyone can draw for any distribution with two or three parameters to i do like him I will be thank for him $\endgroup$
    – A Day
    Commented Mar 31, 2021 at 14:45

1 Answer 1

1
$\begingroup$
data = (SeedRandom[1234]; RandomVariate[
   NormalDistribution[2, 1/2], 20])

(* {1.74583, 1.9647, 1.20305, 2.7683, 3.33901, 1.34158, 1.45272, 2.07147, \
2.05208, 1.16345, 2.01788, 2.08509, 2.46734, 1.58657, 1.95452, 2.5167, \
1.81824, 2.0943, 1.93193, 1.95803} *)

dist = NormalDistribution[m, s];

param = FindDistributionParameters[data, dist]

(* {m -> 1.97664, s -> 0.511284} *)

llf = LogLikelihood[dist, data] // Simplify

(* (-41.6851 + 39.5328 m - 10. m^2 - 18.3788 s^2 - 20. s^2 Log[s])/s^2 *)

Or manually calculating the llf

llf === (Total@Log[PDF[dist, #] & /@ data] // PowerExpand // Simplify)

(* True *)

Show[
 Plot3D[llf,
  {m, 1, 3}, {s, 1/4, 3/4},
  AxesLabel -> (Style[#, 16, Bold] & /@
     {"m", "s", "llf"}),
  PlotStyle -> Opacity[0.7],
  ClippingStyle -> None],
 Graphics3D[{PointSize[Large], Red, Point[{m, s, llf} /. param]}]]

enter image description here

For a three-parameter distribution you need three plots, one each with one of the parameters fixed and plot the llf with the other two.

$\endgroup$
5
  • $\begingroup$ how i ask about one each with one of the parameters fixed please? $\endgroup$
    – A Day
    Commented Mar 31, 2021 at 15:59
  • $\begingroup$ Set one of the parameters to its value in param and plot the llf as a two-parameter function of the other two parameters. Repeat for each parameter. $\endgroup$
    – Bob Hanlon
    Commented Mar 31, 2021 at 16:05
  • $\begingroup$ couldn't draw 2d instead of 3d? $\endgroup$
    – A Day
    Commented Mar 31, 2021 at 16:08
  • $\begingroup$ To draw 2D you would need to fix two parameters and plot against the third. Again using multiple plots. $\endgroup$
    – Bob Hanlon
    Commented Mar 31, 2021 at 16:11
  • $\begingroup$ Thanks you very much $\endgroup$
    – A Day
    Commented Mar 31, 2021 at 16:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.