Skip to content

Instantly share code, notes, and snippets.

@snoble
Created October 11, 2012 02:27
Show Gist options
  • Save snoble/3869806 to your computer and use it in GitHub Desktop.
Save snoble/3869806 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>moments -- Sage</title>
<link type="text/css" rel="stylesheet" href="/css/main.css" />
<script type="text/javascript" src="/javascript/jquery/jquery-1.7.1.min.js"></script>
<script type="text/javascript" src="/javascript/dynamic/localization.js"></script>
<script type="text/javascript" src="/javascript/json/json2.min.js"></script>
<!-- jQuery UI - interacts, widgets, drag-drop, etc. -->
<link rel="stylesheet" href="/javascript/jqueryui/css/sage/jquery-ui-1.8.11.custom.css" />
<script type="text/javascript" src="/javascript/jqueryui/js/jquery-ui-1.8.11.custom.min.js"></script>
<!-- jQuery plugins - color pickers, shift-click, AJAX forms, IE fixes, notifications -->
<link rel="stylesheet" href="/javascript/jquery/plugins/farbtastic/farbtastic.css" type="text/css" />
<script type="text/javascript" src="/javascript/jquery/plugins/farbtastic/farbtastic.min.js"></script>
<script type="text/javascript" src="/javascript/jquery/plugins/extendedclick/jquery.event.extendedclick.min.js"></script>
<script type="text/javascript" src="/javascript/jquery/plugins/form/jquery.form.min.js"></script>
<script type="text/javascript" src="/javascript/jquery/plugins/jquery.bgiframe.min.js"></script>
<link rel="stylesheet" href="/javascript/jquery/plugins/jpicker/css/jPicker-1.1.6.min.css" type="text/css" />
<script type="text/javascript" src="/javascript/jquery/plugins/jpicker/jpicker-1.1.6.min.js"></script>
<link rel="stylesheet" media="screen" type="text/css" href="/javascript/jquery/plugins/colorpicker/css/colorpicker.css" />
<script type="text/javascript" src="/javascript/jquery/plugins/colorpicker/js/colorpicker.min.js"></script>
<script type="text/javascript" src="/javascript/jquery/plugins/achtung/ui.achtung-mod.min.js"></script>
<script type="text/javascript" src="/javascript/sage/js/notebook_lib.js"></script>
<script type="text/javascript" src="/javascript/dynamic/notebook_dynamic.js"></script>
<!-- Work around OSX Lion STIX fonts bug: see http://groups.google.com/group/mathjax-users/browse_thread/thread/42ceab8dbf286740,
https://github.com/mathjax/MathJax/issues/178, and https://github.com/mathjax/MathJax/issues/152 -->
<script type="text/x-mathjax-config">
MathJax.Hub.Register.LoadHook("[MathJax]/jax/output/HTML-CSS/fonts/STIX/fontdata.js", function () {
var HTMLCSS = MathJax.OutputJax["HTML-CSS"];
MathJax.Hub.Browser.Select({
Safari: function (browser) {
browser.STIXfontBug = browser.versionAtLeast("5.1") && browser.isMac;
},
Chrome: function (browser) {
var match = navigator.appVersion.match(/AppleWebKit\/(\d+)/);
if (match && parseInt(match[1]) > 534) {browser.STIXfontBug = true}
}
});
if (MathJax.Hub.Browser.STIXfontBug) {
HTMLCSS.FONTDATA.FONTS["STIXGeneral"].family = "STIXGeneral-Regular";
HTMLCSS.FONTDATA.FONTS["STIXGeneral-italic"].family = "STIXGeneral-Italic";
delete HTMLCSS.FONTDATA.FONTS["STIXGeneral-italic"].style;
}
});
</script>
<script type="text/javascript" src="/javascript/mathjax/MathJax.js?config=TeX-AMS_HTML-full,../../dynamic/mathjax_sage.js"></script>
<!-- Sage3d - accelerated 3D graphics -->
<script type="text/javascript" src="/javascript/sage3d/sage3d.js"></script>
<!-- Jmol - embedded 3D graphics -->
<script type="text/javascript" src="/java/jmol/appletweb/Jmol.js"></script>
<!-- This must stay in head -->
<script>jmolInitialize("/java/jmol");jmolSetCallback("menuFile","/java/jmol/appletweb/SageMenu.mnu");</script>
<!-- TinyMCE and jEditable - in-place editing of text cells -->
<script type="text/javascript" src="/javascript/tiny_mce/tiny_mce.js"></script>
<script type="text/javascript" src="/javascript/jquery/plugins/jeditable/jquery.jeditable.mini.js" charset="utf-8"></script>
<script type="text/javascript" src="/javascript/sage/js/tinymce.js"></script>
<script type="text/javascript" src="/javascript/tiny_mce/plugins/media/js/embed.js"></script>
<script type="text/javascript">user_name= "guest";</script>
<script type="text/javascript">
worksheet_filename = "Steven_H._Noble/1";
worksheet_name = 'moments';
server_ping_while_alive();
</script>
<script type="text/javascript" src="/javascript/sage/js/master.js"></script>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-24214040-1']);
_gaq.push(['_setDomainName', 'sagenb.org']);
_gaq.push(['_trackPageview']);
_gaq.push(['_trackPageLoadTime']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
</head>
<body id="print-page"
class="">
<h1>moments</h1>
<div class="cell_input_active" id="cell_resizer"></div>
<div class="worksheet_cell_list" id="worksheet_cell_list">
<div id="cell_outer_1" class="cell_visible">
<div id="cell_1" class="cell_evaluated">
<div class="cell_input_print">var(&#39;acount&#39;, &#39;bcount&#39;, &#39;am1&#39;, &#39;bm1&#39;, &#39;nbm1&#39;, &#39;am2&#39;, &#39;bm2&#39;, &#39;nbm2&#39;, &#39;am3&#39;, &#39;bm3&#39;, &#39;nbm3&#39;, &#39;am4&#39;, &#39;bm4&#39;, &#39;nbm4&#39;)
def combineMean(xcount, ycount, xm1, ym1, xm2, ym2, xm3, ym3, xm4, ym4):
delta = ym1 - xm1
zcount = xcount + ycount
zm1 = (xcount*xm1 + ycount*ym1)/(xcount + ycount)
zm2 = xm2 + ym2 + delta^2 * xcount*ycount/zcount
zm3 = xm3 + ym3 + delta^3 * xcount*ycount*(xcount - ycount) / zcount^2 + 3*delta*(xcount*ym2 - ycount*xm2)/zcount
zm4 = xm4 + ym4 + delta^4 * xcount * ycount * (xcount^2 - xcount * ycount + ycount^2) / zcount^3 + 6 * delta^2 * (xcount^2 * ym2 + ycount^2 * xm2) / zcount^2 + 4 * delta * (xcount * ym3 - ycount * xm3) / zcount
return [zcount, zm1, zm2, zm3, zm4]
cm = combineMean(acount, bcount, am1, bm1, am2, bm2, am3, bm3, am4, bm4)
ccm = combineMean(cm[0], -bcount, cm[1], nbm1, cm[2], nbm2, cm[3], nbm3, cm[4], nbm4)
solve(ccm[1] == am1, nbm1)&nbsp;</div>
<div id="introspect_div_1" class="introspection"></div>
<div class="cell_output_div">
<table class="cell_output_box">
<tr>
<td class="cell_number" id="cell_number_1"
>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</td>
<td class="output_cell">
<div class="cell_div_output_wrap" id="cell_div_output_1">
<div class="cell_output_print_wrap"
id="cell_output_1">
<pre class="shrunk">[nbm1 == bm1]</pre>
</div>
<div class="cell_output_html_wrap"
id="cell_output_html_1">
</div>
</div>
</td>
</tr>
</table>
</div>
</div>
</div>
<div id="cell_outer_2" class="cell_visible">
<div id="cell_2" class="cell_evaluated">
<div class="cell_input_print">ccm = combineMean(cm[0], -bcount, cm[1], bm1, cm[2], nbm2, cm[3], nbm3, cm[4], nbm4)
solve(ccm[2] == am2, nbm2)&nbsp;</div>
<div id="introspect_div_2" class="introspection"></div>
<div class="cell_output_div">
<table class="cell_output_box">
<tr>
<td class="cell_number" id="cell_number_2"
>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</td>
<td class="output_cell">
<div class="cell_div_output_wrap" id="cell_div_output_2">
<div class="cell_output_print_wrap"
id="cell_output_2">
<pre class="shrunk">[nbm2 == -bm2]</pre>
</div>
<div class="cell_output_html_wrap"
id="cell_output_html_2">
</div>
</div>
</td>
</tr>
</table>
</div>
</div>
</div>
<div id="cell_outer_3" class="cell_visible">
<div id="cell_3" class="cell_evaluated">
<div class="cell_input_print">ccm = combineMean(cm[0], -bcount, cm[1], bm1, cm[2], -bm2, cm[3], nbm3, cm[4], nbm4)
solve(ccm[3] == am3, nbm3)&nbsp;</div>
<div id="introspect_div_3" class="introspection"></div>
<div class="cell_output_div">
<table class="cell_output_box">
<tr>
<td class="cell_number" id="cell_number_3"
>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</td>
<td class="output_cell">
<div class="cell_div_output_wrap" id="cell_div_output_3">
<div class="cell_output_print_wrap"
id="cell_output_3">
<pre class="shrunk">[nbm3 == -bm3]</pre>
</div>
<div class="cell_output_html_wrap"
id="cell_output_html_3">
</div>
</div>
</td>
</tr>
</table>
</div>
</div>
</div>
<div id="cell_outer_4" class="cell_visible">
<div id="cell_4" class="cell_evaluated">
<div class="cell_input_print">ccm = combineMean(cm[0], -bcount, cm[1], bm1, cm[2], -bm2, cm[3], -bm3, cm[4], nbm4)
solve(ccm[4] == am4, nbm4)&nbsp;</div>
<div id="introspect_div_4" class="introspection"></div>
<div class="cell_output_div">
<table class="cell_output_box">
<tr>
<td class="cell_number" id="cell_number_4"
>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</td>
<td class="output_cell">
<div class="cell_div_output_wrap" id="cell_div_output_4">
<div class="cell_output_print_wrap"
id="cell_output_4">
<pre class="shrunk">[nbm4 == -bm4]</pre>
</div>
<div class="cell_output_html_wrap"
id="cell_output_html_4">
</div>
</div>
</td>
</tr>
</table>
</div>
</div>
</div>
<div id="cell_outer_5" class="cell_visible">
<div id="cell_5" class="cell_evaluated">
<div class="cell_input_print">&nbsp;</div>
<div id="introspect_div_5" class="introspection"></div>
<div class="cell_output_div">
<table class="cell_output_box">
<tr>
<td class="cell_number" id="cell_number_5"
>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</td>
<td class="output_cell">
<div class="cell_div_output_wrap" id="cell_div_output_5">
<div class="cell_output_print_wrap"
id="cell_output_5">
</div>
<div class="cell_output_html_wrap"
id="cell_output_html_5">
</div>
</div>
</td>
</tr>
</table>
</div>
</div>
</div>
</div>
<!-- <script>
MathJax.Hub.Queue(["Typeset",MathJax.Hub]);
</script>-->
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment