<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Limina.Log &#187; Programming</title>
	<atom:link href="http://log.liminastudio.com/tag/programming/feed" rel="self" type="application/rss+xml" />
	<link>http://log.liminastudio.com</link>
	<description>Research &#38; Development at Limina.Studio</description>
	<lastBuildDate>Sun, 15 Jan 2012 21:25:34 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Arduino: Compensating for a Logarithmic Curve</title>
		<link>http://log.liminastudio.com/programming/arduino-compensating-for-a-logarithmic-curve</link>
		<comments>http://log.liminastudio.com/programming/arduino-compensating-for-a-logarithmic-curve#comments</comments>
		<pubDate>Thu, 04 Aug 2011 20:05:45 +0000</pubDate>
		<dc:creator>Tedb0t</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[arduino]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Logarithm]]></category>
		<category><![CDATA[Sound]]></category>

		<guid isPermaLink="false">http://log.liminastudio.com/?p=904</guid>
		<description><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://log.liminastudio.com/programming/arduino-compensating-for-a-logarithmic-curve' addthis:title='Arduino: Compensating for a Logarithmic Curve '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div>Did you know that the scale of acoustic pitches is logarithmic?  This means that, even though we perceive the scale of notes as increasing or decreasing linearly, the actual frequencies are doubling or halving with each octave. In my Deconspectrum installation, I&#8217;m mapping acoustic frequencies to color.  If I mapped them linearly, the colors would [...]]]></description>
			<content:encoded><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://log.liminastudio.com/programming/arduino-compensating-for-a-logarithmic-curve' addthis:title='Arduino: Compensating for a Logarithmic Curve '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div><p>Did you know that the scale of acoustic pitches is logarithmic?  This means that, even though we perceive the scale of notes as increasing or decreasing linearly, the actual frequencies are doubling or halving with each octave.</p>
<p>In my <a href="http://log.liminastudio.com/projects/deconspectrum">Deconspectrum installation</a>, I&#8217;m mapping acoustic frequencies to color.  If I mapped them linearly, the colors would change very rapidly in the low frequencies, and then stop changing as obviously as the pitch gets higher.  This is not the effect you would expect, since you want each pitch to be represented by another color.</p>
<p>The solution is to map frequency to color (hue) logarithmically instead of linearly.  Thankfully, AVR C gives us a handy base-10 log function:</p>
<pre>int hueFreq = log10(frequency - FREQ_MIN) * hueScale;</pre>
<p>If we graph this, we get:</p>
<p><a href="http://log.liminastudio.com/wp-content/uploads/2011/08/Freq_Hue_Lin.png"  rel="lightbox[roadtrip]"><img class="alignleft size-medium wp-image-905" title="Freq_Hue_Lin" src="http://log.liminastudio.com/wp-content/uploads/2011/08/Freq_Hue_Lin-300x165.png" alt="" width="300" height="165" /></a>The &#8216;y&#8217; scale is hue and the &#8216;x&#8217; is frequency.  You can see that, with each octave, the change in color progresses more naturally, mimicking our linear perception of pitch.</p>
<p>Here&#8217;s the same graph with a logarithmic frequency axis:</p>
<p><a href="http://log.liminastudio.com/wp-content/uploads/2011/08/Freq_Hue_Log.png"  rel="lightbox[roadtrip]"><img class="alignleft size-medium wp-image-906" title="Freq_Hue_Log" src="http://log.liminastudio.com/wp-content/uploads/2011/08/Freq_Hue_Log-300x161.png" alt="" width="300" height="161" /></a>The dotted line is the log10 function without the cutoff, so you can see the &#8220;simulated&#8221; linearity.</p>
<p>Handy, and highly effective!</p>
]]></content:encoded>
			<wfw:commentRss>http://log.liminastudio.com/programming/arduino-compensating-for-a-logarithmic-curve/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Bash snippet: Process Search &amp; Destroy</title>
		<link>http://log.liminastudio.com/programming/bash-snippet-process-search-destroy</link>
		<comments>http://log.liminastudio.com/programming/bash-snippet-process-search-destroy#comments</comments>
		<pubDate>Tue, 12 Apr 2011 23:04:10 +0000</pubDate>
		<dc:creator>Tedb0t</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Bash]]></category>

		<guid isPermaLink="false">http://log.liminastudio.com/?p=820</guid>
		<description><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://log.liminastudio.com/programming/bash-snippet-process-search-destroy' addthis:title='Bash snippet: Process Search &#38; Destroy '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div>Occasionally on my server I&#8217;ll get dead processes that fit a specific command pattern, and I need to kill them.  However, I don&#8217;t want to killall, as other processes of the same program are still running normally.  Here&#8217;s a handy one-liner I just whipped up to do this: sudo kill `ps ax -o"pid,command" &#124; grep [...]]]></description>
			<content:encoded><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://log.liminastudio.com/programming/bash-snippet-process-search-destroy' addthis:title='Bash snippet: Process Search &amp; Destroy '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div><p>Occasionally on my server I&#8217;ll get dead processes that fit a specific command pattern, and I need to kill them.  However, I don&#8217;t want to <code>killall</code>, as other processes of the same program are still running normally.  Here&#8217;s a handy one-liner I just whipped up to do this:</p>
