<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" version="2.0">

<channel>
<title>Hackszine: Math</title>
<link>http://www.hackszine.com/blog/archive/math/</link>
<description>O&apos;Reilly&apos;s Hacks Series reclaims the term &apos;hacking&apos; for the good guys--innovators who explore and experiment, unearth shortcuts, create useful tools, and come up with fun things to try on their own</description>
<language>en-us</language>
<copyright>Copyright 2008, O'Reilly Media, Inc.</copyright>
<lastBuildDate>Sat, 05 Apr 2008 18:49:04 -0800</lastBuildDate>
<pubDate>Mon, 18 Aug 2008 06:13:03 -0800</pubDate>
<generator>http://www.movabletype.org/?v=4.1</generator>
<docs>http://blogs.law.harvard.edu/tech/rss</docs>
<itunes:author>O'Reilly Media, Inc.</itunes:author>
<itunes:subtitle>Clever solutions to interesting problems.</itunes:subtitle>
<itunes:summary>Hackszine Podcast</itunes:summary>
<itunes:owner>
<itunes:email>webmaster@makezine.com</itunes:email>
</itunes:owner>
<category>Technology</category>
<itunes:category text="Technology">
</itunes:category>
<itunes:category text="Technology">
  <itunes:category text="Gadgets" />
</itunes:category>
<itunes:category text="Games &amp; Hobbies" >
</itunes:category>
<itunes:category text="Science">
</itunes:category>
<itunes:image href="http://makezine.com/images/hackszine/rss_icon.jpg" />
<itunes:explicit>no</itunes:explicit>


<item>
<title>HOWTO - Encode any string into a trigonometric function</title>
<itunes:summary>Following Poromenos&apos; nifty &quot;Hello World!&quot; function, Jan Krueger posted a great explanation for why it works along with a general method for producing a trigonometric function for _any_ string you like: The magic behind Poromenos&apos;s function is the Fourier theorem:...</itunes:summary>
<description>
<![CDATA[<p>Following <a href="http://www.hackszine.com/blog/archive/2008/04/poromenos_hello_world_curve.html">Poromenos' nifty "Hello World!" function</a>, Jan Krueger posted a great explanation for why it works along with a general method for producing a trigonometric function for _any_ string you like:</p>

<blockquote>The magic behind Poromenos's function is the Fourier theorem: any "mostly" continuous and periodic function can be expressed as a sum of sines and cosines. I'm not going to bore you with the details; suffice to say that this also works for sampled functions, i.e. discrete series of values.

<p>There's an algorithm called DFT (Discrete Fourier Transform) that takes a series of N complex sample values and generates a corresponding Fourier series which encodes the various sine/cosine coefficients in N complex output values. In the special case of real input values (which is an extremely common case), you can effectively throw away half of these output values and take the remaining N real/imaginary components, do a bit of magic, and end up with coefficients for a function of the form:</p>

<p>f(t) = x0 + x1 cos(t) + x2 sin(t) + x3 cos(2t) + x4 sin(2t) + ...</p>

<p>Now, f(2 pi n/N) returns exactly the (n+1)th character of the original string.</blockquote></p>

<p>Follow the link and you'll find a nifty C program that will produce a trigonometric function for any string you like.</p>

<p><a href="http://jan-krueger.net/development/howto-encode-your-string-trigonometrically">HOWTO: encode a string into a complicated-looking trigonometric function</a></p>]]>
[&lt;a href="http://www.hackszine.com/blog/archive/2008/04/howto_encode_any_string_into_a.html?CMP=OTC-7G2N43923558" /&gt;Read More&lt;/a&gt;]  
[&lt;a href="http://www.hackszine.com/blog/archive/2008/04/howto_encode_any_string_into_a.html?CMP=OTC-7G2N43923558#comments" /&gt;Comments&lt;/a&gt;]
</description>
<link>http://www.hackszine.com/blog/archive/2008/04/howto_encode_any_string_into_a.html?CMP=OTC-7G2N43923558</link>
<guid>http://www.hackszine.com/blog/archive/2008/04/howto_encode_any_string_into_a.html?CMP=OTC-7G2N43923558</guid>
<category>Math</category>
<pubDate>Sat, 05 Apr 2008 18:49:04 -0800</pubDate>

