<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>My Mathematical Explorations</title>
	<atom:link href="http://math4u.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://math4u.wordpress.com</link>
	<description>Just another WordPress.com weblog</description>
	<lastBuildDate>Fri, 28 Oct 2011 01:48:53 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='math4u.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>My Mathematical Explorations</title>
		<link>http://math4u.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://math4u.wordpress.com/osd.xml" title="My Mathematical Explorations" />
	<atom:link rel='hub' href='http://math4u.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Auditing Hotbits</title>
		<link>http://math4u.wordpress.com/2009/10/07/auditing-hotbits/</link>
		<comments>http://math4u.wordpress.com/2009/10/07/auditing-hotbits/#comments</comments>
		<pubDate>Wed, 07 Oct 2009 15:50:18 +0000</pubDate>
		<dc:creator>perlman</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://math4u.wordpress.com/?p=87</guid>
		<description><![CDATA[Some really cool guy made himself a hardware random number generator using radioactive decay. Particles leaving a decaying isotope are a good source of physical randomness. The frequency with which particles leaving a radioisotope will hit a detector is nice and unpredictable. This guy setup a geiger counter next to some radioisotope and interfaced it [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=math4u.wordpress.com&amp;blog=5462851&amp;post=87&amp;subd=math4u&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Some really cool guy made himself a hardware random number generator using radioactive decay. Particles leaving a decaying isotope are a good source of physical randomness. The frequency with which particles leaving a radioisotope will hit a detector is nice and unpredictable.</p>
<p>This guy setup a geiger counter next to some radioisotope and interfaced it with a computer and now he serves up entropy generated this way through this website:</p>
<p>http://www.fourmilab.ch/hotbits/</p>
<p>lacking a hardware random number generator of my own as of yet, i decided to collect some entropy from here and audit it with autocorrelation. The result is pleasing.</p>
<p><img src="http://math4u.files.wordpress.com/2009/10/hotbits1.png?w=450&#038;h=337" alt="hotbits" title="hotbits" width="450" height="337" class="aligncenter size-full wp-image-89" /></p>
<p>Here is the autocorrelation. I also checked the ratio of values above standard error to values below standard error, and it was less than 5%, which means that we are not seeing periodicity.</p>
<p> sum(cor &gt; 9.233785107408778E-003)/numel(cor)<br />
ans =<br />
    0.013</p>
<p>theres how i did it. </p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/math4u.wordpress.com/87/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/math4u.wordpress.com/87/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/math4u.wordpress.com/87/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/math4u.wordpress.com/87/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/math4u.wordpress.com/87/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/math4u.wordpress.com/87/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/math4u.wordpress.com/87/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/math4u.wordpress.com/87/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/math4u.wordpress.com/87/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/math4u.wordpress.com/87/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/math4u.wordpress.com/87/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/math4u.wordpress.com/87/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/math4u.wordpress.com/87/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/math4u.wordpress.com/87/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=math4u.wordpress.com&amp;blog=5462851&amp;post=87&amp;subd=math4u&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://math4u.wordpress.com/2009/10/07/auditing-hotbits/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/4e13f38185ffdfe9edb3b8992956f834?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">perlman</media:title>
		</media:content>

		<media:content url="http://math4u.files.wordpress.com/2009/10/hotbits1.png" medium="image">
			<media:title type="html">hotbits</media:title>
		</media:content>
	</item>
		<item>
		<title>Autocorrelation on some Genetic Data.</title>
		<link>http://math4u.wordpress.com/2009/10/05/autocorrelation-on-some-genetic-data/</link>
		<comments>http://math4u.wordpress.com/2009/10/05/autocorrelation-on-some-genetic-data/#comments</comments>
		<pubDate>Mon, 05 Oct 2009 15:53:05 +0000</pubDate>
		<dc:creator>perlman</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://math4u.wordpress.com/?p=83</guid>
		<description><![CDATA[I downloaded the genome of some simple microbe. It contained ~5million genes. I took the fafsa format and converted it replace the As,C,s,Gs,and Ts with numbers 1 through 4. Then i passed this through the autocorrelation code i posted previously, using a max autocorr dimension of 2.5million. It took about overnight to compute on my [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=math4u.wordpress.com&amp;blog=5462851&amp;post=83&amp;subd=math4u&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I downloaded the genome of some simple microbe. It contained ~5million genes. I took the fafsa format and converted it replace the As,C,s,Gs,and Ts with numbers 1 through 4. Then i passed this through the autocorrelation code i posted previously, using a max autocorr dimension of 2.5million. It took about overnight to compute on my quadcore. The result is as expected:</p>
<p><img class="aligncenter size-full wp-image-84" title="meth2.5e6" src="http://math4u.files.wordpress.com/2009/10/meth2-5e6.png?w=450&#038;h=337" alt="meth2.5e6" width="450" height="337" /></p>
<p>You can see that very often the autocorrelation is larger than the standard error, so we can say that this stuff is periodic and therefore not random. The standard error is that red line, it is sort of hard to see but trust me its there. Unfortunately the wordpress software makes the image smaller than it really is so it makes it harder to see. </p>
<p>some would argue that this is proof of GODS EXISTENCE OMG!!!!!1!!!</p>
<p>but yeah, it makes sense that a genome should not be random, the development of organisms is bassed of of outside inputs such as: environment, materials(what we are working with), etc. Which affect it at all levels. </p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/math4u.wordpress.com/83/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/math4u.wordpress.com/83/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/math4u.wordpress.com/83/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/math4u.wordpress.com/83/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/math4u.wordpress.com/83/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/math4u.wordpress.com/83/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/math4u.wordpress.com/83/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/math4u.wordpress.com/83/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/math4u.wordpress.com/83/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/math4u.wordpress.com/83/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/math4u.wordpress.com/83/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/math4u.wordpress.com/83/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/math4u.wordpress.com/83/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/math4u.wordpress.com/83/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=math4u.wordpress.com&amp;blog=5462851&amp;post=83&amp;subd=math4u&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://math4u.wordpress.com/2009/10/05/autocorrelation-on-some-genetic-data/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/4e13f38185ffdfe9edb3b8992956f834?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">perlman</media:title>
		</media:content>

		<media:content url="http://math4u.files.wordpress.com/2009/10/meth2-5e6.png" medium="image">
			<media:title type="html">meth2.5e6</media:title>
		</media:content>
	</item>
		<item>
		<title>More: OpenMP</title>
		<link>http://math4u.wordpress.com/2009/09/30/more-openmp/</link>
		<comments>http://math4u.wordpress.com/2009/09/30/more-openmp/#comments</comments>
		<pubDate>Wed, 30 Sep 2009 05:00:36 +0000</pubDate>
		<dc:creator>perlman</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://math4u.wordpress.com/?p=80</guid>
		<description><![CDATA[hey i parallelized this stuff, because we cant be messing around here when i have a quadcore. But there is a catch, the program gives deterministic, but slightly different output than itself compiled without openmp. here is the code: PROGRAM bob USE OMP_lib INTEGER, PARAMETER :: P=140067,M=70000 REAL(8) :: sum,out(M),data(P),VAR,P2,tmp INTEGER :: k,j P2 = [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=math4u.wordpress.com&amp;blog=5462851&amp;post=80&amp;subd=math4u&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>hey i parallelized this stuff, because we cant be messing around here when i have a quadcore. But there is a catch, the program gives deterministic, but slightly different output than itself compiled without openmp.</p>
<p>here is the code:</p>
<pre>
        PROGRAM bob
        USE OMP_lib
        INTEGER, PARAMETER :: P=140067,M=70000
        REAL(8) :: sum,out(M),data(P),VAR,P2,tmp
        INTEGER :: k,j
	P2 = P;
        open (unit = 2, file = "data.txt")
        do k=1,P
                read(2,*) data(k)
        end do
	sum=0
	do k=1,P
                sum = sum + data(k)
        end do
	u = sum/P
        sum = 0
        do k=1,P
               sum = sum + (data(k)-u)*(data(k)-u)
        end do
	VAR = sum/(P-1)
	write (*,*) "STANDARD ERROR:"
	write (*,*) 1.96/SQRT(P2)
	!$OMP PARALLEL PRIVATE(k,tmp,j) DEFAULT(SHARED)
	!$OMP DO
        do k=1,M
                tmp = 0
                do j=k+1,P
                        tmp = tmp + (data(j)-u)*(data(j-k)-u);
                end do
		!$OMP CRITICAL
		out(k) = tmp/(VAR*P)
		!$OMP END CRITICAL
        end do
        !$OMP END DO
        !$OMP END PARALLEL

        open (unit = 7, file = "CORR.txt")
        do k=1,M
                write (7,*) out(k)
        end do

        close(7)
        END PROGRAM
</pre>
<p>if i compile it with openmp it gives me:<br />
1.369807396630835E-003</p>
<p>as the first element of the answer set</p>
<p>if i compile it without openmp it gives me:<br />
1.369807396632110E-003</p>
<p>every other element seems to be the same</p>
<p>this could be a big problem or nothing.</p>
<p>to get around the silly fortran limitations i actually wrote a perl script to take inputs and write out a fortran source and compile it and run it for me, very goofy. but now i can use this code without manually fiddling around everytime i want to run it and it doesnt really slow it down to any appreciable extent. </p>
<p>here is the time for the parrallel code running on a set of about 140k with a max dimension of 70k</p>
<pre>
real	0m3.086s
user	0m9.237s
sys	0m0.168s
</pre>
<p>here it is as it was previously:</p>
<pre>
real	0m7.776s
user	0m7.628s
sys	0m0.148s
</pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/math4u.wordpress.com/80/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/math4u.wordpress.com/80/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/math4u.wordpress.com/80/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/math4u.wordpress.com/80/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/math4u.wordpress.com/80/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/math4u.wordpress.com/80/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/math4u.wordpress.com/80/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/math4u.wordpress.com/80/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/math4u.wordpress.com/80/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/math4u.wordpress.com/80/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/math4u.wordpress.com/80/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/math4u.wordpress.com/80/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/math4u.wordpress.com/80/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/math4u.wordpress.com/80/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=math4u.wordpress.com&amp;blog=5462851&amp;post=80&amp;subd=math4u&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://math4u.wordpress.com/2009/09/30/more-openmp/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/4e13f38185ffdfe9edb3b8992956f834?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">perlman</media:title>
		</media:content>
	</item>
		<item>
		<title>Autocorrelation in Fortran</title>
		<link>http://math4u.wordpress.com/2009/09/30/autocorrelation-in-fortran/</link>
		<comments>http://math4u.wordpress.com/2009/09/30/autocorrelation-in-fortran/#comments</comments>
		<pubDate>Wed, 30 Sep 2009 01:45:45 +0000</pubDate>
		<dc:creator>perlman</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://math4u.wordpress.com/?p=74</guid>
		<description><![CDATA[Well if we are going to be analyzing large sets of random data we cant do it in matlab because matlab is SUPER slow so i wrote some autocorrelation in fortran. fortran is terrible at a lot of modern programming stuff, but its fast. For example, it is a major pain to set a parameter [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=math4u.wordpress.com&amp;blog=5462851&amp;post=74&amp;subd=math4u&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Well if we are going to be analyzing large sets of random data we cant do it in matlab because matlab is SUPER slow</p>
<p>so i wrote some autocorrelation in fortran. fortran is terrible at a lot of modern programming stuff, but its fast. For example, it is a major pain to set a parameter from a command line argument, or to get the length of a file. I am not a master at fortran, so i might just be incompetent but believe me it seems like too much of a pain.</p>
<p>So i have to set the autocorrelation dimension and data set size manually before compiling it. but anyways, here it is:</p>
<pre>
        PROGRAM bob
!       USE OMP_lib
        INTEGER, PARAMETER :: P=140067,M=70000
        REAL(8) :: sum,out(M),data(P),VAR,P2
        INTEGER :: k,j
	P2 = P;
        open (unit = 2, file = "data.txt")
        do k=1,P
                read(2,*) data(k)
        end do
	sum=0
	do k=1,P
                sum = sum + data(k)
        end do
	u = sum/P
        sum = 0
        do k=1,P
               sum = sum + (data(k)-u)*(data(k)-u)
        end do
	VAR = sum/(P-1)
	write (*,*) "STANDARD ERROR:"
	write (*,*) 1.96/SQRT(P2)
        do k=1,M
                out(k) = 0
                do j=k+1,P
                        out(k) = out(k) + (data(j)-u)*(data(j-k)-u);
                end do
		out(k) = out(k)/(VAR*P)
        end do
        open (unit = 7, file = "CORR.txt")
        do k=1,M
                write (7,*) out(k)
        end do
        close(7)
        END PROGRAM
</pre>
<p>the parameter P is the length of the file data.txt, i find it with wc -l. M is the dimension, must be less than half the length of the data set. it outputs a file CORR.txt which is the autocorrelation data to let you load it in matlab with data = load(&#8216;CORR.txt&#8217;). As of now, the input file is a list of numbers seperated by newlines</p>
<p>it rips through the ~140000 element set in a few seconds</p>
<p>future directions will be making it so it can read a binary file and so i dont have to set the damn set length manually and set the correleation dimension at the command line. </p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/math4u.wordpress.com/74/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/math4u.wordpress.com/74/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/math4u.wordpress.com/74/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/math4u.wordpress.com/74/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/math4u.wordpress.com/74/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/math4u.wordpress.com/74/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/math4u.wordpress.com/74/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/math4u.wordpress.com/74/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/math4u.wordpress.com/74/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/math4u.wordpress.com/74/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/math4u.wordpress.com/74/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/math4u.wordpress.com/74/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/math4u.wordpress.com/74/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/math4u.wordpress.com/74/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=math4u.wordpress.com&amp;blog=5462851&amp;post=74&amp;subd=math4u&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://math4u.wordpress.com/2009/09/30/autocorrelation-in-fortran/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/4e13f38185ffdfe9edb3b8992956f834?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">perlman</media:title>
		</media:content>
	</item>
		<item>
		<title>Gauss-Chebyshev Quadrature</title>
		<link>http://math4u.wordpress.com/2009/09/24/gauss-chebyshev-quadrature/</link>
		<comments>http://math4u.wordpress.com/2009/09/24/gauss-chebyshev-quadrature/#comments</comments>
		<pubDate>Thu, 24 Sep 2009 06:22:24 +0000</pubDate>
		<dc:creator>perlman</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://math4u.wordpress.com/?p=72</guid>
		<description><![CDATA[I wrote some code to approximate an integral using Gauss-Chebyshev Quadrature in matlab. It takes an arbitrary function inputed as a string and gives you the integral from $math \left[a,b\right]$ using a desired number of points. example: chebquad(&#8216;exp(-x.^2)&#8217;,2000,-100,100) function int = chebquad(funct,n,a,b); f = inline(funct); x = cos(((2*(1:n) - 1)/(2*n))*pi); w = pi/n; fx = [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=math4u.wordpress.com&amp;blog=5462851&amp;post=72&amp;subd=math4u&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I wrote some code to approximate an integral using Gauss-Chebyshev Quadrature in matlab. It takes an arbitrary function inputed as a string and gives you the integral from $math \left[a,b\right]$ using a desired number of points.<br />
 example:<br />
chebquad(&#8216;exp(-x.^2)&#8217;,2000,-100,100)</p>
<pre>
function int = chebquad(funct,n,a,b);
f = inline(funct);
x = cos(((2*(1:n) - 1)/(2*n))*pi);
w = pi/n;
fx = ((b-a)/2)*f(((b-a)/2)*x + (b+a)/2).*sqrt(1-x.^2);
int = sum(w.*fx);
</pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/math4u.wordpress.com/72/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/math4u.wordpress.com/72/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/math4u.wordpress.com/72/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/math4u.wordpress.com/72/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/math4u.wordpress.com/72/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/math4u.wordpress.com/72/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/math4u.wordpress.com/72/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/math4u.wordpress.com/72/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/math4u.wordpress.com/72/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/math4u.wordpress.com/72/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/math4u.wordpress.com/72/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/math4u.wordpress.com/72/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/math4u.wordpress.com/72/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/math4u.wordpress.com/72/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=math4u.wordpress.com&amp;blog=5462851&amp;post=72&amp;subd=math4u&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://math4u.wordpress.com/2009/09/24/gauss-chebyshev-quadrature/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/4e13f38185ffdfe9edb3b8992956f834?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">perlman</media:title>
		</media:content>
	</item>
		<item>
		<title>Paralellization of the code for Fermats Method</title>
		<link>http://math4u.wordpress.com/2009/03/10/paralellization-of-the-code-for-fermats-method/</link>
		<comments>http://math4u.wordpress.com/2009/03/10/paralellization-of-the-code-for-fermats-method/#comments</comments>
		<pubDate>Tue, 10 Mar 2009 01:49:28 +0000</pubDate>
		<dc:creator>perlman</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://math4u.wordpress.com/?p=65</guid>
		<description><![CDATA[Well, using MPI, it was VERY easy to parallelize the code in the previous post, it was way too easy. goal was to make each thread take different sequential &#8220;guess&#8221; values for When you initialize and MPI program you have two important values for each instance of the program running, the rank, and the size. [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=math4u.wordpress.com&amp;blog=5462851&amp;post=65&amp;subd=math4u&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Well, using MPI, it was VERY easy to parallelize the code in the previous post, it was way too easy.</p>
<p>goal was to make each thread take different sequential &#8220;guess&#8221; values for <img src='http://s0.wp.com/latex.php?latex=a&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='a' title='a' class='latex' /></p>
<p>When you initialize and MPI program you have two important values for each instance of the program running, the rank, and the size. The rank is an identification number assaigned to each instance, starting with 0, ending with the size less 1. The size, obviously, is the number of instances we are running.</p>
<p>So what i did was add the rank to the initial value for the loop, then I added the size to the loop variable <img src='http://s0.wp.com/latex.php?latex=a+&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='a ' title='a ' class='latex' /> every step. So that instead of one loop running adding 1 every time, we have <img src='http://s0.wp.com/latex.php?latex=n+&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='n ' title='n ' class='latex' /> loops running adding <img src='http://s0.wp.com/latex.php?latex=n+&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='n ' title='n ' class='latex' /> every time. They are initially offset by their rank so that each instance will take on different values.</p>
<p>here is the code:</p>
<pre>#include &lt;stdlib.h&gt;
#include &lt;stdio.h&gt;
#include &lt;stdarg.h&gt;
#include &lt;gmp.h&gt;
#include "mpi.h"

int main (int argc, char *argv[]){
  int rank,size;
  MPI_Init(&amp;argc, &amp;argv);
  MPI_Comm_rank(MPI_COMM_WORLD, &amp;rank);
  MPI_Comm_size(MPI_COMM_WORLD, &amp;size);

  char		sho [300];
  mpz_t		N; /* For final computation results */
  mpz_t		A,As,B,Bsq,Bsho,Bs;
  mpz_init_set_str (N, "75557863657023047991947", 10);
  mpz_init(A);
  mpz_init(Bsq);
  mpz_init_set_str(Bs,"1",10);
    mpz_init(Bsho);
    mpz_init(As);
   mpz_init_set_str(B,"2",10);
  mpz_sqrt(A,N);
  mpz_add_ui(A,A,rank);
  while( mpz_cmp(Bs,B) != 0){
   mpz_get_str(sho,10,A);
   /*printf("%s - %i\n",sho,rank);*/
   mpz_add_ui(A,A,size);
   mpz_pow_ui(As,A,2);
   mpz_sub(B,As,N);
   mpz_sqrt(Bsq,B);
   mpz_pow_ui(Bs,Bsq,2);
  }
  mpz_sqrt(Bsq,B);
  mpz_sub(Bsho,A,Bsq);
  mpz_get_str(sho,10,Bsho);
  printf("%s\n",sho);
  mpz_cdiv_q(As,N,Bsho);
  mpz_get_str(sho,10,As);
  printf("%s\n",sho);
  MPI_Abort(MPI_COMM_WORLD,1);
  return 0;
}</pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/math4u.wordpress.com/65/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/math4u.wordpress.com/65/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/math4u.wordpress.com/65/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/math4u.wordpress.com/65/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/math4u.wordpress.com/65/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/math4u.wordpress.com/65/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/math4u.wordpress.com/65/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/math4u.wordpress.com/65/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/math4u.wordpress.com/65/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/math4u.wordpress.com/65/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/math4u.wordpress.com/65/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/math4u.wordpress.com/65/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/math4u.wordpress.com/65/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/math4u.wordpress.com/65/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=math4u.wordpress.com&amp;blog=5462851&amp;post=65&amp;subd=math4u&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://math4u.wordpress.com/2009/03/10/paralellization-of-the-code-for-fermats-method/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/4e13f38185ffdfe9edb3b8992956f834?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">perlman</media:title>
		</media:content>
	</item>
		<item>
		<title>Fermats Factorization method: Implemented in C with GMP</title>
		<link>http://math4u.wordpress.com/2009/03/10/fermats-factorization-method-implemented-in-c-with-gmp/</link>
		<comments>http://math4u.wordpress.com/2009/03/10/fermats-factorization-method-implemented-in-c-with-gmp/#comments</comments>
		<pubDate>Tue, 10 Mar 2009 00:57:25 +0000</pubDate>
		<dc:creator>perlman</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://math4u.wordpress.com/?p=62</guid>
		<description><![CDATA[Searching for more factorization methods i found fermats method. It is not faster than trial division, but it can be used in combination with trial division to make a faster method. I have the code currently implemented in C with GMP, no MPI yet. Fermats method uses difference of squares to accomplish our task: $;atex [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=math4u.wordpress.com&amp;blog=5462851&amp;post=62&amp;subd=math4u&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Searching for more factorization methods i found fermats method. It is not faster than trial division, but it can be used in combination with trial division to make a faster method. I have the code currently implemented in C with GMP, no MPI yet.</p>
<p>Fermats method uses difference of squares to accomplish our task: $;atex N = p*q = a^2 &#8211; b^2$ We guess <img src='http://s0.wp.com/latex.php?latex=a&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='a' title='a' class='latex' /> until we have a <img src='http://s0.wp.com/latex.php?latex=b&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='b' title='b' class='latex' /> that is a perfect square.</p>
<pre>#include &lt;stdlib.h&gt;
#include &lt;stdio.h&gt;
#include &lt;stdarg.h&gt;
#include &lt;gmp.h&gt;
/*#include "mpi.h"*/
int main (int argc, char *argv[]){
  char		sho [300];
  mpz_t		N; /* For final computation results */
  mpz_t		A,As,B,Bsq,Bsho,Bs;
  mpz_init_set_str (N, "2533965587", 10);
  mpz_init(A);
  mpz_init(Bsq);
  mpz_init_set_str(Bs,"1",10);
    mpz_init(Bsho);
    mpz_init(As);
   mpz_init_set_str(B,"2",10);
  mpz_sqrt(A,N);
  while( mpz_cmp(Bs,B) != 0){
   mpz_add_ui(A,A,1);
   mpz_pow_ui(As,A,2);
   mpz_sub(B,As,N);
   mpz_sqrt(Bsq,B);
   mpz_pow_ui(Bs,Bsq,2);
  }
  mpz_sqrt(Bsq,B);
  mpz_sub(Bsho,A,Bsq);
  mpz_get_str(sho,10,Bsho);
  printf("%s\n",sho);
  mpz_cdiv_q(As,N,Bsho);
  mpz_get_str(sho,10,As);
  printf("%s\n",sho);
  return 0;
}</pre>
<p>I used GMP so that any size integer may be handled, though it is probably not necisary for any numbers that i can factor with this computer in a timely manner. This method forms the basis for the Quadratic sieve, the second fastest algorithm for this prime factorization problem. The most challenging aspect of implementing the quadratic sieve seems to be evaluating the prime counting function <img src='http://s0.wp.com/latex.php?latex=%5Cpi%28n%29&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;pi(n)' title='&#92;pi(n)' class='latex' /> . I know there actually is some approximation of this, some sum that converges to it&#8230; That all relates to the riemann hypothesis. It may be very ahrd to implement. I will have to look into it.</p>
<p>The fastest algorithm is the Generalized Number Field Sieve, very hard to implement. It is stated on wikipedia that a working implementation would be a reasonable master&#8217;s thesis. whew</p>
<p>Current goals for this thread of work are:</p>
<li>make a MPI parallelized implementation of fermat combined with trial division</li>
<li>implement the quadratic sieve eventually? seems doable</li>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/math4u.wordpress.com/62/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/math4u.wordpress.com/62/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/math4u.wordpress.com/62/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/math4u.wordpress.com/62/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/math4u.wordpress.com/62/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/math4u.wordpress.com/62/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/math4u.wordpress.com/62/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/math4u.wordpress.com/62/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/math4u.wordpress.com/62/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/math4u.wordpress.com/62/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/math4u.wordpress.com/62/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/math4u.wordpress.com/62/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/math4u.wordpress.com/62/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/math4u.wordpress.com/62/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=math4u.wordpress.com&amp;blog=5462851&amp;post=62&amp;subd=math4u&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://math4u.wordpress.com/2009/03/10/fermats-factorization-method-implemented-in-c-with-gmp/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/4e13f38185ffdfe9edb3b8992956f834?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">perlman</media:title>
		</media:content>
	</item>
		<item>
		<title>Some C and MPI: Arbitrary Precision Arithmatic and Prime Factorizations</title>
		<link>http://math4u.wordpress.com/2009/02/28/some-c-arbitrary-precision-arithmatic-and-prime-factorizations/</link>
		<comments>http://math4u.wordpress.com/2009/02/28/some-c-arbitrary-precision-arithmatic-and-prime-factorizations/#comments</comments>
		<pubDate>Sat, 28 Feb 2009 02:14:12 +0000</pubDate>
		<dc:creator>perlman</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://math4u.wordpress.com/?p=46</guid>
		<description><![CDATA[I have been writing code in fortran a bit, to do a simple prime factorization by dividing. Specifically for breaking RSA. So I assume that there are two prime factors and that they are relatively large. is part of the public key, if someone can factor N into its primes, they can get which then [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=math4u.wordpress.com&amp;blog=5462851&amp;post=46&amp;subd=math4u&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I have been writing code in fortran a bit, to do a simple prime factorization by dividing. Specifically for breaking RSA. So I assume that there are two prime factors and that they are relatively large. <img src='http://s0.wp.com/latex.php?latex=N+%3D+pq&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='N = pq' title='N = pq' class='latex' /> is part of the public key, if someone can factor N into its primes, they can get <img src='http://s0.wp.com/latex.php?latex=M+%3D+%5CPhi%28N%29+%3D+%28p-1%29%2A%28q-1%29&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='M = &#92;Phi(N) = (p-1)*(q-1)' title='M = &#92;Phi(N) = (p-1)*(q-1)' class='latex' /> which then allows one to calculate the private keys.</p>
<p>Cryptology aside, i have been meaning to pick up some C. So today happened to be the day i started, and largely because of the GMP &#8211; Gnu Multi Precision arithmetic library.</p>
<p>Well i needed the multiprecision arithmetic to deal with numbers as large as $N$ comes for RSA. my algorithm works exploiting two things, the fact that: <img src='http://s0.wp.com/latex.php?latex=p+%3C+%5Csqrt%7BN%7D+%3C+q&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='p &lt; &#92;sqrt{N} &lt; q' title='p &lt; &#92;sqrt{N} &lt; q' class='latex' /> and that even numbers will never be candidates. It also takes advantage of the modulus, the modulus is cheap computationally(I believe its very basic to a computer). Also, it assumes that the p and q may be close to <img src='http://s0.wp.com/latex.php?latex=%5Csqrt%7BN%7D&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;sqrt{N}' title='&#92;sqrt{N}' class='latex' /> more often than not.</p>
<p>Here is what happens:</p>
<li>take <img src='http://s0.wp.com/latex.php?latex=S+%3D+%5Csqrt%7BN%7D&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='S = &#92;sqrt{N}' title='S = &#92;sqrt{N}' class='latex' /></li>
<li>round it off and add one to it if its even(make it odd)</li>
<li>start a for loop from S to 3, incremented in twos</li>
<li>if <img src='http://s0.wp.com/latex.php?latex=0+%3D+N+%5Cmod%7B+i%7D&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='0 = N &#92;mod{ i}' title='0 = N &#92;mod{ i}' class='latex' /> then you have it, divide out and print answer
<pre>#include &lt;stdlib.h&gt;
#include &lt;stdio.h&gt;
#include &lt;stdarg.h&gt;
#include &lt;gmp.h&gt;
#include "mpi.h"
int main (int argc, char *argv[]){
    int rank,size;
  unsigned long int	i;
  int        m;
  char		res [300], sho [300];
  MPI_Init(&amp;argc, &amp;argv);
  MPI_Comm_rank(MPI_COMM_WORLD, &amp;rank);
  MPI_Comm_size(MPI_COMM_WORLD, &amp;size); /* initializing MPI, collecting info about environment*/
  mpz_t		N;
  mpz_t		D,S,I,ds,Ss,Se;
  mpz_init(D);
  mpz_init(S);
  mpz_init(Ss);
  mpz_init(Se);
  mpz_init(ds);
    mpz_init(I);
  mpz_init_set_str (N, "951481467360591658636268654185633689926419097", 10);
  mpz_sqrt(S,N);
  mpz_cdiv_q_ui(ds,S,size); /* divvy up lims for loop! */
  mpz_mul_si(Se,ds,rank);
  mpz_add(Ss,Se,ds);
    if ((mpz_divisible_ui_p(Ss,2)) != 0){
        mpz_add_ui(Ss,Ss,1);
    }

  for (mpz_set(I,Ss);mpz_cmp(I,Se)&gt;0;mpz_sub_ui(I,I,2)) {
    m = mpz_divisible_p(N,I);
    if ((mpz_divisible_ui_p(I,100000001)) != 0){
	mpz_get_str(sho,10,I);
	printf("%s\n",sho);
    }
    if (m != 0){
         mpz_get_str(sho,10,I);
	printf("YAY\n%s\n",sho);
	mpz_cdiv_q(D,N,I)	;
	mpz_get_str(res,10,D);
	printf("\n%s\n", res);
	 	MPI_Abort(MPI_COMM_WORLD, 1); /* Tell all threads to exit(1)*/
    }
  }

  return 0;
}</pre>
<p>So there it is, i uopdated the post cause the last code i had posted was terrible&#8230;.</p>
<p>I added MPI to this, which is beautiful. My first implementation using MPI&#8230;</p>
<p>This code isnt going to factor that number unless you have a cluster&#8230; Next step is smarter faster algorithms. Next post dealing with this subject should be just that&#8230; parallelization of these things makes it much more interesting too.</li>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/math4u.wordpress.com/46/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/math4u.wordpress.com/46/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/math4u.wordpress.com/46/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/math4u.wordpress.com/46/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/math4u.wordpress.com/46/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/math4u.wordpress.com/46/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/math4u.wordpress.com/46/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/math4u.wordpress.com/46/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/math4u.wordpress.com/46/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/math4u.wordpress.com/46/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/math4u.wordpress.com/46/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/math4u.wordpress.com/46/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/math4u.wordpress.com/46/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/math4u.wordpress.com/46/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=math4u.wordpress.com&amp;blog=5462851&amp;post=46&amp;subd=math4u&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://math4u.wordpress.com/2009/02/28/some-c-arbitrary-precision-arithmatic-and-prime-factorizations/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/4e13f38185ffdfe9edb3b8992956f834?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">perlman</media:title>
		</media:content>
	</item>
		<item>
		<title>A little more on image processing</title>
		<link>http://math4u.wordpress.com/2009/02/19/a-little-more-on-image-processing/</link>
		<comments>http://math4u.wordpress.com/2009/02/19/a-little-more-on-image-processing/#comments</comments>
		<pubDate>Thu, 19 Feb 2009 13:25:35 +0000</pubDate>
		<dc:creator>perlman</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://math4u.wordpress.com/2009/02/19/a-little-more-on-image-processing/</guid>
		<description><![CDATA[I wanted to say a few more little things about adjusting the color distribution of images. Contrast translates to the standard deviation of the distribution of pixel values. When looking at an image what you really want is a close to uniform distribution of colors. This will allow the color map to be used more [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=math4u.wordpress.com&amp;blog=5462851&amp;post=43&amp;subd=math4u&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I wanted to say a few more little things about adjusting the color distribution of images. </p>
<p>Contrast translates to the standard deviation of the distribution of pixel values. </p>
<p>When looking at an image what you really want is a close to uniform distribution of colors. This will allow the color map to be used more effectively, more colors will be used so there is more for your eye to see.</p>
<p>Effectively, messing with these arithmatic transforms allows us to change how colors are being assaigned without disturbing the shapes and structures within the image. We are more concerned with the fact that there is as difference in the colors between different areas of the image than the magnitude of this difference.</p>
<p>these transforms change the magnitude of these differences, preserving the fact that there is as difference, so we still are looking at the same shapes. </p>
<p>A more advanced method would involve mapping the pixel value distribution of your image to another distribution directly. </p>
<p>Main thing i meant to say here is that you want a close to uniform distribution of values in your image to fully utilize your color map. </p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/math4u.wordpress.com/43/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/math4u.wordpress.com/43/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/math4u.wordpress.com/43/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/math4u.wordpress.com/43/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/math4u.wordpress.com/43/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/math4u.wordpress.com/43/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/math4u.wordpress.com/43/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/math4u.wordpress.com/43/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/math4u.wordpress.com/43/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/math4u.wordpress.com/43/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/math4u.wordpress.com/43/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/math4u.wordpress.com/43/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/math4u.wordpress.com/43/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/math4u.wordpress.com/43/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=math4u.wordpress.com&amp;blog=5462851&amp;post=43&amp;subd=math4u&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://math4u.wordpress.com/2009/02/19/a-little-more-on-image-processing/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/4e13f38185ffdfe9edb3b8992956f834?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">perlman</media:title>
		</media:content>
	</item>
		<item>
		<title>Some basic image filtering</title>
		<link>http://math4u.wordpress.com/2009/02/13/some-basic-image-filtering/</link>
		<comments>http://math4u.wordpress.com/2009/02/13/some-basic-image-filtering/#comments</comments>
		<pubDate>Fri, 13 Feb 2009 02:00:01 +0000</pubDate>
		<dc:creator>perlman</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://math4u.wordpress.com/?p=36</guid>
		<description><![CDATA[I figured i would let you guys see some of the basic methods i use for image filtering. Sometimes you may have an image that has a strange or very skewed color/intensity distribution. The counts may all be very high due to some factor in what your imaging, or they may be too low. The [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=math4u.wordpress.com&amp;blog=5462851&amp;post=36&amp;subd=math4u&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I figured i would let you guys see some of the basic methods i use for image filtering. Sometimes you may have an image that has a strange or very skewed color/intensity distribution. The counts may all be very high due to some factor in what your imaging, or they may be too low. The image may be too faint, or too intense so that one may not be able to see the details properly. Well there are remedies to this. You can use simple image filtering to adjust the color/intensity distribution to suite your needs. Its much easier than you think.</p>
<p><strong>Log Filtering</strong><br />
If an image is too faint so that details refuse to show up, log filtering can increase the visibility of otherwise faint structures. This applys when the distribution of colors/intensity is too large tailed, the range is very large. This causes imaging techniques to assigned their colormaps in a very skewed way. The log reduces the range of the data, making it more normal aswell. The distances between the intensity values are lowered. </p>
<p>Here is a quick little matlab function i wrote to perform log filtering with normalization to keep results predictable.</p>
<pre>
function A = logfilt(A)
A = A/max(max(A));
A = (A*256);%adjust this max to adjust strength, larger makes it have more effect
A = log10(A+1);%add 1 so not to take log(0)
A = A/max(max(A));
A = (A*256);
</pre>
<p><strong> Exponential filtering</strong><br />
If an image is too intense, IE: the whole thing is white. Then the values are too close together, intensity/color distribution is too spikey. The pixel values get assigned poorly, such that far too many pixels have the same value. This can be remedied by increasing the distance between all the intensity values. This will spread the distribution of intensity out so that the color map will be assigned properly so that we can see the differences between pixels better. The distances between intensity values are increased.  </p>
<p>Here is a matlab function same as above only for exp filtering:</p>
<pre>
function A = expfilt(A)
A = A/max(max(A));
A = (A*2);%adjust this multiple to change the strength, make it larger and it has more effect
A = exp(A)-1; %minus 1 to change the 1s to 0s as they were prefilter
A = A/max(max(A));
A = (A*256);
</pre>
<p><strong>Square root filtering</strong><br />
The square root works just like the log only it is inherently weaker. This is a good thing, because sometimes a log is far too much.</p>
<p>I wrote an analogous script&#8230;</p>
<pre>
function A = sqrtfilt(A)
A = A/max(max(A));
A = A*256;%larger and its stronger
A = sqrt(A);
A = A/max(max(A));
A = (A*256);
</pre>
<p>Trial and error is how you will learn to use these. using these tecniques in combination can turn a totally incoherent image into a very good looking thing, showing all the details.  I may add some images to this post later but at this time Im not feeling it.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/math4u.wordpress.com/36/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/math4u.wordpress.com/36/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/math4u.wordpress.com/36/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/math4u.wordpress.com/36/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/math4u.wordpress.com/36/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/math4u.wordpress.com/36/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/math4u.wordpress.com/36/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/math4u.wordpress.com/36/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/math4u.wordpress.com/36/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/math4u.wordpress.com/36/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/math4u.wordpress.com/36/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/math4u.wordpress.com/36/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/math4u.wordpress.com/36/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/math4u.wordpress.com/36/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=math4u.wordpress.com&amp;blog=5462851&amp;post=36&amp;subd=math4u&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://math4u.wordpress.com/2009/02/13/some-basic-image-filtering/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/4e13f38185ffdfe9edb3b8992956f834?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">perlman</media:title>
		</media:content>
	</item>
	</channel>
</rss>
