%!demo
%! ## Plot the PDF of a Log-uniform distribution, with parameters Lower=1
%! ## and Upper=10, truncated at [2, 5] intervals. Generate 10000 random
%! ## samples from this truncated distribution and superimpose a histogram scaled
%! ## accordingly
%! rand ("seed", 21);
%! data_all = exp (unifrnd (log (1), log (10), 20000, 1));
%! data = data_all(data_all >= 2 & data_all <= 5);
%! data = data(1:7500);
%! 
%! pd = LoguniformDistribution (1, 10);
%! t = truncate (pd, 2, 5);
%! 
%! [counts, centers] = hist (data, 50);
%! bin_width = centers(2) - centers(1);
%! bar (centers, counts / (sum (counts) * bin_width), 1);
%! hold on;
%! 
%! ## Plot histogram and truncated PDF
%! x = linspace (0.5, 5, 500);
%! y = pdf (t, x);
%! plot (x, y, "r", "linewidth", 2);
%! title ("Log-uniform distribution (Lower=1, Upper=10) truncated at [2, 5]")
%! legend ("Truncated PDF", "Histogram")
%! 
%! ## This demonstrates truncating a Log-uniform distribution to a specific
%! ## range and visualizing the resulting distribution with random samples.
