{"id":267,"date":"2012-08-25T11:15:34","date_gmt":"2012-08-25T11:15:34","guid":{"rendered":"http:\/\/www.jontrinder.com\/blog\/?p=267"},"modified":"2012-08-25T11:15:34","modified_gmt":"2012-08-25T11:15:34","slug":"random-numbers-where-all-numbers-are-equal-but-some-more-equal-than-others","status":"publish","type":"post","link":"https:\/\/www.jontrinder.com\/blog\/?p=267","title":{"rendered":"Random numbers&#8230;.where all numbers are equal but some more equal than others&#8230;"},"content":{"rendered":"<p>For the ph_lyrics project the tweets occur at random intervals of time. But it was desired that the chosen interval should be more\u00a0likely\u00a0to be a longer rather than shorter interval. What was needed was a php mechanism for generating weighted random numbers.<\/p>\n<p>As ever the folks over at <a href=\"http:\/\/stackoverflow.com\/questions\/445235\/generating-random-results-by-weight-in-php\">stackoverflow<\/a>\u00a0had the answer.<\/p>\n<p>Which looks like this:<\/p>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">\r\nfunction weightedrand($min, $max, $gamma) {\r\n$offset= $max-$min+1;\r\nreturn floor($min+pow(lcg_value(), $gamma)*$offset);\r\n}\r\n <\/pre>\n","protected":false},"excerpt":{"rendered":"<p>For the ph_lyrics project the tweets occur at random intervals of time. But it was desired that the chosen interval should be more\u00a0likely\u00a0to be a longer rather than shorter interval. What was needed was a php mechanism for generating weighted &hellip; <a href=\"https:\/\/www.jontrinder.com\/blog\/?p=267\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[36],"tags":[29,28,83],"class_list":["post-267","post","type-post","status-publish","format-standard","hentry","category-php","tag-coding","tag-ph_lyrics","tag-php"],"_links":{"self":[{"href":"https:\/\/www.jontrinder.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/267","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.jontrinder.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.jontrinder.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.jontrinder.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.jontrinder.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=267"}],"version-history":[{"count":7,"href":"https:\/\/www.jontrinder.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/267\/revisions"}],"predecessor-version":[{"id":275,"href":"https:\/\/www.jontrinder.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/267\/revisions\/275"}],"wp:attachment":[{"href":"https:\/\/www.jontrinder.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=267"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.jontrinder.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=267"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.jontrinder.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=267"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}