# simulation fodder for future exams

Here are two nice exercises for a future simulation exam, seen and solved on X validated. The first one is about simulating a Gibbs sampler associated with the joint target

exp{-|x|-|y|-a(y-x|}

defined over IR² for a≥0 (or possibly a>-1). The conditionals are identical and non-standard, but a simple bound on the conditional density is the corresponding standard double exponential density, which makes for a straightforward accept-reject implementation. However it is also feasible to break the full conditional into three parts, depending on the respective positions of x, y, and 0, and to obtain easily invertible cdfs on the three intervals. The second exercise is about simulating from the cdf $F(x)=1-\exp\{-ax-bx^{p+1}/(p+1)\}$

which can be numerically inverted. It is however more fun to call for an accept-reject algorithm by bounding the density with a ½ ½ mixture of an Exponential Exp(a) and of the 1/(p+1)-th power of an Exponential Exp(b/(p+1)). Since no extra constant appears in the solution,  I suspect the (p+1) in b/(p+1) was introduced on purpose. As seen in the above fit for 10⁶ simulations (and a=1,b=2,p=3), there is no deviation from the target! There is however an even simpler resolution to the exercise: since the tail function (1-F(x)) appears as the product of two tail functions, exp(-ax) and the other one, the cdf is the distribution of the minimum of two random variates, one with the Exp(a) distribution and the other one being the 1/(p+1)-th power of an Exponential Exp(b/(p+1)) distribution. Which of course returns a very similar histogram fit: Tags:
{"ft_lang_label":"__label__en","ft_lang_prob":0.93167025,"math_prob":0.9902381,"size":1544,"snap":"2019-35-2019-39","text_gpt3_token_len":368,"char_repetition_ratio":0.101298705,"word_repetition_ratio":0.016393442,"special_character_ratio":0.23186529,"punctuation_ratio":0.08064516,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9987511,"pos_list":[0,1,2,3,4,5,6,7,8],"im_url_duplicate_count":[null,null,null,9,null,null,null,9,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2019-09-23T06:46:08Z\",\"WARC-Record-ID\":\"<urn:uuid:124e9749-99cd-464d-a177-48cce0db5db6>\",\"Content-Length\":\"29638\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:9b4c6d62-86ff-448f-b0b6-87aa65216197>\",\"WARC-Concurrent-To\":\"<urn:uuid:e4bc4883-b835-4bdb-ae67-c916206df2d1>\",\"WARC-IP-Address\":\"199.167.200.62\",\"WARC-Target-URI\":\"http://www.statsblogs.com/2019/02/19/simulation-fodder-for-future-exams/\",\"WARC-Payload-Digest\":\"sha1:4TTC2SJ6GHB3CXOJM5FL7RI4ROPQORP2\",\"WARC-Block-Digest\":\"sha1:Q6XL56KTPWUSRG7OHHWDHE4ZBUGOK7TQ\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2019/CC-MAIN-2019-39/CC-MAIN-2019-39_segments_1568514576122.89_warc_CC-MAIN-20190923064347-20190923090347-00207.warc.gz\"}"}