{"id":259,"date":"2011-07-03T09:30:42","date_gmt":"2011-07-03T09:30:42","guid":{"rendered":"http:\/\/ahay.org\/blog\/?p=259"},"modified":"2015-09-07T20:46:08","modified_gmt":"2015-09-07T20:46:08","slug":"program-of-the-month-sfnoise","status":"publish","type":"post","link":"https:\/\/ahay.org\/blog\/2011\/07\/03\/program-of-the-month-sfnoise\/","title":{"rendered":"Program of the month: sfnoise"},"content":{"rendered":"<p>Starting from this post, once a month we will blog about one of the popular <strong>Madagascar<\/strong> programs. The 30 <a href=\"\/blog\/2010\/04\/28\/top-ranked-programs-and-projects\/\">highest ranking programs<\/a>, according to <a href=\"https:\/\/github.com\/ahay\/src\/blob\/master\/admin\/rank.py\">admin\/rank.py<\/a>, are<\/p>\n<blockquote>\n<p>grey window math dd spike put graph add cat transp scale pad spray smooth stack noise grey3 real dip ricker1 bandpass dots wiggle mask fft1 segyread contour pick mutter fft3<\/p>\n<\/blockquote>\n<p>This month&#8217;s randomly selected feature is <a href=\"\/RSF\/sfnoise.html\">sfnoise<\/a>. <\/p>\n<p><img decoding=\"async\" src=\"\/RSF\/book\/rsf\/rsf\/sfnoise\/Fig\/noi.png\" alt=\"\" title=\"\" \/> <\/p>\n<p>As stated in the self-documentation, <strong>sfnoise<\/strong> is used for generating random noise and adding it to the data. This is useful for generating synthetic datasets or for multiple realizations in inversion. Computer-generated random numbers are often called pseudo-random, because algorithmically generated sequences of numbers are not truly random. This is actually a useful feature if you want to reproduce previous calculations. For reproducibility, it is imperative to use <strong>seed=<\/strong> parameter to set the initial &#8220;seed&#8221; for the random-number generator. If <strong>seed=<\/strong> is not used, it is set by the computer clock. Therefore, different runs of <strong>sfnoise<\/strong> will produce different sets of numbers. <\/p>\n<p>Try the following on the command line:  <\/p>\n<div class=\"code-box\"><div class=\"code-title\"><i class=\"fa fa-code\"><\/i> <div class=\"pull-right\"><a href=\"#\" class=\"btn btn-default btn-xs toggle-code\" data-toggle=\"tooltip\" title=\"Toggle code\"><i class=\"fa fa-toggle-up\"><\/i><\/a><\/div><\/div><pre ><code>bash$ sfspike n1=5 mag=0 | sfnoise | sfdisfil \n0: -2.455 1.197 -0.145 0.2394 0.7676 \nbash$ sfspike n1=5 mag=0 | sfnoise | sfdisfil \n0: 2.203 -0.1106 -0.07494 -0.4916 0.2163\n<\/code><\/pre><\/div>\n<p>Your sets of numbers will be (most likely) different from the ones above and between the two runs. However, if you run  <\/p>\n<div class=\"code-box\"><div class=\"code-title\"><i class=\"fa fa-code\"><\/i> <div class=\"pull-right\"><a href=\"#\" class=\"btn btn-default btn-xs toggle-code\" data-toggle=\"tooltip\" title=\"Toggle code\"><i class=\"fa fa-toggle-up\"><\/i><\/a><\/div><\/div><pre ><code>bash$ sfspike n1=5 mag=0 | sfnoise seed=2011 | sfdisfil \n0: 0.1917 0.3379 -0.9459 0.5841 -0.02078\n<\/code><\/pre><\/div>\n<p>you should see exactly the same set of number as above. You should also get the same numbers if using  <\/p>\n<div class=\"code-box\"><div class=\"code-title\"><i class=\"fa fa-code\"><\/i> <div class=\"pull-right\"><a href=\"#\" class=\"btn btn-default btn-xs toggle-code\" data-toggle=\"tooltip\" title=\"Toggle code\"><i class=\"fa fa-toggle-up\"><\/i><\/a><\/div><\/div><pre ><code>bash$ sfspike n1=5 | sfnoise seed=2011 rep=y | sfdisfil \n0: 0.1917 0.3379 -0.9459 0.5841 -0.02078\n<\/code><\/pre><\/div>\n<p>The <strong>rep=<\/strong> parameter controls if the noise is replacing the data or being added to the data. The default operation is addition.  <\/p>\n<div class=\"code-box\"><div class=\"code-title\"><i class=\"fa fa-code\"><\/i> <div class=\"pull-right\"><a href=\"#\" class=\"btn btn-default btn-xs toggle-code\" data-toggle=\"tooltip\" title=\"Toggle code\"><i class=\"fa fa-toggle-up\"><\/i><\/a><\/div><\/div><pre ><code>bash$ sfspike n1=5 | sfnoise seed=2011 | sfdisfil \n0: 1.192 1.338 0.05412 1.584 0.9792\n<\/code><\/pre><\/div>\n<p>The algorithm for pseudorandom number generation that <strong>sfnoise<\/strong> uses is known as <a href=\"http:\/\/www.math.sci.hiroshima-u.ac.jp\/~m-mat\/MT\/emt.html\">Mersenne twister<\/a>. It is a powerful algorithm that generates a nearly uniformly distributed sequence that does not repeat for a very large period of $2^{19937}-1$. <\/p>\n<blockquote>\n<p>Matsumoto, M.; Nishimura, T. (1998). &#8220;Mersenne twister: a 623-dimensionally equidistributed uniform pseudo-random number generator&#8221;. ACM Transactions on Modeling and Computer Simulation 8 (1): 3\u009630.<\/p>\n<\/blockquote>\n<p>Uniformly-distributed numbers can be used to generate random numbers with other distributions. By default, <strong>sfnoise<\/strong> is using <a href=\"http:\/\/en.wikipedia.org\/wiki\/Normal_distribution\">normal distribution<\/a>. It can be changed to uniform distribution by setting <strong>type=n<\/strong>. <\/p>\n<ul>\n<li>See <a href=\"\/RSF\/book\/rsf\/rsf\/sfnoise.html\">rsf\/rsf\/sfnoise<\/a> for simple examples of setting the noise distribution parameters (<strong>type=<\/strong>, <strong>mean=<\/strong>, <strong>var=<\/strong>, <strong>range=<\/strong>). <\/li>\n<\/ul>\n<p><img decoding=\"async\" src=\"\/RSF\/book\/rsf\/rsf\/sfnoise\/Fig\/variance.png\" alt=\"\" title=\"\" \/> <img decoding=\"async\" src=\"\/RSF\/book\/rsf\/rsf\/sfnoise\/Fig\/range.png\" alt=\"\" title=\"\" \/><\/p>\n<ul>\n<li>See <a href=\"\/RSF\/book\/geostats\/simulate\/rfield.html\">geostats\/simulate\/rfield <\/a>and Jim Jenning&#8217;s <a href=\"\/wikilocal\/docs\/data_flows.ppt\">presentation<\/a> at <a href=\"\/wiki\/Houston_2010\">Houston-2010<\/a> school for more sophisticated examples of using <strong>sfnoise<\/strong>, together with FFT-based variogram computation, in geostatistical simulations. <\/li>\n<\/ul>\n<p><img decoding=\"async\" src=\"\/RSF\/book\/geostats\/simulate\/rfield\/Fig\/ex2D_sim_03_real.png\" alt=\"\" title=\"\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Starting from this post, once a month we will blog about one of the popular Madagascar programs. The 30 highest ranking programs, according to admin\/rank.py, are grey window math dd spike put graph add cat transp scale pad spray smooth stack noise grey3 real dip ricker1 bandpass dots wiggle mask fft1 segyread contour pick mutter [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_import_markdown_pro_load_document_selector":0,"_import_markdown_pro_submit_text_textarea":"","activitypub_content_warning":"","activitypub_content_visibility":"local","activitypub_max_image_attachments":4,"activitypub_interaction_policy_quote":"","footnotes":""},"categories":[5],"tags":[],"class_list":["post-259","post","type-post","status-publish","format-standard","hentry","category-documentation"],"_links":{"self":[{"href":"https:\/\/ahay.org\/blog\/wp-json\/wp\/v2\/posts\/259","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ahay.org\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ahay.org\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ahay.org\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ahay.org\/blog\/wp-json\/wp\/v2\/comments?post=259"}],"version-history":[{"count":3,"href":"https:\/\/ahay.org\/blog\/wp-json\/wp\/v2\/posts\/259\/revisions"}],"predecessor-version":[{"id":22426,"href":"https:\/\/ahay.org\/blog\/wp-json\/wp\/v2\/posts\/259\/revisions\/22426"}],"wp:attachment":[{"href":"https:\/\/ahay.org\/blog\/wp-json\/wp\/v2\/media?parent=259"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ahay.org\/blog\/wp-json\/wp\/v2\/categories?post=259"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ahay.org\/blog\/wp-json\/wp\/v2\/tags?post=259"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}