<pre>sudo kill `ps ax -o"pid,command" | grep -E 'command_pattern' | awk '{print $1}'`</pre>
<pre>ps ax -o"pid,command"</pre>
<p> gives you a list of all processes, just showing pid and command.</p>
<pre>grep -E 'command_pattern'</pre>
<p> searches for a regex command pattern.</p>
<pre>awk '{print $1}'</pre>
<p> returns the first column—the pid.  This is the ultimate output of the backticked expression, which is substituted as the parameter for <code>kill</code>.</p>
<p>Hope you find it useful!</p>
]]></content:encoded>
			<wfw:commentRss>http://log.liminastudio.com/programming/bash-snippet-process-search-destroy/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Bash snippet: Initialize a bunch of files with dummy text</title>
		<link>http://log.liminastudio.com/programming/bash-snippet-initialize-a-bunch-of-files-with-dummy-text</link>
		<comments>http://log.liminastudio.com/programming/bash-snippet-initialize-a-bunch-of-files-with-dummy-text#comments</comments>
		<pubDate>Mon, 10 Jan 2011 21:08:08 +0000</pubDate>
		<dc:creator>Tedb0t</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Bash]]></category>

		<guid isPermaLink="false">http://log.liminastudio.com/?p=782</guid>
		<description><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://log.liminastudio.com/programming/bash-snippet-initialize-a-bunch-of-files-with-dummy-text' addthis:title='Bash snippet: Initialize a bunch of files with dummy text '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div>Check it: for i in test-{0..10}; do echo "dummy data" &#62; $i; done Neat!]]></description>
			<content:encoded><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://log.liminastudio.com/programming/bash-snippet-initialize-a-bunch-of-files-with-dummy-text' addthis:title='Bash snippet: Initialize a bunch of files with dummy text '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div><p>Check it:</p>
<pre>for i in test-{0..10}; do echo "dummy data" &gt; $i; done</pre>
<p>Neat!</p>
]]></content:encoded>
			<wfw:commentRss>http://log.liminastudio.com/programming/bash-snippet-initialize-a-bunch-of-files-with-dummy-text/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Photoshop to Flash: Best Practices</title>
		<link>http://log.liminastudio.com/programming/photoshop-to-flash-best-practices</link>
		<comments>http://log.liminastudio.com/programming/photoshop-to-flash-best-practices#comments</comments>
		<pubDate>Fri, 09 Jul 2010 21:22:39 +0000</pubDate>
		<dc:creator>Tedb0t</dc:creator>
				<category><![CDATA[Commentary]]></category>
		<category><![CDATA[Miscellaneous]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Photoshop]]></category>

		<guid isPermaLink="false">http://log.liminastudio.com/?p=651</guid>
		<description><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://log.liminastudio.com/programming/photoshop-to-flash-best-practices' addthis:title='Photoshop to Flash: Best Practices '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div>Building out a Flash interface from a PSD can be a time consuming process, so to make things most efficient, here are some handy guidelines for preparing Photoshop files.  Designers may want to duplicate their PSD and save it as a new file specifically for Flash import if they want to keep extra hidden layers, [...]]]></description>
			<content:encoded><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://log.liminastudio.com/programming/photoshop-to-flash-best-practices' addthis:title='Photoshop to Flash: Best Practices '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div><p>Building out a Flash interface from a PSD can be a time consuming process, so to make things most efficient, here are some handy guidelines for preparing Photoshop files.  Designers may want to duplicate their PSD and save it as a new file specifically for Flash import if they want to keep extra hidden layers, etc..</p>
