{"id":123,"date":"2016-06-11T07:26:41","date_gmt":"2016-06-11T07:26:41","guid":{"rendered":"http:\/\/www.uncertain-future.org.uk\/?page_id=123"},"modified":"2016-06-11T07:41:41","modified_gmt":"2016-06-11T07:41:41","slug":"random-number-generators","status":"publish","type":"page","link":"http:\/\/www.uncertain-future.org.uk\/?page_id=123","title":{"rendered":"Random Number Generators for Different Distributions"},"content":{"rendered":"<p><u><\/u><u>Libraries<\/u><\/p>\n<p>No special library routines are required for these routines<\/p>\n<p><u>Download<\/u><\/p>\n<p>Download sample code for rtriangle and rtrapezoid routines\u00a0[<a href=\"http:\/\/&lt;a&gt;http:\/\/www.uncertain-future.org.uk\/wp-content\/uploads\/2016\/06\/R-TriTrap.zip&gt;Here&lt;\/a&gt;\"><em>Here<\/em><\/a>]<\/p>\n<p><u>Procedure<\/u><\/p>\n<p>R provides built in routines to generate random (density dependent) samples from different distributions.\u00a0\u00a0 There are other routines to provide the density function or cumulative quantile probability for any value of x.\u00a0 A sample of these routines is as follows:<\/p>\n<p>runif (num, min, max)\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 for uniform distribution<\/p>\n<p>rnorm (num, mean, sd)\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 for normal distribution<\/p>\n<p>rlnorm(num, logmean, logsd)\u00a0\u00a0\u00a0\u00a0\u00a0 for log normal distribution<\/p>\n<p>rexp(num, rate)\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 for exponential distribution<\/p>\n<p>rgamma(num, shape, rate)\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 for gamma distribution<\/p>\n<p>rbeta (num, shape1, shape2)\u00a0\u00a0\u00a0\u00a0\u00a0 for beta distribution<\/p>\n<p>Here num is the number of samples required, and the other variables are the parameters of each distribution.\u00a0 Other statistical distributions are available (see R help files).<\/p>\n<p>Two other routines have been written to provide random samples from the triangular or trapezoidal distributions<\/p>\n<p>rtriangle (num, min, peak, max)\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 for triangular distribution<\/p>\n<p>rtrapezoid (num, min, peak1, peak2, max)\u00a0\u00a0 for trapezoidal distribution<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Libraries No special library routines are required for these routines Download Download sample code for rtriangle and rtrapezoid routines\u00a0[Here] Procedure R provides built in routines to generate random (density dependent) samples from different distributions.\u00a0\u00a0 There are other routines to provide the density function or cumulative quantile probability for any value of x.\u00a0 A sample of &hellip; <a href=\"http:\/\/www.uncertain-future.org.uk\/?page_id=123\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Random Number Generators for Different Distributions<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":28,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-123","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"http:\/\/www.uncertain-future.org.uk\/index.php?rest_route=\/wp\/v2\/pages\/123","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.uncertain-future.org.uk\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"http:\/\/www.uncertain-future.org.uk\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"http:\/\/www.uncertain-future.org.uk\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.uncertain-future.org.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=123"}],"version-history":[{"count":2,"href":"http:\/\/www.uncertain-future.org.uk\/index.php?rest_route=\/wp\/v2\/pages\/123\/revisions"}],"predecessor-version":[{"id":137,"href":"http:\/\/www.uncertain-future.org.uk\/index.php?rest_route=\/wp\/v2\/pages\/123\/revisions\/137"}],"up":[{"embeddable":true,"href":"http:\/\/www.uncertain-future.org.uk\/index.php?rest_route=\/wp\/v2\/pages\/28"}],"wp:attachment":[{"href":"http:\/\/www.uncertain-future.org.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=123"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}