<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://www.theeggeadventure.com/wikimedia/index.php?action=history&amp;feed=atom&amp;title=Stddev</id>
	<title>Stddev - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://www.theeggeadventure.com/wikimedia/index.php?action=history&amp;feed=atom&amp;title=Stddev"/>
	<link rel="alternate" type="text/html" href="https://www.theeggeadventure.com/wikimedia/index.php?title=Stddev&amp;action=history"/>
	<updated>2026-05-25T01:05:36Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.46.0-beta</generator>
	<entry>
		<id>https://www.theeggeadventure.com/wikimedia/index.php?title=Stddev&amp;diff=2280&amp;oldid=prev</id>
		<title>Brianegge: Created page with &#039;This handy script calcs the standard deviation of a list of numbers from the standard input.  Example:  &lt;geshi lang=&quot;bash&quot;&gt; ping google.com | ruby -ne &#039;if $_ =~ /time(\d+)ms/ the…&#039;</title>
		<link rel="alternate" type="text/html" href="https://www.theeggeadventure.com/wikimedia/index.php?title=Stddev&amp;diff=2280&amp;oldid=prev"/>
		<updated>2009-10-20T07:22:03Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;#039;This handy script calcs the standard deviation of a list of numbers from the standard input.  Example:  &amp;lt;geshi lang=&amp;quot;bash&amp;quot;&amp;gt; ping google.com | ruby -ne &amp;#039;if $_ =~ /time(\d+)ms/ the…&amp;#039;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;This handy script calcs the standard deviation of a list of numbers from the standard input.  Example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;geshi lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
ping google.com | ruby -ne &amp;#039;if $_ =~ /time(\d+)ms/ then puts $1 end&amp;#039; | stddev&lt;br /&gt;
count   mean    stddev&lt;br /&gt;
4       48.33   34.39&lt;br /&gt;
&amp;lt;/geshi&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;geshi lang=&amp;quot;ruby&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/env ruby&lt;br /&gt;
&lt;br /&gt;
def variance(population)&lt;br /&gt;
  n = 0&lt;br /&gt;
  mean = 0.0&lt;br /&gt;
  s = 0.0&lt;br /&gt;
  population.each { |x|&lt;br /&gt;
    n = n + 1&lt;br /&gt;
      delta = x - mean&lt;br /&gt;
      mean = mean + (delta / n)&lt;br /&gt;
      s = s + delta * (x - mean)&lt;br /&gt;
  }&lt;br /&gt;
# if you want to calculate std deviation&lt;br /&gt;
# of a sample change this to &amp;quot;s / (n-1)&amp;quot;&lt;br /&gt;
  return s / n&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
def mean(population)&lt;br /&gt;
  n = 0&lt;br /&gt;
  mean = 0.0&lt;br /&gt;
  population.each { |x|&lt;br /&gt;
    n = n + 1&lt;br /&gt;
      delta = x - mean&lt;br /&gt;
      mean = mean + (delta / n)&lt;br /&gt;
  }&lt;br /&gt;
  return mean&lt;br /&gt;
end&lt;br /&gt;
# calculate the standard deviation of a population&lt;br /&gt;
# accepts: an array, the population&lt;br /&gt;
# returns: the standard deviation&lt;br /&gt;
def standard_deviation(population)&lt;br /&gt;
  Math.sqrt(variance(population))&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
values = []&lt;br /&gt;
$&amp;lt;.each do |l|&lt;br /&gt;
 values &amp;lt;&amp;lt; l.to_f&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
puts [&amp;quot;count&amp;quot;, &amp;quot;mean&amp;quot;, &amp;quot;stddev&amp;quot;].join(&amp;quot;\t&amp;quot;)&lt;br /&gt;
puts &amp;quot;%d\t%.2f\t%.2f&amp;quot; % [values.size(), mean(values), standard_deviation(values)]&lt;br /&gt;
&amp;lt;/geshi&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Ruby]]&lt;/div&gt;</summary>
		<author><name>Brianegge</name></author>
	</entry>
</feed>