<ul>
<li>Turn off or delete all unused or irrelevant layers.</li>
<li>Merge all adjustment layers or masks into regular layers.  Masked layers or groups cannot be used!</li>
<li>Layer effects are OK!  However, if you turn one off and don&#8217;t plan on using it at all, make sure you remove the effect by dragging it onto the trash icon in the Layers palette.</li>
<li>Vector graphics are <em>always</em> preferred!  If you are using Illustrator to design any assets, please provide the Illustrator file too, as Flash cannot import Smart Vector Objects.</li>
<li>Vector graphics are especially preferred for layers intended to be animated.  Imported bitmaps will often look shoddy and low-resolution when moving around and rotating.</li>
<li>If an Illustrator file can&#8217;t be provided, rasterize any Smart Vector Objects or other non-standard layers.</li>
<li>Keep groups and layers orderly and named accurately whenever possible <img src='http://log.liminastudio.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://log.liminastudio.com/programming/photoshop-to-flash-best-practices/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Flash Error #2078 with no code</title>
		<link>http://log.liminastudio.com/programming/flash-error-2078-with-no-code</link>
		<comments>http://log.liminastudio.com/programming/flash-error-2078-with-no-code#comments</comments>
		<pubDate>Fri, 25 Jun 2010 20:28:50 +0000</pubDate>
		<dc:creator>Tedb0t</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[Flash]]></category>

		<guid isPermaLink="false">http://log.liminastudio.com/?p=635</guid>
		<description><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://log.liminastudio.com/programming/flash-error-2078-with-no-code' addthis:title='Flash Error #2078 with no code '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div>I was getting this error: Error #2078: The name property of a Timeline-placed object cannot be modified. &#8230;even though I had no code addressing any Timeline-placed objects. What gived? I was trying to give an instance name of &#8220;name&#8221; to the object. Change it and you&#8217;re good. Word to the wise!]]></description>
			<content:encoded><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://log.liminastudio.com/programming/flash-error-2078-with-no-code' addthis:title='Flash Error #2078 with no code '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div><p>I was getting this error:</p>
<pre>Error #2078: The name property of a Timeline-placed object cannot be modified.</pre>
<p>&#8230;even though I had no code addressing any Timeline-placed objects.  What gived?  I was trying to give an instance name of &#8220;name&#8221; to the object.  Change it and you&#8217;re good.  Word to the wise!</p>
]]></content:encoded>
			<wfw:commentRss>http://log.liminastudio.com/programming/flash-error-2078-with-no-code/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>byteSlice()</title>
		<link>http://log.liminastudio.com/itp/byteslice</link>
		<comments>http://log.liminastudio.com/itp/byteslice#comments</comments>
		<pubDate>Sat, 01 May 2010 03:17:33 +0000</pubDate>
		<dc:creator>Tedb0t</dc:creator>
				<category><![CDATA[ITP]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Thesis]]></category>
		<category><![CDATA[arduino]]></category>
		<category><![CDATA[C++]]></category>

		<guid isPermaLink="false">http://log.liminastudio.com/?p=605</guid>
		<description><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://log.liminastudio.com/itp/byteslice' addthis:title='byteSlice() '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div>Here&#8217;s a weird little function I just wrote to &#8220;slice&#8221; an integer out of a byte: int byteSlice(byte input, byte startIndex, byte endIndex){ // generates an integer value from an arbitrary slice of a byte // Example: // // index: 01234567 // input = B01101100 (int 108) // // startIndex = 1 // endIndex = [...]]]></description>
			<content:encoded><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://log.liminastudio.com/itp/byteslice' addthis:title='byteSlice() '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div><p>Here&#8217;s a weird little function I just wrote to &#8220;slice&#8221; an integer out of a byte:</p>
<pre>int byteSlice(byte input, byte startIndex, byte endIndex){

  // generates an integer value from an arbitrary slice of a byte
  // Example:
  //
  // index:   01234567
  // input = B01101100 (int 108)
  //
  // startIndex = 1
  // endIndex = 4
  // slice = B1101
  // returns int 13

  byte output;

  // shift left to shave off bits before startIndex
  output = input << startIndex;
  // shift right to shave off bits after endIndex
  output = output >> (7-endIndex) + startIndex;

  return int(output);
}</pre>
<p>This basically takes out a chunk of a byte and gives you the integer representation of its bits.  The input index byte datatypes are a neurotic memory optimization, since the indices can&#8217;t be greater than 7. <img src='http://log.liminastudio.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />   Example Arduino implementation:</p>
<pre>void setup(){

  Serial.begin(9600);
  byte in = 108;

  Serial.print(in, DEC);
  Serial.print("\t");
  Serial.println(in, BIN);
  Serial.println("----------------");
  Serial.print(byteSlice(in, 0, 7), DEC);
  Serial.print("\t");
  Serial.println(byteSlice(in, 0, 7), BIN);
  Serial.println("----------------");
  Serial.print(byteSlice(in, 1, 4), DEC);
  Serial.print("\t");
  Serial.println(byteSlice(in, 1, 4), BIN);
  Serial.println("----------------");
  Serial.print(byteSlice(in, 3, 6), DEC);
  Serial.print("\t");
  Serial.println(byteSlice(in, 3, 6), BIN);
}

void loop(){
}</pre>
]]></content:encoded>
			<wfw:commentRss>http://log.liminastudio.com/itp/byteslice/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Converting a byte to an array and vice-versa</title>
		<link>http://log.liminastudio.com/itp/converting-a-byte-to-an-array-and-vice-versa</link>
		<comments>http://log.liminastudio.com/itp/converting-a-byte-to-an-array-and-vice-versa#comments</comments>
		<pubDate>Mon, 19 Apr 2010 00:48:00 +0000</pubDate>
		<dc:creator>Tedb0t</dc:creator>
				<category><![CDATA[ITP]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Thesis]]></category>
		<category><![CDATA[arduino]]></category>
		<category><![CDATA[Bitmath]]></category>
		<category><![CDATA[C++]]></category>

		<guid isPermaLink="false">http://log.liminastudio.com/?p=596</guid>
		<description><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://log.liminastudio.com/itp/converting-a-byte-to-an-array-and-vice-versa' addthis:title='Converting a byte to an array and vice-versa '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div>Here are two super-useful Arduino utility functions I just devised for my thesis: byte arrayToByte(int arr[], int len){ // Convert -1 to 0 and pack the array into a byte int i; byte result = 0; for(i=len-1; i&#62;=0; i--){ if(arr[i] == -1){ result &#38;= ~(0 &#60;&#60; i); } else { result &#124;= (1 &#60;&#60; i); [...]]]></description>
			<content:encoded><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://log.liminastudio.com/itp/converting-a-byte-to-an-array-and-vice-versa' addthis:title='Converting a byte to an array and vice-versa '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div><p>Here are two super-useful Arduino utility functions I just devised for my thesis:</p>
<pre>byte arrayToByte(int arr[], int len){
  // Convert -1 to 0 and pack the array into a byte
  int i;
  byte result = 0;

  for(i=len-1; i&gt;=0; i--){
    if(arr[i] == -1){
      result &amp;= ~(0 &lt;&lt; i);
    } else {
      result |= (1 &lt;&lt; i);
    }
  }
  return result;
}</pre>
<pre>int* byteToArray(byte in){
  int i, temp, out[8];

  for(i=0; i&lt;8; i++){     temp = (in &gt;&gt; i) &amp; 1;
    if(temp == 0) temp = -1;
    out[i] = temp;
  }
  return out;
}</pre>
<p>The first function takes in an array of up to 8 integers valued 1 or -1 and generates a corresponding byte; the second does the reverse.  Easy to modify for other integer values.</p>
]]></content:encoded>
			<wfw:commentRss>http://log.liminastudio.com/itp/converting-a-byte-to-an-array-and-vice-versa/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Implementing the Perceptron Rule</title>
		<link>http://log.liminastudio.com/itp/implementing-the-perceptron-rule</link>
		<comments>http://log.liminastudio.com/itp/implementing-the-perceptron-rule#comments</comments>
		<pubDate>Sat, 17 Apr 2010 21:41:52 +0000</pubDate>
		<dc:creator>Tedb0t</dc:creator>
				<category><![CDATA[ITP]]></category>
		<category><![CDATA[Learning Bit by Bit]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Thesis]]></category>
		<category><![CDATA[arduino]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[Neural Networks]]></category>

		<guid isPermaLink="false">http://log.liminastudio.com/?p=586</guid>
		<description><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://log.liminastudio.com/itp/implementing-the-perceptron-rule' addthis:title='Implementing the Perceptron Rule '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div>A perceptron is one of the simplest forms of neural networks: a linear classifier.  It is a method of associating input patterns with output patterns, with the advantage that it is forgiving of noise in the input. The network consists of an input and output layer (and optional &#8220;hidden&#8221; layers in between) with weighted connections [...]]]></description>
			<content:encoded><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://log.liminastudio.com/itp/implementing-the-perceptron-rule' addthis:title='Implementing the Perceptron Rule '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div><p>A <a href="http://en.wikipedia.org/wiki/Perceptron">perceptron</a> is one of the simplest forms of neural networks: a <a href="http://en.wikipedia.org/wiki/Linear_classifier">linear classifier</a>.  It is a method of associating input patterns with output patterns, with the advantage that it is forgiving of noise in the input.</p>
