{"id":2174,"date":"2020-10-24T17:44:35","date_gmt":"2020-10-24T12:14:35","guid":{"rendered":"https:\/\/www.rangakrish.com\/?p=2174"},"modified":"2020-10-24T17:45:49","modified_gmt":"2020-10-24T12:15:49","slug":"using-random-walk-principle-to-generate-music","status":"publish","type":"post","link":"https:\/\/www.rangakrish.com\/index.php\/2020\/10\/24\/using-random-walk-principle-to-generate-music\/","title":{"rendered":"Using Random Walk Principle to Generate Music"},"content":{"rendered":"<p>In mathematics, the simplest example of <em><strong>Random Walk<\/strong><\/em>\u00a0is a random process along a one-dimensional plane of integers, starting at 0 and moving in the positive or negative direction in steps of +1 or -1, with equal probability. The <em><strong>Random Walk<\/strong><\/em>\u00a0theory has been applied in many domains including <em><strong>Physics<\/strong><\/em> and even the <em><strong>Stock Market<\/strong><\/em>.<\/p>\n<p><a href=\"https:\/\/www.mit.edu\/~kardar\/teaching\/projects\/chemotaxis(AndreaSchmidt)\/random.htm\" target=\"_blank\" rel=\"noopener noreferrer\"><em><strong>Here<\/strong><\/em><\/a>\u00a0is a nice article on the principle of <em><strong>Random Walk<\/strong><\/em> in Mathematics. A more detailed video lecture is available <a href=\"https:\/\/www.youtube.com\/watch?v=6wUD_gp5WeE\" target=\"_blank\" rel=\"noopener noreferrer\"><em><strong>here<\/strong><\/em><\/a>.<\/p>\n<p>The following shows a rendering of the <em><strong>Random Walk<\/strong><\/em> process in <a href=\"https:\/\/www.wolfram.com\/mathematica\/\" target=\"_blank\" rel=\"noopener noreferrer\"><em><strong>Mathematica<\/strong><\/em><\/a>.<\/p>\n<figure id=\"attachment_2175\" aria-describedby=\"caption-attachment-2175\" style=\"width: 500px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2020\/10\/Mathematica-RandomWalk.png?ssl=1\"><img data-recalc-dims=\"1\" fetchpriority=\"high\" decoding=\"async\" data-attachment-id=\"2175\" data-permalink=\"https:\/\/www.rangakrish.com\/index.php\/2020\/10\/24\/using-random-walk-principle-to-generate-music\/mathematica-randomwalk\/\" data-orig-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2020\/10\/Mathematica-RandomWalk.png\" data-orig-size=\"656,296\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"Random Walk Example in Mathematica\" data-image-description=\"&lt;p&gt;Random Walk Example in Mathematica&lt;\/p&gt;\n\" data-image-caption=\"&lt;p&gt;Random Walk Example in Mathematica&lt;\/p&gt;\n\" data-large-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2020\/10\/Mathematica-RandomWalk.png\" class=\"wp-image-2175\" src=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2020\/10\/Mathematica-RandomWalk.png?resize=500%2C226&#038;ssl=1\" alt=\"Random Walk Example in Mathematica\" width=\"500\" height=\"226\" srcset=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2020\/10\/Mathematica-RandomWalk.png?resize=300%2C135&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2020\/10\/Mathematica-RandomWalk.png?w=656&amp;ssl=1 656w\" sizes=\"(max-width: 500px) 100vw, 500px\" \/><\/a><figcaption id=\"caption-attachment-2175\" class=\"wp-caption-text\"><strong>Random Walk Example in Mathematica<\/strong><\/figcaption><\/figure>\n<p>My focus today is on using the <em><strong>Random Walk<\/strong><\/em> idea to generate music in <a href=\"https:\/\/opusmodus.com\" target=\"_blank\" rel=\"noopener noreferrer\"><em><strong>Opusmodus<\/strong><\/em><\/a>, my preferred platform for algorithmic music composition. <em><strong>Opusmodus<\/strong><\/em> has many functions that help mimic randomness, and one such function is <em><strong>\u201cgen-walk\u201d<\/strong><\/em>, an implementation of the <em><strong>Random Walk<\/strong><\/em> idea on a 1-dimensional plane.<\/p>\n<p>The following shows three evaluations of the <em><strong>\u201cgen-walk\u201d<\/strong><\/em> function (executed in the <em><strong>Listener<\/strong><\/em> pane):<\/p>\n<figure id=\"attachment_2176\" aria-describedby=\"caption-attachment-2176\" style=\"width: 600px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2020\/10\/gen-walk.png?ssl=1\"><img data-recalc-dims=\"1\" decoding=\"async\" data-attachment-id=\"2176\" data-permalink=\"https:\/\/www.rangakrish.com\/index.php\/2020\/10\/24\/using-random-walk-principle-to-generate-music\/gen-walk\/\" data-orig-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2020\/10\/gen-walk.png\" data-orig-size=\"573,159\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"gen-walk in Opusmodus\" data-image-description=\"&lt;p&gt;gen-walk in Opusmodus&lt;\/p&gt;\n\" data-image-caption=\"&lt;p&gt;gen-walk in Opusmodus&lt;\/p&gt;\n\" data-large-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2020\/10\/gen-walk.png\" class=\"wp-image-2176\" src=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2020\/10\/gen-walk.png?resize=600%2C166&#038;ssl=1\" alt=\"gen-walk in Opusmodus\" width=\"600\" height=\"166\" srcset=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2020\/10\/gen-walk.png?resize=300%2C83&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2020\/10\/gen-walk.png?w=573&amp;ssl=1 573w\" sizes=\"(max-width: 600px) 100vw, 600px\" \/><\/a><figcaption id=\"caption-attachment-2176\" class=\"wp-caption-text\"><strong>gen-walk in Opusmodus<\/strong><\/figcaption><\/figure>\n<p>The first example shows 10 successive integer values starting from 0 with steps of +1 or -1, with equal probability.<\/p>\n<p>The second example shows how we can specify the step size. In this case, it can be +\/-1, +\/-2 and +\/-3.<\/p>\n<p>The third example is a very useful extension, where instead of working with integers, we work with pitches directly. In this case, we specify a starting pitch (on the chromatic scale) and let the function generate other pitches based on the given intervals. This is the idea that we will be using today.<\/p>\n<p>It is also possible to specify the <em><strong>forward<\/strong><\/em> and <em><strong>backward<\/strong><\/em> probabilities. Please go through the documentation to understand its entire functionality.<\/p>\n<p>Just as I did in <em><strong>Mathematica<\/strong><\/em>, we can plot the generated integral values in <em><strong>Opusmodus<\/strong><\/em>. See this image:<\/p>\n<figure id=\"attachment_2177\" aria-describedby=\"caption-attachment-2177\" style=\"width: 500px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2020\/10\/gen-walk-plot.png?ssl=1\"><img data-recalc-dims=\"1\" decoding=\"async\" data-attachment-id=\"2177\" data-permalink=\"https:\/\/www.rangakrish.com\/index.php\/2020\/10\/24\/using-random-walk-principle-to-generate-music\/gen-walk-plot\/\" data-orig-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2020\/10\/gen-walk-plot.png\" data-orig-size=\"676,152\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"gen-walk Plot\" data-image-description=\"&lt;p&gt;gen-walk Plot&lt;\/p&gt;\n\" data-image-caption=\"&lt;p&gt;gen-walk Plot&lt;\/p&gt;\n\" data-large-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2020\/10\/gen-walk-plot.png\" class=\"wp-image-2177\" src=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2020\/10\/gen-walk-plot.png?resize=500%2C112&#038;ssl=1\" alt=\"gen-walk Plot\" width=\"500\" height=\"112\" srcset=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2020\/10\/gen-walk-plot.png?resize=300%2C67&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2020\/10\/gen-walk-plot.png?w=676&amp;ssl=1 676w\" sizes=\"(max-width: 500px) 100vw, 500px\" \/><\/a><figcaption id=\"caption-attachment-2177\" class=\"wp-caption-text\"><strong>gen-walk Plot<\/strong><\/figcaption><\/figure>\n<p>The above plot was generated by the following expression:<\/p>\n<figure id=\"attachment_2186\" aria-describedby=\"caption-attachment-2186\" style=\"width: 500px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2020\/10\/gen-walk-code.png?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"2186\" data-permalink=\"https:\/\/www.rangakrish.com\/index.php\/2020\/10\/24\/using-random-walk-principle-to-generate-music\/gen-walk-code\/\" data-orig-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2020\/10\/gen-walk-code.png\" data-orig-size=\"395,61\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"Code to Plot gen-walk Output\" data-image-description=\"&lt;p&gt;Code to Plot gen-walk Output&lt;\/p&gt;\n\" data-image-caption=\"&lt;p&gt;Code to Plot gen-walk Output&lt;\/p&gt;\n\" data-large-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2020\/10\/gen-walk-code.png\" class=\"wp-image-2186\" src=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2020\/10\/gen-walk-code.png?resize=500%2C77&#038;ssl=1\" alt=\"Code to Plot gen-walk Output\" width=\"500\" height=\"77\" srcset=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2020\/10\/gen-walk-code.png?resize=300%2C46&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2020\/10\/gen-walk-code.png?w=395&amp;ssl=1 395w\" sizes=\"(max-width: 500px) 100vw, 500px\" \/><\/a><figcaption id=\"caption-attachment-2186\" class=\"wp-caption-text\"><strong>Code to Plot gen-walk Output<\/strong><\/figcaption><\/figure>\n<p>It is now time to look at the <em><strong>Opusmodus<\/strong><\/em> code for music generation:<\/p>\n<figure id=\"attachment_2178\" aria-describedby=\"caption-attachment-2178\" style=\"width: 600px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2020\/10\/random-walk-opusmodus.png?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"2178\" data-permalink=\"https:\/\/www.rangakrish.com\/index.php\/2020\/10\/24\/using-random-walk-principle-to-generate-music\/random-walk-opusmodus\/\" data-orig-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2020\/10\/random-walk-opusmodus.png\" data-orig-size=\"838,541\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"Using gen-walk to Synthesize Music\" data-image-description=\"&lt;p&gt;Using gen-walk to Synthesize Music&lt;\/p&gt;\n\" data-image-caption=\"&lt;p&gt;Using gen-walk to Synthesize Music&lt;\/p&gt;\n\" data-large-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2020\/10\/random-walk-opusmodus.png\" class=\"wp-image-2178\" src=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2020\/10\/random-walk-opusmodus.png?resize=600%2C387&#038;ssl=1\" alt=\"Using gen-walk to Synthesize Music\" width=\"600\" height=\"387\" srcset=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2020\/10\/random-walk-opusmodus.png?resize=300%2C194&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2020\/10\/random-walk-opusmodus.png?resize=768%2C496&amp;ssl=1 768w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2020\/10\/random-walk-opusmodus.png?resize=140%2C90&amp;ssl=1 140w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2020\/10\/random-walk-opusmodus.png?w=838&amp;ssl=1 838w\" sizes=\"(max-width: 600px) 100vw, 600px\" \/><\/a><figcaption id=\"caption-attachment-2178\" class=\"wp-caption-text\"><strong>Using gen-walk to Synthesize Music<\/strong><\/figcaption><\/figure>\n<p>The <em><strong>&#8220;create-track&#8221;<\/strong><\/em> function does the main work. First, we select the rhythm randomly from the given set. Then, required number of pitches are generated using the <em><strong>gen-walk<\/strong><\/em> function. The number of pitches depends on the corresponding rhythm (we exclude rests). These two are then combined to create the <em><strong>OMN<\/strong><\/em>. Just to make it interesting, I am using three channels and each of then will be associated with a different <em><strong>OMN<\/strong><\/em> structure.<\/p>\n<p>The generated music is far from perfect, of course. The idea is just to show how we can use <em><strong>\u201cgen-walk\u201d<\/strong><\/em> function to create music. One can apply other filters to come up with better music.<\/p>\n<p>Note that every time we run this code, a different piece of music will be generated, and that is the idea! Here is the <em><strong>musicxml<\/strong><\/em> rendering during one execution of the above code:<\/p>\n<figure id=\"attachment_2179\" aria-describedby=\"caption-attachment-2179\" style=\"width: 500px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2020\/10\/musicxml.png?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"2179\" data-permalink=\"https:\/\/www.rangakrish.com\/index.php\/2020\/10\/24\/using-random-walk-principle-to-generate-music\/musicxml\/\" data-orig-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2020\/10\/musicxml.png\" data-orig-size=\"683,351\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"Generated Music &amp;#8211; MusicXML\" data-image-description=\"&lt;p&gt;Generated Music &amp;#8211; MusicXML&lt;\/p&gt;\n\" data-image-caption=\"&lt;p&gt;Generated Music &amp;#8211; MusicXML&lt;\/p&gt;\n\" data-large-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2020\/10\/musicxml.png\" class=\"wp-image-2179\" src=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2020\/10\/musicxml.png?resize=500%2C257&#038;ssl=1\" alt=\"Generated Music - MusicXML\" width=\"500\" height=\"257\" srcset=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2020\/10\/musicxml.png?resize=300%2C154&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2020\/10\/musicxml.png?w=683&amp;ssl=1 683w\" sizes=\"(max-width: 500px) 100vw, 500px\" \/><\/a><figcaption id=\"caption-attachment-2179\" class=\"wp-caption-text\"><strong>Generated Music &#8211; MusicXML<\/strong><\/figcaption><\/figure>\n<p>Here is another run:<\/p>\n<figure id=\"attachment_2180\" aria-describedby=\"caption-attachment-2180\" style=\"width: 500px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2020\/10\/musicxml2.png?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"2180\" data-permalink=\"https:\/\/www.rangakrish.com\/index.php\/2020\/10\/24\/using-random-walk-principle-to-generate-music\/musicxml2\/\" data-orig-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2020\/10\/musicxml2.png\" data-orig-size=\"682,338\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"Another Run\" data-image-description=\"&lt;p&gt;Another Run&lt;\/p&gt;\n\" data-image-caption=\"&lt;p&gt;Another Run&lt;\/p&gt;\n\" data-large-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2020\/10\/musicxml2.png\" class=\"wp-image-2180\" src=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2020\/10\/musicxml2.png?resize=500%2C248&#038;ssl=1\" alt=\"Another Run\" width=\"500\" height=\"248\" srcset=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2020\/10\/musicxml2.png?resize=300%2C149&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2020\/10\/musicxml2.png?w=682&amp;ssl=1 682w\" sizes=\"(max-width: 500px) 100vw, 500px\" \/><\/a><figcaption id=\"caption-attachment-2180\" class=\"wp-caption-text\"><strong>Another Run<\/strong><\/figcaption><\/figure>\n<p>As you can see for yourself, a simple function such as <em><strong>gen-walk<\/strong><\/em> can lay the foundation for some interesting musical structure. You can use my code as a starting point and experiment further by adding your own logic.<\/p>\n<p>You can download the <em><strong>Opusmodus<\/strong><\/em> code from <a href=\"http:\/\/www.rangakrish.com\/downloads\/RandomWalk.opmo\" target=\"_blank\" rel=\"noopener noreferrer\"><em><strong>here<\/strong><\/em><\/a>. You can find my other articles on <em><strong>Opusmodus<\/strong><\/em> <a href=\"https:\/\/www.rangakrish.com\/index.php\/category\/music\/\" target=\"_blank\" rel=\"noopener noreferrer\"><em><strong>here<\/strong><\/em><\/a>.<\/p>\n<p>Have a nice weekend!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In mathematics, the simplest example of Random Walk\u00a0is a random process along a one-dimensional plane of integers, starting at 0 and moving in the positive or negative direction in steps of +1 or -1, with equal probability. The Random Walk\u00a0theory has been applied in many domains including Physics and even the Stock Market. Here\u00a0is a [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"advanced_seo_description":"","jetpack_seo_html_title":"","jetpack_seo_noindex":false,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[18,5,17],"tags":[252,37,251],"class_list":["post-2174","post","type-post","status-publish","format-standard","hentry","category-lisp","category-music","category-programming","tag-algorithmic-music-synthesis","tag-opusmodus","tag-random-walk"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p9OLnF-z4","jetpack-related-posts":[{"id":1711,"url":"https:\/\/www.rangakrish.com\/index.php\/2019\/09\/01\/poetry-in-prolog-part-2\/","url_meta":{"origin":2174,"position":0},"title":"Poetry in Prolog: Part-2","author":"admin","date":"September 1, 2019","format":false,"excerpt":"In an earlier post, I showed how Prolog can be used to generate poetry, making use of my \"iLexicon\". I want to continue the discussion today by giving another example, this time based on the theme of sounds emitted by various animals and birds. As hinted in my previous articles,\u2026","rel":"","context":"In &quot;Natural Language Processing&quot;","block_context":{"text":"Natural Language Processing","link":"https:\/\/www.rangakrish.com\/index.php\/category\/natural-language-processing\/"},"img":{"alt_text":"The DCG Grammar","src":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/09\/code.jpg?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/09\/code.jpg?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/09\/code.jpg?resize=525%2C300&ssl=1 1.5x"},"classes":[]},{"id":2206,"url":"https:\/\/www.rangakrish.com\/index.php\/2020\/11\/22\/a-library-for-algorithmic-music-composition\/","url_meta":{"origin":2174,"position":1},"title":"A Library for Algorithmic Music Composition","author":"admin","date":"November 22, 2020","format":false,"excerpt":"I have recently started implementing a library for algorithmic music composition. It provides higher-level algorithms and abstractions for composing multi-track music, and works with Opusmodus\u00a0software. Opusmodus is a great platform for music composition and has excellent support for MIDI-based music. My library is an attempt to enrich the Opusmodus platform\u2026","rel":"","context":"In &quot;LISP&quot;","block_context":{"text":"LISP","link":"https:\/\/www.rangakrish.com\/index.php\/category\/lisp\/"},"img":{"alt_text":"App for Controlling Opusmodus","src":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2020\/11\/Screen1-300x139.jpg?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":159,"url":"https:\/\/www.rangakrish.com\/index.php\/2016\/02\/28\/using-cellular-automata-to-generate-music\/","url_meta":{"origin":2174,"position":2},"title":"Using Cellular Automata to Generate Music","author":"admin","date":"February 28, 2016","format":false,"excerpt":"Cellular automata are a powerful computational formalism. Stephen Wolfram\u2019s book A New Kind of Science\u00a0provides a thorough study of these devices. Not surprisingly,\u00a0Wolfram Mathematica has great support for working with them. For example, the following figure shows the evolution of Rule 30 over 50 steps, plotted using ArrayPlot function (in\u2026","rel":"","context":"In &quot;LISP&quot;","block_context":{"text":"LISP","link":"https:\/\/www.rangakrish.com\/index.php\/category\/lisp\/"},"img":{"alt_text":"Cellular Automata","src":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2016\/02\/Cellular-Automata.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":653,"url":"https:\/\/www.rangakrish.com\/index.php\/2017\/10\/14\/using-function-calls-in-the-grammar\/","url_meta":{"origin":2174,"position":3},"title":"Using Function Calls in the Grammar","author":"admin","date":"October 14, 2017","format":false,"excerpt":"One of the advanced features of iLangGen is the ability to embed arbitrary function calls on the RHS of grammar rules. Such functions impart interesting dynamic behaviour to the generated data. For convenience and flexibility, iLangGen supports two types of function calls - Direct and Indirect. In the case of\u2026","rel":"","context":"In &quot;LISP&quot;","block_context":{"text":"LISP","link":"https:\/\/www.rangakrish.com\/index.php\/category\/lisp\/"},"img":{"alt_text":"Direct Function Call in Grammar","src":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2017\/10\/Image1.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":2645,"url":"https:\/\/www.rangakrish.com\/index.php\/2021\/12\/25\/calling-lisp-functions-from-d-language\/","url_meta":{"origin":2174,"position":4},"title":"Calling Lisp Functions from D Language","author":"admin","date":"December 25, 2021","format":false,"excerpt":"After exploring \"newLisp\" in the past few posts, I would like to start looking at the \"D Programming Language\"\u00a0(DLang). DLang\u00a0has been around since 2001. It was originally created by Walter Bright and later Andrei Alexandrescu joined the team in 2007. The main inspiration for DLang was C++, although it uses\u2026","rel":"","context":"In &quot;D Language&quot;","block_context":{"text":"D Language","link":"https:\/\/www.rangakrish.com\/index.php\/category\/d-language\/"},"img":{"alt_text":"Lisp Function Called from D","src":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2021\/12\/Lisp-300x107.jpg?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2021\/12\/Lisp-300x107.jpg?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2021\/12\/Lisp-300x107.jpg?resize=525%2C300&ssl=1 1.5x"},"classes":[]},{"id":227,"url":"https:\/\/www.rangakrish.com\/index.php\/2016\/05\/10\/generating-melody-to-fit-harmony\/","url_meta":{"origin":2174,"position":5},"title":"Generating Melody to Fit Harmony","author":"admin","date":"May 10, 2016","format":false,"excerpt":"There are two common approaches to composing music. One involves synthesizing a suitable chord progression first and then layering melody over it. The other is to start with melody and then harmonize it by applying chords. Of course, you can mix both approaches - use one technique for a portion\u2026","rel":"","context":"In &quot;LISP&quot;","block_context":{"text":"LISP","link":"https:\/\/www.rangakrish.com\/index.php\/category\/lisp\/"},"img":{"alt_text":"Melody Over Harmony","src":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2016\/05\/Melody-Over-Harmony-888x1024.png?resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2016\/05\/Melody-Over-Harmony-888x1024.png?resize=350%2C200 1x, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2016\/05\/Melody-Over-Harmony-888x1024.png?resize=525%2C300 1.5x, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2016\/05\/Melody-Over-Harmony-888x1024.png?resize=700%2C400 2x"},"classes":[]}],"_links":{"self":[{"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/posts\/2174","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/comments?post=2174"}],"version-history":[{"count":0,"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/posts\/2174\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/media?parent=2174"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/categories?post=2174"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/tags?post=2174"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}