%!demo
%! ## Plot the PDF of an Inverse Gaussian distribution, with parameters mu = 1
%! ## and lambda = 2, truncated at [0.5, 2] intervals. Generate 10000 random
%! ## samples from this truncated distribution and superimpose a histogram scaled
%! ## accordingly
%!
%! pd = makedist ("InverseGaussian", "mu", 1, "lambda", 2)
%! t = truncate (pd, 0.5, 2)
%! rand ("seed", 21);
%! data = random (t, 10000, 1);
%!
%! ## Plot histogram and fitted PDF
%! plot (t)
%! hold on
%! hist (data, 100, 50)
%! hold off
%! title ("Inverse Gaussian distribution (mu = 1, lambda = 2) truncated at [0.5, 2]")
%! legend ("Truncated PDF", "Histogram")
%!
%! ## This demonstrates truncating an Inverse Gaussian distribution to a specific
%! ## range and visualizing the resulting distribution with random samples.