<p>The network consists of an input and output layer (and optional &#8220;hidden&#8221; layers in between) with weighted connections between all of them.  To train a perceptron, you present an input pattern and the output pattern it should learn to output.  Then you step through each pair of neurons in each pair of layers and modify their weights with this equation:</p>
<p>∆w<sub>i</sub> = c (d &#8211; sign( ∑x<sub>i</sub>w<sub>i</sub>)) x<sub>i</sub></p>
<p>&#8230;where w<sub>i</sub> is the ith weight (real-valued), c is the learning constant (i.e. 0.1), d is the desired output for this node (1 or -1), and x<sub>i</sub> is the input activation (1 or -1).  The input activation term indicates that the input node in question &#8220;contributes&#8221; to the output or &#8220;inhibits&#8221; it.  sign() is given by:</p>
<p>sign(x) = 1 if x ≥ 0, else -1</p>
<p>Here&#8217;s a C++ implementation from my <a href="http://github.com/virgildisgr4ce/Neuroduino">Neuroduino</a> Arduino library:</p>
<pre>int Neuroduino::signThreshold(double sum){
	if (sum &gt;= _net.Theta) {
		return 1;
	} else {
		return -1;
	}
}

double Neuroduino::weightedSum(int l, int node){
	// calculates input activation for a particular neuron
	int i;
	double currentWeight, sum = 0.0;

	for (i=0; i&lt;_net.Layer[l-1]-&gt;Units; i++) {
		currentWeight = _net.Layer[l]-&gt;Weight[node][i];
		sum += currentWeight * _net.Layer[l-1]-&gt;Output[i];
	}

	return sum;
}

void Neuroduino::adjustWeights(int trainArray[]){
	int l,i,j;
	int in,out, error;
	int activation;	// for each "rightmost" node
	double delta;

	for (l=1; l&lt;_numLayers; l++) {
		// cycle through each pair of nodes
		for (i=0; i&lt;_net.Layer[l]-&gt;Units; i++) {
			// "rightmost" layer
			// calculate current activation of this output node
			activation = signThreshold(weightedSum(l,i));
			out = trainArray[i];	// correct activation
			error = out - activation;	// -2, 2, or 0

			for (j=0; j&lt;_net.Layer[l-1]-&gt;Units; j++) {
				// "leftmost" layer

				in = _net.Layer[l-1]-&gt;Output[j];

				delta = _net.Eta * in * error;
				_net.Layer[l]-&gt;Weight[i][j] += delta;
			}
		}
	}
}

void Neuroduino::simulateNetwork(){
	/*****
	 Calculate activations of each output node
	 *****/
	int l,j;

	for (l=_numLayers-1; l&gt;0; l--) {
		// step backwards through layers
		// TODO: this will only work for _numLayers = 2!
		for (j=0; j &lt; _net.Layer[l]-&gt;Units; j++) {
			_output[j] = signThreshold(weightedSum(1, j));
		}
	}
}</pre>
]]></content:encoded>
			<wfw:commentRss>http://log.liminastudio.com/itp/implementing-the-perceptron-rule/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Least Common Multiple algorithm in AS3 / Java</title>
		<link>http://log.liminastudio.com/itp/least-common-multiple-algorithm-in-as3-java</link>
		<comments>http://log.liminastudio.com/itp/least-common-multiple-algorithm-in-as3-java#comments</comments>
		<pubDate>Wed, 14 Apr 2010 21:42:29 +0000</pubDate>
		<dc:creator>Tedb0t</dc:creator>
				<category><![CDATA[ITP]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Writing and Reading Poetry in the Digital Age]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[Math]]></category>

		<guid isPermaLink="false">http://log.liminastudio.com/?p=581</guid>
		<description><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://log.liminastudio.com/itp/least-common-multiple-algorithm-in-as3-java' addthis:title='Least Common Multiple algorithm in AS3 / Java '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div>Today I needed to find the Least Common Multiple of more than 2 numbers for my recombinatory poem tool, and discovered it&#8217;s more of a sophisticated problem than I had initially thought.  Here is my implementation, using recursive greatest common divisor reduction: function gcd(a, b){ // Euclidean algorithm var t; while (b != 0){ t [...]]]></description>
			<content:encoded><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://log.liminastudio.com/itp/least-common-multiple-algorithm-in-as3-java' addthis:title='Least Common Multiple algorithm in AS3 / Java '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div><p>Today I needed to find the <a href="http://en.wikipedia.org/wiki/Least_common_multiple">Least Common Multiple</a> of more than 2 numbers for my recombinatory poem tool, and discovered it&#8217;s more of a sophisticated problem than I had initially thought.  Here is my implementation, using recursive <a href="http://en.wikipedia.org/wiki/Euclidean_algorithm">greatest common divisor</a> reduction:</p>
