This file is indexed.

/usr/share/doc/pyxplot/html/ex-meansd.html is in pyxplot-doc 0.8.4-3.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta name="generator" content="plasTeX" />
<meta content="text/html; charset=utf-8" http-equiv="content-type" />
<title>PyXPlot Users' Guide: Foreach Datum Loops</title>

<link href="sect0037.html" title="While and Do Loops" rel="next" />
<link href="sect0036.html" title="Foreach Loops" rel="prev" />
<link href="sect0031.html" title="Programming and Flow Control" rel="up" />
<link rel="stylesheet" href="styles/styles.css" />
</head>
<body>

<div class="navigation">
<table cellspacing="2" cellpadding="0" width="100%">
<tr>
<td><a href="sect0036.html" title="Foreach Loops"><img alt="Previous: Foreach Loops" border="0" src="icons/previous.gif" width="32" height="32" /></a></td>

<td><a href="sect0031.html" title="Programming and Flow Control"><img alt="Up: Programming and Flow Control" border="0" src="icons/up.gif" width="32" height="32" /></a></td>

<td><a href="sect0037.html" title="While and Do Loops"><img alt="Next: While and Do Loops" border="0" src="icons/next.gif" width="32" height="32" /></a></td>

<td class="navtitle" align="center">PyXPlot Users' Guide</td>
<td><a href="index.html" title="Table of Contents"><img border="0" alt="" src="icons/contents.gif" width="32" height="32" /></a></td>

<td><a href="sect0255.html" title="Index"><img border="0" alt="" src="icons/index.gif" width="32" height="32" /></a></td>

<td><img border="0" alt="" src="icons/blank.gif" width="32" height="32" /></td>
</tr>
</table>
</div>

<div class="breadcrumbs">
<span>
<span>
<a href="index.html">PyXPlot Users' Guide</a> <b>:</b>
</span>

</span><span>
<span>
<a href="sect0001.html">Introduction to PyXPlot</a> <b>:</b>
</span>

</span><span>
<span>
<a href="sect0031.html">Programming and Flow Control</a> <b>:</b>
</span>

</span><span>

<span>
<b class="current">Foreach Datum Loops</b>
</span>
</span>
<hr />
</div>

<div><h1 id="ex:meansd">6.5 Foreach Datum Loops</h1>
<p>Foreach datum loops are similar to foreach loops in that they run a script block once for each item in a list. In this case, however, the list in question is the list of datapoints in a file. The syntax of the <tt class="tt">foreach datum</tt> command<a name="a0000000586" id="a0000000586"></a> is similar to that of the commands met in the previous chapter for acting upon datafiles: the standard modifiers <tt class="tt">every</tt>, <tt class="tt">index</tt>, <tt class="tt">select</tt> and <tt class="tt">using</tt> can be used to select which columns of the datafile, and which subset of the datapoints, should be used: </p><pre>
foreach datum i,j,name in "data.dat" using 1:2:"%s"%($3)
 {
  ...
 }
</pre><p>The <tt class="tt">foreach datum</tt> command<a name="a0000000587" id="a0000000587"></a> is followed by a comma-separated list of the variable(s) which are to be read from the datafile on each iteration of the loop. The <tt class="tt">using</tt> modifier specifies the columns or rows of data which are to be used to set the values of each variable. In this example, the third variable, <tt class="tt">name</tt>, is set using a quoted string, indicating that it will be set to equal whatever string of text is found in the third column of the datafile. </p><p> <span class="upshape"><span class="mdseries"><span class="rm">Calculating the Mean and Standard Deviation of Data.</span></span></span></p><div>

<table cellspacing="0" class="tabular">
<tr>

    
    <td style="border-top-style:solid; border-left:1px solid black; border-right:1px solid black; border-top-color:black; border-top-width:1px; text-align:left"><p> The following PyXPlot script calculates the mean and standard deviation of a set of datapoints using the <tt class="tt">foreach datum</tt> command<a name="a0000000588" id="a0000000588"></a>: </p></td>

</tr><tr>

    
    <td style="text-align:left; border-right:1px solid black; border-left:1px solid black"><p><tt class="tt">N_data = 0</tt><br /><tt class="tt">sum_x = 0</tt><br /><tt class="tt">sum_x2 = 0</tt><br /></p></td>

</tr><tr>

    
    <td style="text-align:left; border-right:1px solid black; border-left:1px solid black"><p><tt class="tt">foreach datum x in ’–’</tt><br /><tt class="tt">{</tt><br /><tt class="tt">N_data = N_data + 1</tt><br /><tt class="tt">sum_x = sum_x + x</tt><br /><tt class="tt">sum_x2 = sum_x2 + x**2</tt><br /><tt class="tt">}</tt><br /><tt class="tt">1.3</tt><br /><tt class="tt">1.2</tt><br /><tt class="tt">1.5</tt><br /><tt class="tt">1.1</tt><br /><tt class="tt">1.3</tt><br /><tt class="tt">END</tt><br /></p></td>

</tr><tr>

    
    <td style="text-align:left; border-right:1px solid black; border-left:1px solid black"><p><tt class="tt">mean = sum_x / N_data</tt><br /><tt class="tt">SD = sqrt(sum_x2 / N_data - mean**2)</tt><br /></p></td>

</tr><tr>

    
    <td style="text-align:left; border-right:1px solid black; border-left:1px solid black"><p><tt class="tt">print "Mean = %s"%(mean)</tt><br /><tt class="tt">print "SD = %s"%(SD)</tt> </p></td>

</tr><tr>

    
    <td style="border-bottom-style:solid; border-bottom-width:1px; border-left:1px solid black; border-right:1px solid black; text-align:left; border-bottom-color:black"><p>For the data supplied, a mean of <img src="images/img-0296.png" alt="$1.28$" style="vertical-align:0px; 
                                     width:31px; 
                                     height:12px" class="math gen" /> and a standard deviation of <img src="images/img-0297.png" alt="$0.133$" style="vertical-align:0px; 
                                     width:41px; 
                                     height:12px" class="math gen" /> are returned.  </p></td>

</tr>
</table>
</div></div>





<div class="navigation">
<table cellspacing="2" cellpadding="0" width="100%">
<tr>
<td><a href="sect0036.html" title="Foreach Loops"><img alt="Previous: Foreach Loops" border="0" src="icons/previous.gif" width="32" height="32" /></a></td>

<td><a href="sect0031.html" title="Programming and Flow Control"><img alt="Up: Programming and Flow Control" border="0" src="icons/up.gif" width="32" height="32" /></a></td>

<td><a href="sect0037.html" title="While and Do Loops"><img alt="Next: While and Do Loops" border="0" src="icons/next.gif" width="32" height="32" /></a></td>

<td class="navtitle" align="center">PyXPlot Users' Guide</td>
<td><a href="index.html" title="Table of Contents"><img border="0" alt="" src="icons/contents.gif" width="32" height="32" /></a></td>

<td><a href="sect0255.html" title="Index"><img border="0" alt="" src="icons/index.gif" width="32" height="32" /></a></td>

<td><img border="0" alt="" src="icons/blank.gif" width="32" height="32" /></td>
</tr>
</table>
</div>

<script language="javascript" src="icons/imgadjust.js" type="text/javascript"></script>

</body>
</html>