Commits

kcrisman committed dd6d5da Draft

Added more Sage cell examples for testing

Updated interact Intro for latest Sage cell API
Added examples, both autoevaluating and not, to Other Topics

Comments (0)

Files changed (2)

 <link rel="shortcut icon" href="../../MAA.png" type="image/png" />
 <link rel="stylesheet" href="../styles.css" type="text/css" />
 <script src="scripts.js" type="text/javascript"></script>
+
+<!-- This stuff makes the Sage cell instances work right -->
+    <script src="http://aleph.sagemath.org/static/jquery.min.js"></script>
+    <script src="http://aleph.sagemath.org/embedded_sagecell.js"></script>
+    <script>
+$(function () {
+    sagecell.makeSagecell({inputLocation:  '#Petersen',
+                           template:       sagecell.templates.restricted,
+                           autoeval: true});
+    sagecell.makeSagecell({inputLocation: '#Distribution',
+                           template:       sagecell.templates.restricted,
+                           evalButtonText: 'Evaluate'});
+    sagecell.makeSagecell({inputLocation: '#R',
+                           template:       sagecell.templates.restricted,
+                           evalButtonText: 'Evaluate'});
+    sagecell.makeSagecell({inputLocation: '#Cats',
+                           template:       sagecell.templates.restricted,
+                           evalButtonText: 'Evaluate'});
+});
+    </script>
+
 </head>
 
 <body>
 more being added all the time.  We access them using the "graphs.[tab]" syntax, and can plot them too.
 Below, we see the well-known Petersen graph.</p>
 
-<p>FIXME: Add a screenshot.</p>
+<div id="Petersen"><script type="text/x-sage">graphs.PetersenGraph().show()</script></div>
 
 <p>It's possible to define one's own graphs using adjacency information of various kinds (such as 
 matrices).  One can explicitly set the position of every vertex
 <p>For most more advanced functionality, Sage uses packages like the <a href="http://www.gnu.org/software/gsl/">GNU
 Scientific Library</a> or <a href="http://www.scipy.org/">Scipy</a>.</p>
 
-<p>Example:  FIXME needs formatting, screenshot?
-dist=RealDistribution('gaussian',3)
-my_data=[dist.get_random_element()+2 for _ in range(10)]
-my_data 
-</p>
+<div id="Distribution"><script type="text/x-sage">dist=RealDistribution('gaussian',3)
+my_data=[dist.get_random_element()+2 for _ in range(20)]
+my_data; mean(my_data)</script></div>
 
 <p>Also, thanks to the <a href="http://www.r-project.org/">R package</a>, 
 Sage has essentially every statistics thing you would ever need. Through the notebook, first choose
-the "R" evaluation possibility from the drop-down menu: FIXME: screenshot</p>
+the "R" evaluation possibility from the drop-down menu, then paste in your code: FIXME: screenshot</p>
 
-<p>Then just paste in your R code!  Here is an example using the Kruskal-Wallis test.  FIXME formatting
-x=r([2.9, 3.0, 2.5, 2.6, 3.2]) # normal subjects
+<p>Or, for many things the R interface for Sage will work just fine.  Click Evaluate, below.</p>
+<div id="R"><script type="text/x-sage">x=r([2.9, 3.0, 2.5, 2.6, 3.2]) # normal subjects
 y=r([3.8, 2.7, 4.0, 2.4])      # with obstructive airway disease
 z=r([2.8, 3.4, 3.7, 2.2, 2.0]) # with asbestosis
 a = r([x,y,z]) # make a long R vector of all the data
 b = r.factor(5*[1]+4*[2]+5*[3]) # create something for R to tell which subjects are which
-a; b # show them 
-r.kruskal_test(a,b) # do the KW test! 
-</p>
+print a; print b # show them 
+r.kruskal_test(a,b) # do the KW test! </script></div>
+<p>Apparently there wasn't enough data for us to reject the null hypothesis here.</p>
+
 
 <h2 id="Combinatorics">Combinatorics</h2>
 
 
 <p>One can do permutations of arbitrary sets:</p>
 
-<p>FIXME: include something like 
-pets = ['dog', 'cat', 'snake', 'spider']
+<div id="Cats"><script type="text/x-sage">pets = ['dog', 'cat', 'snake', 'spider']
 for pair in Permutations(pets, 2):
-    print pair 
-</p>
+    print pair </script></div>
 
 <p>But there are also plenty of numerical things:
 <ul>
 <link rel="shortcut icon" href="../../MAA.png" type="image/png" />
 <link rel="stylesheet" href="../styles.css" type="text/css" />
 <script src="scripts.js" type="text/javascript"></script>
+
+<!-- Stuff to make live Sage cell instances -->
+
+    <script src="http://aleph.sagemath.org/static/jquery.min.js"></script>
+    <script src="http://aleph.sagemath.org/embedded_sagecell.js"></script>
+    <script>
+$(function () {
+    sagecell.makeSagecell({inputLocation:  '#sagecell-interact',
+                           template:       sagecell.templates.minimal,
+                           evalButtonText: 'Activate'});
+    sagecell.makeSagecell({inputLocation: '#sagecell-test',
+                           evalButtonText: 'Evaluate'});
+});
+    </script>
+
 </head>
 
 <body>
 
 
 <h2>Interact Example</h2>
-<div id="singlecell-interact"><script type="text/code">var('x')
+<div id="sagecell-interact"><script type="text/x-sage">var('x')
 x0  = 0
 f(x)   = sin(x)*e^(-x)
 p   = plot(f,(x,-1,5), thickness=2)
 
 Or just edit the box below.
 
-<div id="singlecell-test">factorial(30) # edit me</div>
-
-
-<!-- Code to make the above divs actually work -->
-<script type="text/javascript" src="http://sagemath.org:5467/static/jquery-1.5.min.js"></script>
-<script type="text/javascript" src="http://sagemath.org:5467/embedded_singlecell.js"></script>
-<script type="text/javascript">
-    $(function() { // load only when the page is loaded
-      var makecells = function() {
-      singlecell.makeSinglecell({
-          inputDiv: "#singlecell-test",
-	  editor: "codemirror",
-	  hide: ["computationID","files","messages","sageMode"],
-	  replaceOutput: true});
-     singlecell.makeSinglecell({
-          inputDiv: "#singlecell-interact",
-	  template: singlecell.templates.minimal,
-	  evalButtonText: "Explore Taylor Polynomials"});
-      }
-    
-      singlecell.init(makecells); // load Single Cell libraries and then
-                                  // initialize two Single Cell instances
-    
-      });
-</script>
+<div id="sagecell-test"><script type="text/x-sage">factorial(30) # edit me</script></div>
 
 
 <div class="footer">