<pre>function gcd(a, b){
	// Euclidean algorithm
	var t;
	while (b != 0){
		t = b;
		b = a % b;
		a = t;
	}
	return a;
}

function lcm(a, b){
	return (a * b / gcd(a, b));
}

function lcmm(args){
	// Recursively iterate through pairs of arguments
	// i.e. lcm(args[0], lcm(args[1], lcm(args[2], args[3])))

	if(args.length == 2){
		return lcm(args[0], args[1]);
	} else {
		var arg0 = args[0];
		args.shift();
		return lcm(arg0, lcmm(args));
	}
}</pre>
<p>Just pass in an array like so:</p>
<pre>trace(lcmm([1,2,3,4]));</pre>
]]></content:encoded>
			<wfw:commentRss>http://log.liminastudio.com/itp/least-common-multiple-algorithm-in-as3-java/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Gestures on the &lt;canvas&gt;</title>
		<link>http://log.liminastudio.com/itp/gestures-on-the</link>
		<comments>http://log.liminastudio.com/itp/gestures-on-the#comments</comments>
		<pubDate>Sat, 26 Sep 2009 00:59:38 +0000</pubDate>
		<dc:creator>Tedb0t</dc:creator>
				<category><![CDATA[Drawing Machines]]></category>
		<category><![CDATA[ITP]]></category>
		<category><![CDATA[Algorithm]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Recursion]]></category>

		<guid isPermaLink="false">http://log.liminastudio.com/?p=419</guid>
		<description><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://log.liminastudio.com/itp/gestures-on-the' addthis:title='Gestures on the &#60;canvas&#62; '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div>I&#8217;ve begun developing an algorithmic, recursive gestural tree using JavaScript to draw into the HTML5 &#60;canvas&#62; element.  After running into a few initial problems, like discovering I was overflowing my browser stack limit, I progressed to some scribbly sketches. Fixing the locating problems yielded these: I then decided to move towards a continuous, single line composed [...]]]></description>
			<content:encoded><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://log.liminastudio.com/itp/gestures-on-the' addthis:title='Gestures on the &lt;canvas&gt; '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div><p>I&#8217;ve begun developing an algorithmic, recursive gestural tree using JavaScript to draw into the <a href="https://developer.mozilla.org/en/Canvas_tutorial/Drawing_shapes">HTML5 &lt;canvas&gt; element</a>.  After running into a few initial problems, like discovering I was overflowing my <a href="http://tests.novemberborn.net/javascript/callstack-size.html">browser stack limit</a>, I progressed to some scribbly sketches.</p>