</item>

<item>
<title>Poromenos&apos; hello world curve</title>
<itunes:summary> Take a peek at this curve. If you take the rounded y value for every integer x from 0 through 11, you&apos;ll have yourself the ascii values for the string &quot;Hello world!&quot;. Well, I have a computer architecture exam...</itunes:summary>
<description>
<![CDATA[<p><span class="mt-enclosure mt-enclosure-image" style="display: inline;"><img alt="helloworldgraph_20080402.jpg" src="http://www.hackszine.com/helloworldgraph_20080402.jpg" width="500" height="300" class="mt-image-none" style="" /></span></p>

<p>Take a peek at this curve. If you take the rounded y value for every integer x from 0 through 11, you'll have yourself the ascii values for the string "Hello world!".</p>

<blockquote>Well, I have a computer architecture exam in six hours and can't be bothered, so I figured I would realize a lifelong dream of mine, and make a program that prints "Hello world!" using curve fitting techniques. Enlisting the help of a good friend with numerous mathematical papers under his belt (ostensibly because he could not afford a tighter belt), MATLAB and a longing for procrastination, we embarked on this perilous journey. After many, many hours of fitting and discarding data, I can finally present to you my masterpiece.</blockquote>

<p>It's 12 characters summed from 10 sines and cosines:</p>

<blockquote><code>96.75 - 21.98*cos(x*1.118) + 13.29*sin(x*1.118)  - 8.387*cos(2*x*1.118) + 17.94*sin(2*x*1.118) + 1.265*cos(3*x*1.118) + 16.58*sin(3*x*1.118) + 3.988*cos(4*x*1.118) + 8.463*sin(4*x*1.118) + 0.3583*cos(5*x*1.118) + 5.878*sin(5*x*1.118)</code></blockquote>

<p>Poromenos' blog has the full Python script which evaluates and renders the famous words. Hands down, this is the best math to happen to me all day.</p>

<p><a href="http://www.poromenos.org/node/89">Printing "Hello world!" using curve fitting techniques</a></p>]]>
[&lt;a href="http://www.hackszine.com/blog/archive/2008/04/poromenos_hello_world_curve.html?CMP=OTC-7G2N43923558" /&gt;Read More&lt;/a&gt;]  
[&lt;a href="http://www.hackszine.com/blog/archive/2008/04/poromenos_hello_world_curve.html?CMP=OTC-7G2N43923558#comments" /&gt;Comments&lt;/a&gt;]
</description>
<link>http://www.hackszine.com/blog/archive/2008/04/poromenos_hello_world_curve.html?CMP=OTC-7G2N43923558</link>
<guid>http://www.hackszine.com/blog/archive/2008/04/poromenos_hello_world_curve.html?CMP=OTC-7G2N43923558</guid>
<category>Math</category>
<pubDate>Wed, 02 Apr 2008 21:15:41 -0800</pubDate>

</item>

