<rss xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" version="2.0">
  <channel>
    <title>MaplePrimes - comments on Post, Generating Samples from Custom Probability Distributions (IV)</title>
    <link>http://www.mapleprimes.com/posts/96015-Generating-Samples-From-Custom-Probability-Distributions-IV</link>
    <language>en-us</language>
    <copyright>2026 Maplesoft, A Division of Waterloo Maple Inc.</copyright>
    <generator>Maplesoft Document System</generator>
    <lastBuildDate>Sat, 13 Jun 2026 00:41:44 GMT</lastBuildDate>
    <pubDate>Sat, 13 Jun 2026 00:41:44 GMT</pubDate>
    <itunes:subtitle />
    <itunes:summary />
    <description>The latest comments added to the Post, Generating Samples from Custom Probability Distributions (IV)</description>
    <image>
      <url>http://www.mapleprimes.com/images/mapleprimeswhite.jpg</url>
      <title>MaplePrimes - comments on Post, Generating Samples from Custom Probability Distributions (IV)</title>
      <link>http://www.mapleprimes.com/posts/96015-Generating-Samples-From-Custom-Probability-Distributions-IV</link>
    </image>
    <item>
      <title>generating many samples</title>
      <link>http://www.mapleprimes.com/posts/96015-Generating-Samples-From-Custom-Probability-Distributions-IV?ref=Feed:MaplePrimes:Generating Samples from Custom Probability Distributions (IV):Comments#comment97758</link>
      <itunes:summary>&lt;p&gt;I enjoyed this series of related posts &lt;em&gt;very&lt;/em&gt; much.&lt;/p&gt;
&lt;p&gt;They do remind me of a related topic which was discussed (a few different times) on this site some years ago. it was the issue of how to efficiently generate many different medium-sized samples of a given distribution. At that time, the focus was mostly on reducing overhead within the Statistics package, or reducing the overhead of garbage collecting (a.k.a. memory management) of Array/Vector containers for such samples. The judgement then (IIRC) was in preference of generating a single sample up front -- as large as one can bear in terms of memory allocation.&lt;/p&gt;
&lt;p&gt;Now it seems to me that you have mostly been discussing user-defined distributions, and that presumably there are some better/dedicated methods for sample well-known stock distributions. Please correct me if that is wrong. So my related question is: for these relevant distributions how can the overhead of duplicated recomputation of all these subdivisions (that you have shown above) be avoided in the case that one wishes to resample a distribution many different times? Eg, if I wish to generate finite-sized samples of 10,000 entries, repeated say 100,000 times.&lt;/p&gt;
&lt;!--break--&gt;
&lt;p&gt;acer&lt;/p&gt;</itunes:summary>
      <description>The latest comments added to the Post, Generating Samples from Custom Probability Distributions (IV)</description>
      <guid>97758</guid>
      <pubDate>Wed, 13 Oct 2010 05:58:52 Z</pubDate>
      <itunes:author>acer</itunes:author>
      <author>acer</author>
    </item>
    <item>
      <title>re: generating many samples</title>
      <link>http://www.mapleprimes.com/posts/96015-Generating-Samples-From-Custom-Probability-Distributions-IV?ref=Feed:MaplePrimes:Generating Samples from Custom Probability Distributions (IV):Comments#comment97862</link>
      <itunes:summary>&lt;p&gt;&lt;a href="http://www.mapleprimes.com/posts/96015-Generating-Samples-From-Custom-Probability-Distributions-IV#comment97758"&gt;@acer&lt;/a&gt;&amp;nbsp;: Indeed, all of what I discussed is specific to user-defined distributions, but your question applies to both the predefined and the custom distributions, in principle: for both, there are situations where there is data we want to keep between invocations of the C level code. However, we currently have facilities for doing so only for the predefined distributions. Fixing this has been on my wish list for a while, but it hasn't bubbled to the top quite yet.&lt;/p&gt;
&lt;p&gt;So in the mean time, for custom distributions, it is still best to, as you say, create a sample that is as big as your memory can bear and then slice and dice that to obtain your subsamples. For predefined distributions, it should be almost as efficient if you use this underdocumented calling sequence:&lt;/p&gt;
&lt;pre&gt;X := Statistics[RandomVariable](SomePredefinedDistribution(alpha, beta));&lt;br&gt;p := Statistics[Sample](X); # This does most of the library-level precomputation&lt;br&gt;for i to 10^5 do&lt;br&gt;&amp;nbsp;&amp;nbsp;sample := p(10^4):&lt;br&gt;&amp;nbsp;&amp;nbsp;process(sample):&lt;br&gt;end do:&lt;/pre&gt;
&lt;p&gt;This took 65s for SomePredefinedDistribution(alpha, beta) = Normal(0, 1) on one machine where I tested it (with the process statement omitted), versus 63s for 100 samples of size 10^7. We will try to document this calling sequence (where Sample returns a procedure) &amp;nbsp;better in a future version of Maple.&lt;/p&gt;
&lt;p&gt;Hope this helps,&lt;/p&gt;
&lt;p&gt;Erik Postma&lt;br&gt;Maplesoft.&amp;nbsp;&lt;/p&gt;</itunes:summary>
      <description>The latest comments added to the Post, Generating Samples from Custom Probability Distributions (IV)</description>
      <guid>97862</guid>
      <pubDate>Sat, 16 Oct 2010 10:48:55 Z</pubDate>
      <itunes:author>epostma</itunes:author>
      <author>epostma</author>
    </item>
    <item>
      <title>thanks</title>
      <link>http://www.mapleprimes.com/posts/96015-Generating-Samples-From-Custom-Probability-Distributions-IV?ref=Feed:MaplePrimes:Generating Samples from Custom Probability Distributions (IV):Comments#comment97863</link>
      <itunes:summary>&lt;p&gt;&lt;a href="http://www.mapleprimes.com/posts/96015-Generating-Samples-From-Custom-Probability-Distributions-IV#comment97862"&gt;@epostma&lt;/a&gt; Erik, you are a gentleman and a scholar.&lt;/p&gt;</itunes:summary>
      <description>The latest comments added to the Post, Generating Samples from Custom Probability Distributions (IV)</description>
      <guid>97863</guid>
      <pubDate>Sat, 16 Oct 2010 11:30:00 Z</pubDate>
      <itunes:author>acer</itunes:author>
      <author>acer</author>
    </item>
  </channel>
</rss>