<p><a href="http://log.liminastudio.com/wp-content/uploads/2009/09/Picture-1.png"  rel="lightbox[roadtrip]"><img class="alignnone size-thumbnail wp-image-420" title="Picture 1" src="http://log.liminastudio.com/wp-content/uploads/2009/09/Picture-1-150x74.png" alt="Picture 1" width="150" height="74" /></a> <a href="http://log.liminastudio.com/wp-content/uploads/2009/09/Picture-2.png"  rel="lightbox[roadtrip]"><img class="alignnone size-thumbnail wp-image-421" title="Picture 2" src="http://log.liminastudio.com/wp-content/uploads/2009/09/Picture-2-150x150.png" alt="Picture 2" width="150" height="150" /></a> <a href="http://log.liminastudio.com/wp-content/uploads/2009/09/Picture-3.png"  rel="lightbox[roadtrip]"><img class="alignnone size-thumbnail wp-image-422" title="Picture 3" src="http://log.liminastudio.com/wp-content/uploads/2009/09/Picture-3-150x150.png" alt="Picture 3" width="150" height="150" /></a> <a href="http://log.liminastudio.com/wp-content/uploads/2009/09/Picture-4.png"  rel="lightbox[roadtrip]"><img class="alignnone size-thumbnail wp-image-423" title="Picture 4" src="http://log.liminastudio.com/wp-content/uploads/2009/09/Picture-4-150x150.png" alt="Picture 4" width="150" height="150" /></a> <a href="http://log.liminastudio.com/wp-content/uploads/2009/09/Picture-5.png"  rel="lightbox[roadtrip]"><img class="alignnone size-thumbnail wp-image-424" title="Picture 5" src="http://log.liminastudio.com/wp-content/uploads/2009/09/Picture-5-150x150.png" alt="Picture 5" width="150" height="150" /></a></p>
<p><a href="http://liminastudio.com/projects/dm/gestures/test1.html">Fixing the locating problems</a> yielded these:</p>
<p><a href="http://log.liminastudio.com/wp-content/uploads/2009/09/Picture-9.png"  rel="lightbox[roadtrip]"><img class="alignnone size-thumbnail wp-image-435" title="Picture 9" src="http://log.liminastudio.com/wp-content/uploads/2009/09/Picture-9-150x150.png" alt="Picture 9" width="150" height="150" /></a> <a href="http://log.liminastudio.com/wp-content/uploads/2009/09/Picture-10.png"  rel="lightbox[roadtrip]"><img class="alignnone size-thumbnail wp-image-436" title="Picture 10" src="http://log.liminastudio.com/wp-content/uploads/2009/09/Picture-10-150x150.png" alt="Picture 10" width="150" height="150" /></a> <a href="http://log.liminastudio.com/wp-content/uploads/2009/09/Picture-11.png"  rel="lightbox[roadtrip]"><img class="alignnone size-thumbnail wp-image-437" title="Picture 11" src="http://log.liminastudio.com/wp-content/uploads/2009/09/Picture-11-150x150.png" alt="Picture 11" width="150" height="150" /></a> <a href="http://log.liminastudio.com/wp-content/uploads/2009/09/Picture-12.png"  rel="lightbox[roadtrip]"><img class="alignnone size-thumbnail wp-image-438" title="Picture 12" src="http://log.liminastudio.com/wp-content/uploads/2009/09/Picture-12-150x150.png" alt="Picture 12" width="150" height="150" /></a></p>
<p>I then decided to move towards a <a href="http://liminastudio.com/projects/dm/gestures/scribbler_01.html">continuous, single line</a> composed of <a href="http://liminastudio.com/projects/dm/gestures/scribbler_02.html">Bezier segments</a>:</p>
<p><a href="http://log.liminastudio.com/wp-content/uploads/2009/09/Picture-13.png"  rel="lightbox[roadtrip]"><img class="alignnone size-thumbnail wp-image-441" title="Picture 13" src="http://log.liminastudio.com/wp-content/uploads/2009/09/Picture-13-150x150.png" alt="Picture 13" width="150" height="150" /></a> <a href="http://log.liminastudio.com/wp-content/uploads/2009/09/Picture-16.png"  rel="lightbox[roadtrip]"><img class="alignnone size-thumbnail wp-image-442" title="Picture 16" src="http://log.liminastudio.com/wp-content/uploads/2009/09/Picture-16-150x150.png" alt="Picture 16" width="150" height="150" /></a> <a href="http://log.liminastudio.com/wp-content/uploads/2009/09/Picture-17.png"  rel="lightbox[roadtrip]"><img class="alignnone size-thumbnail wp-image-443" title="Picture 17" src="http://log.liminastudio.com/wp-content/uploads/2009/09/Picture-17-150x150.png" alt="Picture 17" width="150" height="150" /></a></p>
<p>This could easily pave the way for a recursive sketching algorithm that composes each Bezier segment from <em>n</em> number of smaller Bezier segments down to a predefined number of levels.  The larger question, in this investigation, remains: what determines the high-level gestures?</p>
]]></content:encoded>
			<wfw:commentRss>http://log.liminastudio.com/itp/gestures-on-the/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