<item>
<title>Detecting forged photos algorithmically</title>
<itunes:summary> John Graham-Cumming posted an automated tool for detecting &quot;Clone Tool&quot; Photoshop forgeries. Photojournalism ethics issues (LInk, Link) aside, John had some ulterior motives: I was motivated to work on this program by greed (or at least my never-ending love...</itunes:summary>
<description>
<![CDATA[<p><span class="mt-enclosure mt-enclosure-image" style="display: inline;"><img alt="copymove_20080228.jpg" src="http://www.hackszine.com/copymove_20080228.jpg" width="500" height="700" class="mt-image-none" style="" /></span></p>

<p>John Graham-Cumming posted an automated tool for detecting "Clone Tool" Photoshop forgeries. Photojournalism ethics issues (<a href="http://en.wikipedia.org/wiki/Adnan_Hajj_photographs_controversy">LInk</a>, <a href="http://www.berkeleydailyplanet.com/issue/2004-02-17/article/18291">Link</a>) aside, John had some ulterior motives:</p>

<blockquote>I was motivated to work on this program by greed (or at least my never-ending love of having a little flutter on things). Best of the Best runs spot-the-ball competitions in airports to win very expensive cars. But they also run the same competition online. That meant I could get my hands on the actual image used... could I process it to discover where the ball had been removed? (In reality, this isn't the right way to win because the actual ball position is not governed by where it actually was, but where a judge thinks it was).

<p>Would it be cheating if I could? Apparently not, the competition rules say I should use my skill and judgment in determining the ball position. Surely, skill covers my programming ability.</p>

<p>So, I went looking for tampering algorithms and eventually came across Detection of Copy-Move Forgery in Digital Images written by Jessica Fridrich at SUNY Binghamton. The paper describes an algorithm for detecting just the sort of changes I thought I was looking for.</blockquote></p>

<p>Essentially the algorithm cuts the image into a bunch of 16x16 chunks and runs each chunk through a discrete cosine transform. The DCTed chunks are compressed and sorted, and the algorithm looks for multiple matching chunks that were shifted the same direction and distance, highlighting the source image if a large number of matches are found.</p>

<p>Another blogger, jjwiseman, released a speed optimization for John's code, which he successfully used on the infamous Adnan Hajj Reuters images. While the algorithm is able to detect this style of manipulation, it's noted that it has a habit of returning false positives in images with a blurry background.</p>

<p>That said, it'd be pretty interesting to run this through a big database of news photos and see what turns up.</p>

<p>Detection of Copy-Move Forgery in Digital Images -  <a href="http://www.ws.binghamton.edu/fridrich/Research/copymove.pdf">Link</a>  (PDF)<br />
John Graham-Cumming's Clone Tool Detector - <a href="http://www.jgc.org/blog/2008/02/tonight-im-going-to-write-myself-aston.html">Link</a><br />
Protecting Journalistic Integrity Algorithmically (jjwiseman's update) - <a href="http://lemonodor.com/archives/2008/02/protecting_journalistic_integrity_algorithmically.html#c22564">Link</a></p>]]>
[&lt;a href="http://www.hackszine.com/blog/archive/2008/02/detecting_forged_photos_algori.html?CMP=OTC-7G2N43923558" /&gt;Read More&lt;/a&gt;]  
[&lt;a href="http://www.hackszine.com/blog/archive/2008/02/detecting_forged_photos_algori.html?CMP=OTC-7G2N43923558#comments" /&gt;Comments&lt;/a&gt;]
</description>
<link>http://www.hackszine.com/blog/archive/2008/02/detecting_forged_photos_algori.html?CMP=OTC-7G2N43923558</link>
<guid>http://www.hackszine.com/blog/archive/2008/02/detecting_forged_photos_algori.html?CMP=OTC-7G2N43923558</guid>
<category>Photography</category>
<pubDate>Thu, 28 Feb 2008 21:11:08 -0800</pubDate>

</item>

<item>
<title>R: open source statistical computing</title>
<itunes:summary> I was digging around for an open source statistics package today and came across R, a GPLed statistics and and data analysis suite. Sweet! R provides a wide variety of statistical (linear and nonlinear modelling, classical statistical tests, time-series...</itunes:summary>
<description>
<![CDATA[<p><img alt="r_20080131.jpg" src="http://www.hackszine.com/r_20080131.jpg" width="500" height="348" /></p>

<p>I was digging around for an open source statistics package today and came across R, a GPLed statistics and and data analysis suite. Sweet!</p>

<blockquote>R provides a wide variety of statistical (linear and nonlinear modelling, classical statistical tests, time-series analysis, classification, clustering, ...) and graphical techniques, and is highly extensible. The S language is often the vehicle of choice for research in statistical methodology, and R provides an Open Source route to participation in that activity.

<p>One of R's strengths is the ease with which well-designed publication-quality plots can be produced, including mathematical symbols and formulae where needed. Great care has been taken over the defaults for the minor design choices in graphics, but the user retains full control.</blockquote></p>

<p>So I've been messing around with this for the last half hour and it's really an exciting package, especially if you're a coder or unix geek. You interface with R through a command line programming interface, executing simple statements, setting variables, and defining functions. It feels similar to issuing commands at a unix prompt, except you're working with data sets instead of file descriptors. </p>

<p>What's cool is the robust capability of the standard function set. Want to read in a data set from a tab delimited table you found on the internet? Check this out:</p>

<blockquote><code>

<p># Read a table in from a URL (tab delimited table with row headers)<br />
Mydata &lt;- read.table(http://someserver.com/table.txt', header=TRUE)</p>

<p># Display summary (mean, median, min, max, etc.) for each column<br />
summary(Mydata)</p>

<p># Get the standard deviation for the values in column "foo"<br />
attach(Mydata)<br />
sd(foo)<br />
</code></blockquote></p>

<p>Learning the command set is a little daunting at first, but the console even does tab completion. If you don't know what a function does, just put a question mark before it. For instance, "?sd" will quickly pull up help for the standard deviation function.</p>

<p>I've only scratched the surface, but there are links below to some R beginner guides which should help you get started. Anyone out there more familiar with the package? Please share any useful links and tips in the comments.</p>

<p>The R Project for Statistical Computing - <a href="http://www.r-project.org/index.html">Link</a><br />
An Introduction to Statistical Computing in R - <a href="http://socserv.mcmaster.ca/jfox/Courses/UCLA/index.html">Link</a><br />
Producing Simple Graphs with R - <a href="http://www.harding.edu/fmccown/R/">Link</a></p>]]>
[&lt;a href="http://www.hackszine.com/blog/archive/2008/01/r_open_source_statistical_comp.html?CMP=OTC-7G2N43923558" /&gt;Read More&lt;/a&gt;]  
[&lt;a href="http://www.hackszine.com/blog/archive/2008/01/r_open_source_statistical_comp.html?CMP=OTC-7G2N43923558#comments" /&gt;Comments&lt;/a&gt;]
</description>
<link>http://www.hackszine.com/blog/archive/2008/01/r_open_source_statistical_comp.html?CMP=OTC-7G2N43923558</link>
<guid>http://www.hackszine.com/blog/archive/2008/01/r_open_source_statistical_comp.html?CMP=OTC-7G2N43923558</guid>
<category>Statistics</category>
<pubDate>Thu, 31 Jan 2008 20:35:09 -0800</pubDate>

</item>

<item>
<title>Accelerometer motion analysis</title>
<itunes:summary> There&apos;s an article over on the WiiLi Wiki that goes into great detail describing how to translate 3D accelerometer measurements into an estimation of the position, rotation, and velocity of a device like the Wiimote. By making a few...</itunes:summary>
<description>
<![CDATA[<p><img alt="wiirot_20080123.jpg" src="http://www.hackszine.com/wiirot_20080123.jpg" width="500" height="327" /></p>

<p>There's an article over on the WiiLi Wiki that goes into great detail describing how to translate 3D accelerometer measurements into an estimation of the position, rotation, and velocity of a device like the Wiimote. By making a few assumptions&mdash;people's arms have a limited range of motion, most Wii play doesn't take place in moving vehicles, etc.&mdash;it's quite surprising what you can get away with with just the accelerometer data.</p>

<blockquote>The amusingly named (but rarely used) term for the rate of change of acceleration is jerk. The jerk term for the remote shows up in the time derivative of the force recorded by the sensor, along with the rotation term that contains the angular velocity of the remote. We can extract both rotation and linear acceleration if we assume a few things:

<ul><li>We know the "up" direction before the motion starts.</li>
<li>Throughout the motion, the jerk on the remote perpendicular to the current direction of gravity is small.</li></ul>

<p>Then we can assume the time derivative of the force component which is perpendicular to our current estimate of the up direction is caused by the user rotating the controller only. This allows us to update our estimate of the up direction for the next time step. In each time step, we can also get the linear acceleration of the remote by subtracting our estimate of  from the current force sensor report. In effect we are integrating up a coupled set of ordinary differential equations. (Note, need to review the math here. Beware.)</p>

<p>The main problem with this technique is error accumulation in our estimate of "up." Since it is unlikely the user can keep the controller in constant linear motion without injuring themselves, the TV, or their opponent, we can look for times when the total reported force is close to g = 1.0 to recenter . You have to be careful when doing this because it is possible and probably common for the Wiimote to report an acceleration close to g = 1.0 while it is accelerating. When this happens your acceleration vector does not actually point "up" and you will recenter to an incorrect R. This can happen anytime you are accelerating both downward and in the horizontal plane.</blockquote></p>

<p>I keep thinking that there should be some class of flying vehicle that, when operated under fairly restrained conditions, might be able to get by with just accelerometer measurements to obtain reasonably accurate state information. You could integrate the acceleration data through very limited motions that are within some margin of error, recalibrate, and repeat. This is probably a pipe dream, but I really want a solution for a $50 6DOF IMU. :/</p>

<p>Accelerometer motion analysis - <a href="http://www.wiili.org/index.php/Motion_analysis">Link</a></p>]]>
[&lt;a href="http://www.hackszine.com/blog/archive/2008/01/accelerometer_motion_analysis.html?CMP=OTC-7G2N43923558" /&gt;Read More&lt;/a&gt;]  
[&lt;a href="http://www.hackszine.com/blog/archive/2008/01/accelerometer_motion_analysis.html?CMP=OTC-7G2N43923558#comments" /&gt;Comments&lt;/a&gt;]
</description>
<link>http://www.hackszine.com/blog/archive/2008/01/accelerometer_motion_analysis.html?CMP=OTC-7G2N43923558</link>
<guid>http://www.hackszine.com/blog/archive/2008/01/accelerometer_motion_analysis.html?CMP=OTC-7G2N43923558</guid>
<category>Software Engineering</category>
<pubDate>Wed, 23 Jan 2008 22:30:23 -0800</pubDate>

</item>

<item>
<title>Tupper&apos;s Self-Referential Formula</title>
<itunes:summary> Tupper&apos;s Self-Referential Formula is an equation that, when graphed, displays the formula itself. Here&apos;s the equation (same as the image of the output shown at the beginning of this post): Check out the link for the specifics of the...</itunes:summary>
<description>
<![CDATA[<p><img alt="Self-Referential Formula.jpeg" src="http://www.hackszine.com/blog/archive/Self-Referential%20Formula.jpeg" width="449" height="85" /></p>

<p><a href="http://mathworld.wolfram.com/TuppersSelf-ReferentialFormula.html">Tupper's Self-Referential Formula</a> is an equation that, when graphed, displays the formula itself. Here's the equation (same as the image of the output shown at the beginning of this post):</p>

<p><img alt="equation1.gif" src="http://www.hackszine.com/blog/archive/equation1.gif" width="233" height="35" /></p>

<p>Check out the link for the specifics of the functions and values of the variables.</p>

<p><em>(Via <a href="http://www.kottke.org/remainder/07/01/12656.html">kottke</a>)</em></p>]]>
[&lt;a href="http://www.hackszine.com/blog/archive/2007/01/tuppers_selfreferential_formul.html?CMP=OTC-7G2N43923558" /&gt;Read More&lt;/a&gt;]  
[&lt;a href="http://www.hackszine.com/blog/archive/2007/01/tuppers_selfreferential_formul.html?CMP=OTC-7G2N43923558#comments" /&gt;Comments&lt;/a&gt;]
</description>
<link>http://www.hackszine.com/blog/archive/2007/01/tuppers_selfreferential_formul.html?CMP=OTC-7G2N43923558</link>
<guid>http://www.hackszine.com/blog/archive/2007/01/tuppers_selfreferential_formul.html?CMP=OTC-7G2N43923558</guid>
<category>Math</category>
<pubDate>Thu, 25 Jan 2007 07:04:47 -0800</pubDate>

</item>


</channel>
</rss>