📄 node261.html
字号:
<html><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"><!--Converted with jLaTeX2HTML 2002 (1.62) JA patch-1.4patched version by: Kenshi Muto, Debian Project.LaTeX2HTML 2002 (1.62),original version by: Nikos Drakos, CBLU, University of Leeds* revised and updated by: Marcus Hennecke, Ross Moore, Herb Swan* with significant contributions from: Jens Lippmann, Marek Rouchal, Martin Wilck and others --><HTML><HEAD><TITLE>22.3 Integrals</TITLE><META NAME="description" CONTENT="22.3 Integrals"><META NAME="keywords" CONTENT="everything"><META NAME="resource-type" CONTENT="document"><META NAME="distribution" CONTENT="global"><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1"><META NAME="Generator" CONTENT="jLaTeX2HTML v2002 JA patch-1.4"><META HTTP-EQUIV="Content-Style-Type" CONTENT="text/css"><LINK REL="STYLESHEET" HREF="everything.css" tppabs="http://www.isi.edu/nsnam/ns/doc/everything.css"><LINK REL="next" HREF="node262.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node262.html"><LINK REL="previous" HREF="node260.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node260.html"><LINK REL="up" HREF="node247.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node247.html"><LINK REL="next" HREF="node262.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node262.html"></HEAD><BODY ><!--Navigation Panel--><A NAME="tex2html5308" HREF="node262.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node262.html"><IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="file:/usr/share/latex2html/icons/next.png"></A> <A NAME="tex2html5302" HREF="node247.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node247.html"><IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="file:/usr/share/latex2html/icons/up.png"></A> <A NAME="tex2html5296" HREF="node260.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node260.html"><IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="file:/usr/share/latex2html/icons/prev.png"></A> <A NAME="tex2html5304" HREF="node1.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node1.html"><IMG WIDTH="65" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="contents" SRC="file:/usr/share/latex2html/icons/contents.png"></A> <A NAME="tex2html5306" HREF="node590.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node590.html"><IMG WIDTH="43" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="index" SRC="file:/usr/share/latex2html/icons/index.png"></A> <BR><B> Next:</B> <A NAME="tex2html5309" HREF="node262.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node262.html">22.4 ns-random</A><B> Up:</B> <A NAME="tex2html5303" HREF="node247.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node247.html">22. Mathematical Support</A><B> Previous:</B> <A NAME="tex2html5297" HREF="node260.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node260.html">22.2 Random Variables</A>   <B> <A NAME="tex2html5305" HREF="node1.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node1.html">Contents</A></B>   <B> <A NAME="tex2html5307" HREF="node590.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node590.html">Index</A></B> <BR><BR><!--End of Navigation Panel--><H1><A NAME="SECTION04230000000000000000"></A><A NAME="sec:integral"></A><BR>22.3 Integrals</H1><P>The Integrator../ns-2/integrator.hsupports the approximation of (continuous) integration by (discrete)sums; it is defined in integrator.h as<PRE>{\rm From integrator.h:} class Integrator : public TclObject { public: Integrator(); void set(double x, double y); void newPoint(double x, double y); int command(int argc, const char*const* argv); protected: double lastx_; double lasty_; double sum_; };{\rm From integrator.cc:} Integrator::Integrator() : lastx_(0.), lasty_(0.), sum_(0.) { bind("lastx_", &lastx_); bind("lasty_", &lasty_); bind("sum_", &sum_); } void Integrator::set(double x, double y) { lastx_ = x; lasty_ = y; sum_ = 0.; } void Integrator::newPoint(double x, double y) { sum_ += (x - lastx_) * lasty_; lastx_ = x; lasty_ = y; } int Integrator::command(int argc, const char*const* argv) { if (argc == 4) { if (strcmp(argv[1], "newpoint") == 0) { double x = atof(argv[2]); double y = atof(argv[3]); newPoint(x, y); return (TCL_OK); } } return (TclObject::command(argc, argv)); }</PRE>This class provides a base class used by other classes suchas <TT>QueueMonitor</TT> that keep running sums.Each new element of the running sum is added bythe [x, y]newPoint function.After the th execution of <TT>newPoint</TT>, the running sumis equal to <!-- MATH $\sum_{i=1}^{k}y_{i-1}(x_i - x_{i-1})$ --> where unless <TT>lastx<BR>_</TT>, <TT>lasty<BR>_</TT>, or <TT>sum<BR>_</TT>are reset via OTcl.Note that a new point in the sum can be added either by theC++ member <TT>newPoint</TT> or the OTcl member <TT>newpoint</TT>.The use of integrals to compute certain types of averages(e.g. mean queue lengths) is given in (pp. 429-430, [<A HREF="node589.html#Jain91:Art" tppabs="http://www.isi.edu/nsnam/ns/doc/node589.html#Jain91:Art">16</A>]).<P><BR><HR><ADDRESS>2003-09-23</ADDRESS></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -