<?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>Matt Daubneys Blog &#187; graphs</title>
	<atom:link href="http://daubers.co.uk/tag/graphs/feed/" rel="self" type="application/rss+xml" />
	<link>http://daubers.co.uk</link>
	<description></description>
	<lastBuildDate>Sat, 31 Dec 2011 17:08:35 +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>Denyhosts Stats</title>
		<link>http://daubers.co.uk/2009/05/25/denyhosts-stats/</link>
		<comments>http://daubers.co.uk/2009/05/25/denyhosts-stats/#comments</comments>
		<pubDate>Mon, 25 May 2009 14:44:20 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[ubuntu]]></category>
		<category><![CDATA[webbyness]]></category>
		<category><![CDATA[denyhosts]]></category>
		<category><![CDATA[graphs]]></category>
		<category><![CDATA[matplotlib]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[stats]]></category>

		<guid isPermaLink="false">http://daubers.co.uk/?p=187</guid>
		<description><![CDATA[I have been told many many times that moving ssh to a different port (i.e. other than 22) makes your machine more secure. I do see some wisdom in this, however, I&#8217;ve decided to put it to the test. I have been using Denyhosts to stop brute force attacks on my ssh servers for some [...]]]></description>
			<content:encoded><![CDATA[<p>I have been told many many times that moving ssh to a different port (i.e. other than 22) makes your machine more secure. I do see some wisdom in this, however, I&#8217;ve decided to put it to the test. I have been using Denyhosts to stop brute force attacks on my ssh servers for some time now, and on my most recent server, the attacks per day are fairly regular, as seen in the graph.</p>
<p style="text-align: left;">
<div id="attachment_188" class="wp-caption aligncenter" style="width: 490px"><a href="http://daubers.co.uk/wp-content/uploads/2009/05/plot.png"><img class="size-full wp-image-188" title="Plot of Deny Hosts Blocks per Day" src="http://daubers.co.uk/wp-content/uploads/2009/05/plot.png" alt="Plot of Deny Hosts Blocks per Day" width="480" height="360" /></a><p class="wp-caption-text">Plot of Deny Hosts Blocks per Day</p></div>
<p style="text-align: left;">At the end of June I will stop using port 22 and start using another random port. I&#8217;ll then collect data for 3 months and at the end of september do another blog post showing the difference. I also have another server that I will repeat this experiment on, but that one will be 3 months behind.</p>
<p style="text-align: left;">Hopefully then I will have a nice sturdy scientific answer as to how much more protection moving ssh to a different port gives <img src='http://daubers.co.uk/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p style="text-align: left;">The code I used to generate this graph is given below for reference.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
</pre></td><td class="code"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">os</span>
<span style="color: #ff7700;font-weight:bold;">import</span> matplotlib
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">datetime</span>
<span style="color: #ff7700;font-weight:bold;">import</span> matplotlib.<span style="color: black;">pyplot</span> <span style="color: #ff7700;font-weight:bold;">as</span> plt
<span style="color: #ff7700;font-weight:bold;">import</span> matplotlib.<span style="color: black;">dates</span> <span style="color: #ff7700;font-weight:bold;">as</span> mdates
<span style="color: #ff7700;font-weight:bold;">import</span> matplotlib.<span style="color: black;">mlab</span> <span style="color: #ff7700;font-weight:bold;">as</span> mlab
matplotlib.<span style="color: black;">use</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'Agg'</span><span style="color: black;">&#41;</span>
&nbsp;
&nbsp;
datelist = <span style="color: black;">&#123;</span><span style="color: black;">&#125;</span>
rootdir = <span style="color: #483d8b;">'./'</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">def</span> plot_all<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>:
	<span style="color: #808080; font-style: italic;">#first convert dict to a set of x values and a set of y values</span>
	keys = datelist.<span style="color: black;">keys</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
	keys.<span style="color: black;">sort</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
	values = <span style="color: black;">&#91;</span><span style="color: black;">&#93;</span>
	times = <span style="color: black;">&#91;</span><span style="color: black;">&#93;</span>
	<span style="color: #ff7700;font-weight:bold;">for</span> key <span style="color: #ff7700;font-weight:bold;">in</span> keys:
		values.<span style="color: black;">append</span><span style="color: black;">&#40;</span>datelist<span style="color: black;">&#91;</span>key<span style="color: black;">&#93;</span><span style="color: black;">&#41;</span>
	<span style="color: #808080; font-style: italic;">#now convert the keys into time format</span>
		times.<span style="color: black;">append</span><span style="color: black;">&#40;</span><span style="color: #dc143c;">datetime</span>.<span style="color: #dc143c;">datetime</span>.<span style="color: black;">strptime</span><span style="color: black;">&#40;</span>key, <span style="color: #483d8b;">&quot;%Y-%m-%d&quot;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
&nbsp;
	<span style="color: #808080; font-style: italic;">#now we're ready to plot with matplotlib</span>
	months   = mdates.<span style="color: black;">MonthLocator</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>  <span style="color: #808080; font-style: italic;"># every month</span>
	days	= mdates.<span style="color: black;">DayLocator</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
	yearsFmt = mdates.<span style="color: black;">DateFormatter</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'%b'</span><span style="color: black;">&#41;</span>
	dayFmt = mdates.<span style="color: black;">DateFormatter</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'%d'</span><span style="color: black;">&#41;</span>
&nbsp;
	fig = plt.<span style="color: black;">figure</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
	ax = fig.<span style="color: black;">add_subplot</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">111</span><span style="color: black;">&#41;</span>
	dates = <span style="color: #008000;">range</span><span style="color: black;">&#40;</span>times<span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span>.<span style="color: black;">toordinal</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>, times<span style="color: black;">&#91;</span>-<span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span>.<span style="color: black;">toordinal</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span> 
	ax.<span style="color: black;">bar</span><span style="color: black;">&#40;</span>times,values,width=<span style="color: #ff4500;">1</span><span style="color: black;">&#41;</span>
&nbsp;
	ax.<span style="color: black;">set_xlabel</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'Date'</span><span style="color: black;">&#41;</span>
	ax.<span style="color: black;">set_ylabel</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'Number of Hosts Denied'</span><span style="color: black;">&#41;</span>
&nbsp;
	<span style="color: #808080; font-style: italic;">#ax.plot(times, values)</span>
	<span style="color: #808080; font-style: italic;">#ax.xaxis.set_major_formatter(yearsFmt)</span>
	<span style="color: #808080; font-style: italic;">#ax.xaxis.set_major_locator(months)</span>
	<span style="color: #808080; font-style: italic;">#ax.xaxis.set_minor_formatter(dayFmt)</span>
	<span style="color: #808080; font-style: italic;">#ax.xaxis.set_minor_locator(days)</span>
	ax.<span style="color: black;">format_xdata</span> = mdates.<span style="color: black;">DateFormatter</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'%Y-%m-%d'</span><span style="color: black;">&#41;</span>
	fig.<span style="color: black;">autofmt_xdate</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
        fig.<span style="color: black;">savefig</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;plot.png&quot;</span><span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">def</span> countup<span style="color: black;">&#40;</span><span style="color: #008000;">file</span><span style="color: black;">&#41;</span>:
	f = <span style="color: #008000;">open</span><span style="color: black;">&#40;</span><span style="color: #008000;">file</span>, <span style="color: #483d8b;">'r'</span><span style="color: black;">&#41;</span>
	<span style="color: #ff7700;font-weight:bold;">for</span> line <span style="color: #ff7700;font-weight:bold;">in</span> f.<span style="color: black;">readlines</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>:
		<span style="color: #808080; font-style: italic;">#split by spaces to get the date</span>
		line = line.<span style="color: black;">split</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot; &quot;</span><span style="color: black;">&#41;</span>
		<span style="color: #808080; font-style: italic;">#now see if this is already in the list</span>
		newline = <span style="color: #008000;">False</span>	
		<span style="color: #ff7700;font-weight:bold;">for</span> part <span style="color: #ff7700;font-weight:bold;">in</span> line:
			<span style="color: #ff7700;font-weight:bold;">if</span> part == <span style="color: #483d8b;">&quot;new&quot;</span>:
				newline = <span style="color: #008000;">True</span>
			<span style="color: #ff7700;font-weight:bold;">else</span>:
				<span style="color: #ff7700;font-weight:bold;">continue</span>
		<span style="color: #ff7700;font-weight:bold;">if</span> newline == <span style="color: #008000;">True</span>:
			n = <span style="color: #ff4500;">0</span>
			<span style="color: #ff7700;font-weight:bold;">if</span> line<span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span> <span style="color: #ff7700;font-weight:bold;">in</span> datelist:
				datelist<span style="color: black;">&#91;</span>line<span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span><span style="color: black;">&#93;</span> = datelist<span style="color: black;">&#91;</span>line<span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span><span style="color: black;">&#93;</span> + <span style="color: #ff4500;">1</span>
			<span style="color: #ff7700;font-weight:bold;">else</span>:
				datelist<span style="color: black;">&#91;</span>line<span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span><span style="color: black;">&#93;</span> = <span style="color: #ff4500;">1</span>
	f.<span style="color: black;">close</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">for</span> subdir, dirs, files <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #dc143c;">os</span>.<span style="color: black;">walk</span><span style="color: black;">&#40;</span>rootdir<span style="color: black;">&#41;</span>:
	<span style="color: #ff7700;font-weight:bold;">for</span> <span style="color: #008000;">file</span> <span style="color: #ff7700;font-weight:bold;">in</span> files:
		<span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #ff7700;font-weight:bold;">not</span> <span style="color: #008000;">file</span><span style="color: black;">&#91;</span>-<span style="color: #ff4500;">2</span>:<span style="color: black;">&#93;</span> == <span style="color: #483d8b;">&quot;py&quot;</span> <span style="color: #ff7700;font-weight:bold;">and</span> <span style="color: #008000;">file</span>.<span style="color: black;">split</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;.&quot;</span><span style="color: black;">&#41;</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span> == <span style="color: #483d8b;">&quot;denyhosts&quot;</span>:
			countup<span style="color: black;">&#40;</span>rootdir + <span style="color: #008000;">file</span><span style="color: black;">&#41;</span>
&nbsp;
keys = datelist.<span style="color: black;">keys</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
keys.<span style="color: black;">sort</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">for</span> key <span style="color: #ff7700;font-weight:bold;">in</span> keys:
	<span style="color: #ff7700;font-weight:bold;">print</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;%s, %s&quot;</span> <span style="color: #66cc66;">%</span> <span style="color: black;">&#40;</span>key,datelist<span style="color: black;">&#91;</span>key<span style="color: black;">&#93;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
plot_all<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://daubers.co.uk/2009/05/25/denyhosts-stats/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Monte Carlo Madness</title>
		<link>http://daubers.co.uk/2009/03/13/monte-carlo-madness/</link>
		<comments>http://daubers.co.uk/2009/03/13/monte-carlo-madness/#comments</comments>
		<pubDate>Fri, 13 Mar 2009 20:21:35 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[learning]]></category>
		<category><![CDATA[Physics]]></category>
		<category><![CDATA[Science]]></category>
		<category><![CDATA[Statistical Physics]]></category>
		<category><![CDATA[ubuntu]]></category>
		<category><![CDATA[Uni]]></category>
		<category><![CDATA[gnuplot]]></category>
		<category><![CDATA[graphs]]></category>
		<category><![CDATA[monte carlo]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[statistics]]></category>

		<guid isPermaLink="false">http://daubers.co.uk/?p=142</guid>
		<description><![CDATA[One of my modules has recently involved writing a set of monte carlo models. I&#8217;d heard of these mystical things before, but never implimented one myself (or understood the statistics behind them). I&#8217;ve become fairly interested in how these things work now, but one thing I didn&#8217;t understand was how the number of random numbers [...]]]></description>
			<content:encoded><![CDATA[<p>One of my modules has recently involved writing a set of <a title="Monte Carlo methods - Wikipedia" href="http://en.wikipedia.org/wiki/Monte_Carlo_method" target="_blank">monte carlo models</a>. I&#8217;d heard of these mystical things before, but never implimented one myself (or understood the statistics behind them). I&#8217;ve become fairly interested in how these things work now, but one thing I didn&#8217;t understand was how the number of random numbers you use affected the final result. This seemed like a fairly easy thing to calclate and graph, so I bodged som outputs into my code, wrote a short python script to do a few hundred runs and see what came out the other end.</p>
<p>What came out, I really wasn&#8217;t expecting. I assumed the uncertainty (or variance) would decrease as an exponential curve as you incresed the iterations, what really occurs can be seen in the graph below.</p>
<p style="text-align: center;">
<div class="wp-caption aligncenter" style="width: 522px"><img title="Iterations against Variance" src="http://daubers.co.uk/~daubers/iterations_v_variance.gif" alt="WTF?" width="512" height="384" /><p class="wp-caption-text">WTF?</p></div>
<p>That horrible wiggly bit at the beggining was completley unexpected. I am now wondering if it&#8217;s a sign that my data hasn&#8217;t been thermalized properly.</p>
<p>Any one out there with any experience of this want to comment?</p>
]]></content:encoded>
			<wfw:commentRss>http://daubers.co.uk/2009/03/13/monte-carlo-madness/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

