text:
\chapter{State Of The Art}
\section{Multi Protocol Label Switching (MPLS)}

In MPLS Networks, Packets are forwarded using the 20 Byte Labels unlike the 32 bit IP Address. In order to understand the working of MPLS and its advantages over conventional IP Network, we must understand how the traditional IP traffic processed.

\subsection{IP Routing}

IP routing\cite{2008} is the process of sending packets from one L3 host to another. The hosts can be in same or different networks and the networks are identified using the IP Addresses. Each packet will have a field for source address and destination address and the packets are forwarded based on the destination address. All the IP Networking devices will maintain a routing table. The devices can be a host machine or a router. The routing table consists of an address field where we can see a 32 bit address and an interface field where we can see a physical or logical interface corresponding to the address.

\begin{figure}
       \centering\includegraphics[width=\textwidth]{Final/routing table.png}
       \caption{Sample routing table}
       \label{fig:compbest}
\end{figure}

The figure 1.1 is a sample of routing table from a Juniper router. We can see the networks and the corresponding exit interfaces. Theses routing tables are created and maintained by different routing protocols and each routing protocol have its own mechanisms of finding the best route to the destination. OSPF, RIP and BGP are the well-known routing protocols\cite{2005}.

\subsection{MPLS Switching}

Multi-protocol label switching (MPLS)\cite{farrel_2004}, is a technique that uses 20-bit labels instead of 32-bit IP Address for sending packet from one MPLS router to another. The Labels are pre populated using different protocols such as Label Distribution Protocol (LDP), Resource Reservation Protocol (RSVP) or Multiprotocol BGP (MP BGP). The packet switching is happening at 2.5 header of the OSI reference model and hence it's called switching. As MPLS need the help of other protocols to create the labels, the name multi-protocol labelled switching

 \begin{figure}
       \centering\includegraphics[width=\textwidth]{Final/MPLS Network.png}
       \caption{MPLS Network}
       \label{fig:compbest}
\end{figure}

In the Figure 1.2 the CE1 is a L3 router which operates exclusively on IP address and PE1 is called provider edge router which will operate on both IP address and labels. P is provider router which works exclusively on labels. The incoming packets from CE1 in PE1 taken to a class called Forward equivalence class which assign a label corresponding to the destination IP address. The PE1 then forward the packet to P router which will pop the existing label and add its label corresponding to the destination and finally PE2 will pop the MPLS header from the packet and forward the packet to CE2 using IP routing table.

 \begin{figure}
       \centering\includegraphics[width=\textwidth]{Final/MPLS Header.jpg}
       \caption{MPLS Header}
       \label{fig:compbest}
\end{figure}

MPLS header gets in between the Ethernet header and the IP Header. The header is 4 bytes in size. The first 20 bits are for the labels, the next 3 bits are for class of service and the next 1 bit for the bottom of stack flag which basically say where the label is positioned. The last 8 bits are for the TTL (time to live).

\section{Security Requirements in MPLS}

As we know that MPLS is a widely used technology by Service provider to provide VPN Services, the expectation from the VPN Customers and the Service provider is that MPLS Should inherently possess basic security requirements\cite{2010} by its architecture. In this section we can see the basic security requirements of an MPLS Network\cite{davie_farrel_2008}.

\subsection{Address Space Separation}

The expectation is that a packet destined to a host with a particular address in a VPN shouldn't’t reach another VPN or the core. MPLS assume unique address space between 2 non intersecting VPNs and the address space between VPNs should be absolutely independent. This is a basic assumption of address space in MPLS VPNs. In another words the address space in a VPN is very private to it and the same address may can be used in different VPNs for its local connectivity. The routing between 2 VPNs or the VPN and the MPLS core should be independent. Adding a 64-bit RD (Route Distinguisher) by the MPLS core to each IPv4 route will make the VPN unique with the address and unique to the core. The exception is that The IP address of the link between the Provider Edge (PE) and the Customer Edge (CE) router are connected with must be unique. Every PE router is maintaining a VRF table (Virtual Router Forwarding) for each VPNs it connected with. This VRF tables separates the routing between the VPNs. In MPBGP (A signalling protocol), between the core to the other PE routers, the separation is maintained by unique VPN identifiers (VPN ID). This Information is redistributed to all the PE routers and available to all the PEs. So, unless configured to, a packet to host through a VPN cannot reach another VPN.

\subsection{Hiding the MPLS Core from outside}

The Network provider usually hide the internal structure of the MPLS core from outside. In another word, a traceroute should not detail the MPLS Core routers and its addresses. If the internal details of the network are visible to an attacker, its easy to trigger a DOS (Denial-of-service) attack. The network detailing should be hidden even to the VPN Customers and Users. A simple continues ping to any of the PE or P routers in the MPLS core can make the router busy and lead to denial of services.
\subsection{Resistance to attacks}

The Network provider usually hide the internal structure of the MPLS core from outside. In another word. It is easy to trigger a DOS Attack to any exposed resource either by abusing the underlying Routing protocol or by abusing the Signalling protocol (example: attack LDP). This can make instabilities in the Network. 3 Solutions are possible in this case. 1 s isolate the core to the maximum from outside. 2nd is use various packet filters such as ACLs and filter unwanted traffic incoming from outside to the core. 3rd is use the authentication mechanisms provided by the routing protocols and signalling protocols (MD5 Authentication). Out of all these the strongest solution is the isolation of the MPLS Core. The Link connecting the CE and PE should be protected securely.
\subsection{Label spoofing}

As we already discussed that, the packets in MPLS Network is transmitted based on the labels and the PE router maintain an FEC and assign a label to the incoming packet. The design of MPLS is in such a way that the PE cannot accept a pre labelled packet. If an attacker can label an IP packet with a label, the PE cannot accept that, and it can lead to packet drop. So, protecting the packet from the data path of the CE router or even outside is very important. The result of label spoofing within the MPLS core can forward the packet to the convenience of the attacker. Hence protecting the packets from label spoofing Is very important in MPLS.

\section{Possible attacks in MPLS}

MPLS can be attacked in many ways\cite{grayson_guernsey_butts_spainhower_shenoi_2009}. There are tools available which can target various signalling protocols by sending dummy messages to initiate a session, keep the session open or close the session. Loki is one such tool which can use to attack MPLS. It can capture the packets, inject packets, firewall the packets. Let us see some attacks Loki can make in the MPLS Network. In this section, we will attempt to list the different safety assaults that are susceptible to the MPLS network. Security attacks were divided into four kinds: Data Plane Attacks, Control Plane Attacks, MPLS Network Operational and Management Attacks, and Insider Attacks.

\subsection{Attacks on the Data Plane}

Attacks aimed mainly at User or Service Provider data are categorized into data-plane security attacks. These attacks are either aimed at manipulating the data flowing through the MPLS network, removing the data flowing through the MPLS network, injecting malicious data or simply observing maliciously unauthorized data.

\subsubsection{Taking the MPLS traffic outside the core}

If an attacker has access to any core device, he can relabel or encapsulate an udp header with a destination address which attacker desired to send. Thus, the attacker can read or access the data from attacker's convenience. In order to do this, the attacker should be aware of the labels used in the traffic. Service providers usually hide the internal architecture of the MPLS core, but still it's not 100 percent safe.

\subsubsection{Modify the Data Traffic}

Manipulating or changing the header fields of the packets can cause severe damage to MPLS Network. This is only possible when the MPLS Internals are exposed to the attacker. Getting the access of the MPLS core is however not easy since service providers usually hide the core from outside. Service providers use firewalls and other filters in their core to filter and block illegitimate packets and accesses. But once the attacker somehow managed to gain the core access, He/ She can make sever damage to the Networks.

Listed few of the attacks which is possible by packet manipulations, they are:

\subsubsection{Modify the routes}

Attacker can manipulate the network field of the packets the CE router can route the packets to a different destination out of the MPLS Cloud. Attacker can change the L3 field, Labels or encapsulate an UDP Header with completely different Network information. If the attacker gain access to packets part of financial transactions, we can imagine the damage. Rerouting of traffic can take one customers traffic to another customers network. \\

    Path Switching:   Generally, all MPLS packets flow through a Label switched path (LSP) assigned by the service provider. These paths are basically allocated by the service provider based on the labels associated to the packets. Labels are assigned by various parameters such as destination prefix or intended quality of service. For example, if Video streaming packets required a high bandwidth link, then the label will be of the LSP with higher throughput. If an attacker know the particular Label associated to the best LSP, he can label his local traffic such as online gaming traffic and gain best quality of service at the same time the genuine traffic which is expected good quality of service can get dropped. \\

    Destination Switching: This can be done in different ways. 1 is by changing the labels , 2nd by changing the destination IP address. Attacker can take the packets to any destination he/she desired and conduct malicious operations. \\

    Brute-Force Label Prediction: If an attacker know the destination address, then he/she can inject traffic with some random labels to MPLS networks. Attacker can injects packets by changing labels each time till get a reply from the destination and by doing this the attacker deduce the LSP. Once knew the label information of the LSP, he can use this for malicious operations.\\

    Address Messages Modification: This is very similar to Label modification. If an attacker gained access to the Customer edge router, he can manipulate the destination address field of the packet and the Provider edge router will take the packet to a Forward Equivalence Class for allocating a label. Suppose the FEC have no information or class for the destination address marked in the packet by attacker, might lead to create a New LSP and send the packets through a compromised link.\\

    Label Edge Router (LER) label Modification:  Customer edge routers are the routers which assign labels to the packets very first time in the MPLS Network and the core routers do the packet forwarding based on the labels PE assigned. If an attacker gained access to the PE router, he can pop the label which PE assigned and push a new label. The Provider router will have to choose an LSP according to the incoming label and if there is no LSP for the incoming label, then this might lead to packet drop or send the packet as IP packet if configured to do so.\\

    VPN label Modification: This attack is very similar to the label modification attack. If an attacker could setup an illegitimate VPNs by using any attacking tools like Loki, then relabelling the packets within the provider edge can cause the P router to switch the packets to the illegitimate VPN. If there is no LSP information in the P router for the new, label then the packet may forward as a plain IP traffic which may be the intention of the attacker. \\

    VRF table Modification: This is a very serious attack. A VRF table will have labels and corresponding outgoing physical/logical interfaces. By modifying the VRF table either by changing the labels in the table or the outgoing interface, the attacker can take the packets through the compromised link and to a malicious destination.\\

    \subsubsection{Data Insertion attacks}

This type of attacks is done by injecting forged traffic into the MPLS network and making the MPLS switch accept it as a genuine traffic and thus making it to forward the packets to the end devices. These packets are sent with malicious intentions to gain certain access to the end device or to read sensitive information. Various Data injection attacks are listed below\\

    Insertion of malicious data traffic to Spoof and Replay: This attack is done by injecting a packet with a spoofed address. The address may belongs to a genuine participant and the MPLS Switch will be assuming the forged packet is from the genuine source. The MPLS switch will reply to the forged spoofed packets. This can cause DOS attack since the MPLS switch is always busy replying the attacker.\\

    Insertion of malicious data using VPN Labels . To do this the attacker should know the labels of the target VPN and the access details of the corresponding egress LER or PER. The attacker inject packets manipulated with the VPN labels and labelled to reach the target LER. Once the packets reach the target LER, it will forward the packets to the target VPN. This attack is not very easy since its need too much of information about the MPLS cloud which is generally very difficult to gain.\\

    Insertion of malicious data using LER Labels: This attack is done by manipulating the labels to reach the packets to the target VPN.  The difference between this attack and the one mentioned above is the VPN labels can be ignored. once the packets reach the target LER, then it will forward the packets to an attached VPN site or to a remote VPN site or to the MPLS core. This can even result in looping. To do this attack the attacker should know which LER is accepting packets labelled from outside\\

     \subsubsection{Denial-of-Service (DOS) Attacks}

DOS is a type of attack which make any service unavailable to its legitimate users. Each system have an upper scale on the number of requests in a second to handle. If the requests coming in are beyond its capacity, then the overloading requests may not be able to serve. If the requests are basically from an attacker just to make the system busy handling the request maximum to its capacity, then the legitimate requests from genuine users won’t be served. Financial services, e commerce websites etc are very vulnerable to such attacks since these types of services expects huge number of transactions in a second. There are many ways an attacker can initiate a DOS attack in MPLS Networks are few of them are listed below.\\

    Modifying the Community Attribute in LERs: To conduct this attack, there should be a target VPN and the attacker should gain access to the PER connected to the VPN. The attacker can modify the VRF table of in the PER associated to the target VPN and then distrust the incoming and outgoing traffic on the target VPN. \\

    Notification Messages Fabrication: This is an attack targeted on LDP Sessions. If the signalling protocol is LDP, then closing the LDP Session will cause tearing down the LSP. If an attacker gets access of an MPLS Link of a MPLS Switch, it can send fabricated LDP Notification message. Upon accepting the LDP Notification message, the LDP Peer will close the LDP Session and the LSP will get closed and traffic through that LSP will be dropped and the Link will be unavailable to the legitimate users. If the attacker gained access of all the links of the MPLS Switch, they can close all the LSPs and causing all the traffic to drop\cite{palmieri_fiore_2007}. \\

    Blocking Keep-Alive Messages:  Similar to the Notification message fabrication, attacker can block the keep alive messages. Not receiving the LDP Keep alive message for a configured interval will lead to closing of the LDP Session and shutting of the LSP. This attack is difficult to identify.\\

    Address Withdraw Messages Fabrication : Address withdraw message is send by LDP when it detect a Link which is down and not in operation. An attacker can send such a manipulated message about one LSR to another causing removal of the link from the received LSRs table. When a genuine packet come to the LSR to a destination originally should be routed through the removed link will get routed through another congested link or will get dropped. This will cause DOS attack to the genuine MPLS users.\\

    Label Withdraw Messages Fabrication: Similar to address withdrawal message, attacker can manipulate Label withdrawal message and upon receiving this message the subsequent MPLS router will remove the label from its FEC and lead to flushing of the LSP.\\

    Label Memory Exhaustion: If the LSR is in label retention mode, then flooding those LSRs with label mapping messages will cause it to store such labels. Once the label table memory is exhausted then the LSRs will flush the labels which is in use and use the flooded labels instead. This will cause flushing the working LSPs and creating new LSPs with the manipulated labels.\\

    LSP Deletion: this attack is targeted on RSVP uses, I mean the signalling protocol is RSVP. Similar to label withdrawal message, RSVP can send ‘PathTear’ message if it want to remove any labels from the FEC. Manipulating such packets can cause closing of a working LSP and lead to disruption in the network connectivity and thus DOS attack.\\

\subsection{Cross domain attacks}

A MPLS Customer Edge router(CE) is sending IP (V4 or V6) traffic to Provider Edge(PE) Router and PE router is responsible for assigning labels according to the FEC. An attacker can exploit this cross domain communication between CE and PE (MPLS and Non MPLS domains) and can do various attacks, few are listed below,\\

    Promiscuous Path Acceptance: This attack is possible when the signalling protocol is RSVP. When MPLS traffic engineering is performed, RSVP is used as the signalling protocol as it can perform various quality of service activities. If a service provider MPLS Switch is used for Integrated Services Quality of Service, a Provider Edge Router would receive and accept packets with Router Alert options set by the RSVP as part of QOS and Traffic Engineering. Those packets are guaranteed to be forwarded. This attack is very dangerous because the attacker can do any sort of Traffic Engineering changes in the MPLS Network.\\

    Pre-Labeled Traffic Acceptance: If a Provider Edge (PE) is configured to accept relabelled packets from a Customer Edge Router, then gaining access to a CE router can be dangerous because the attacker can inject packets with relabelled and the MPLS network will be exposed to many kind of signalling attacks.\\

\section{Existing security tools}

There are many security tools available to protect MPLS\cite{bănuță_2012} which are external to MPLS. There is no single solution but integrating many of them according to the need will make the MPLS core secure from the attacks discussed above. All the tools have its own limitations and complexities. The tools are different by its mode of operation and provided services. Some of them do payload authentication and some of them do data encryption etc. There is no single tool protects the MPLS core from all the threats discussed above. Based on the threat analysis and understanding the threat and its level of damage, the tools to be used can be determined. Some of the widely used security tools are listed below.

 \subsection{Application Data Encryption}

 TLS\cite{rfc8446} is a service used to for reliable secured data transfer. This is very similar to the application data encryption, but TLS create a secure channel between the sender and receiver. There are handshakes and key exchanges in TLS. The payload is send as cipher text. Here also the data encryption and deception is a responsibility of the user application.However the problem with TLS is that the Layer 3 field is plain text and it can be exposed to the attacker. Upon accessing such packet by the attacker, he/she can plan various attacks such as route modification attacks to the data.

\subsection{IP Security (IPSec)}

IPSec\cite{shirazi_asim_irfan_ikram_2010} is another tool which gives the data confidentiality. IPSec can give end to end and hop-by-hop protection. The nest way is to use IPSec between the users seated by an MPLS cloud. I mean between the data source and data destination which is placed either side of the MPLS Network. Data will be encrypted before fed to the MPLS Network. Upon receiving the packet by the destination, IPSec will conduct decryption of data, check the integrity of the data. IPSec can authenticate the participants of the VPN which give additional security. However if the data type Is of non IP, then IPSec cannot be implemented.

\subsection{Link layer security (MACSec)}

MACSec\cite{jeong_park_park_seo_han_jung_2016} is a tool used to for encrypting at the Ethernet level. MAC sec is hop-by-hop solution which is applied in between two adjacent communications routers. In the case of MPLS, MACsec can be applied between adjacent LSRs. Inorder to gain end to end protection, MAC sec need to be applied between all the LSRs. The drawback of MACsec is that encrypting and decrypting the data at each hope cause additional latency and chances of financial transactions timing out or delay in live streaming etc make MACsec not favourite. \\

      All the above-mentioned tools have its advantages and disadvantages. All the tools are very powerful in doing what it offered at the same time it can lead to additional complexities in the Network. All of the tools are designed for certain use cases. MPLS Opportunistic Security is an additional tool to protect the MPLS Network from the above discussed threats and it's not a substitute or replacement for any of the tools we discussed above. The tools discussed above are not exclusive to MPLS and not desired by evaluating all the MPLS related threats. MPLS OS is designed for MPLS network after analyzing all the possible threats in MPLS Networks.

max_stars_repo_licenses: Linux-OpenIB Naumen Condor-1.1 MS-PL

max_issues_repo_licenses: Linux-OpenIB Naumen Condor-1.1 MS-PL

max_forks_repo_licenses: Linux-OpenIB Naumen Condor-1.1 MS-PL


text:
%!TEX root = ../Thesis.tex
\chapter{Spatial Discretization \label{ch:SpatialDiscretization}}
In \Fref{ch:ArnoldiMethod} necessity of spatially discretizing the fission source in order to take the inner product was introduced.  The inner product is necessary for orthogonalizing and normalizing the Arnoldi vectors.  The discretization causes an error in the eigenvalue estimate if the discretization is too coarse.

The effect of discretization was demonstrated in \Fref{sec:ArnoldiResults} and in \Fref{fig:BasicBias} the error in the eigenvalue estimate is shown as a function of the spatial bin width.   We see from this figure the importance of having a sufficient number of spatial bins to eliminate discretization errors.  Using a large number of spatial bins will remove the error in the eigenvalue estimate associated with discretization, but can increase the computational expense of sampling from and scoring in a fission source, as well as taking the inner product of two fission sources if too many bins are used.

When sampling from a discretized fission source, or tallying in a discretized fission source, the bin to sample/tally must be determined.  The time required to find the appropriate bin is proportional to the number of spatial bins used, so as the number of spatial bins increases, the time required for sampling or tallying increases and the figure of merit decreases.

When choosing a discretization strategy, it is important to find the smallest number of spatial bins that will reduce the eigenvalue error due to spatial discretization smaller than the statistical uncertainty.  We must be careful not to use too many spatial bins or the efficiency will suffer.

In \Fref{fig:BasicBias} we see that the slopes of the linear best fit approximations have values ranging from 1.8 to 1.9.  This indicates there is a nearly quadratic or second-order relationship between the spatial discretization and the error in the eigenvalue estimate.  In this chapter I will demonstrate a higher order accurate approximation to the spatial discretization and show how it reduces the error caused by the discretization of the fission source.  This idea is based on work performed by \citet{Griesheimer:2005Funct-0} on Functional Expansion Tallies.

\section{Second-Order Accurate Approximation---Linear in Space  \label{sec:LinearSpace}}
The spatial approximation used in \Fref{ch:ArnoldiMethod} is a first-order accurate approximation, i.e. constant in space.  The fission source was approximated as
\begin{equation}
    \vP(x) = \sum_{b=1}^B a_b \Px,
    \label{eq:ApproximatedSource}
\end{equation}
where $B$ is the number of spatial bins and
\begin{equation}
    \Pi_b(x) = \begin{cases}
        \left(\frac{1}{x_{b+1}-x_b}\right)^{1/2}, & x_b \leq x < x_{b+1} \\
        0, & \mathrm{otherwise}.
    \end{cases}
    \label{eq:FirstOrderApproximation}
\end{equation}
The fission source, $\vP(x)$ is represented in Arnoldi's method as a vector of the form
\begin{equation}
    \vP = \left[a_1, a_2, \ldots, a_B\right]^T.
    \label{eq:ConstantSpaceArnoldiVector}
\end{equation}

A spatial discretization of order 2 is not very different from the first-order accurate approximation given in \Fref{eq:ApproximatedSource} and \Fref{eq:FirstOrderApproximation}.  We approximate the fission source as a linear combination of functions
\begin{equation}
    \vL(x) = \sum_{b=1}^B \Lx,
    \label{eq:LinearSource}
\end{equation}
where $B$ is the number of spatial bins.  The fission source in each bin is approximated by a linear function, \Lx, over the range of the bin:
\begin{equation}
    \Lx = \begin{cases}
        \alpha_b + \beta_b x, & x_b \leq x < x_{b+1} \\
        0, & \mathrm{otherwise}.
    \end{cases}
    \label{eq:SecondOrderApproximation}
\end{equation}
In this second-order accurate approximation the term $\beta_b x$ is included which preserves some of the spatial information ignored in a first-order accurate approximation.  Similarly to the first-order accurate approximation, the Arnoldi vector representation of \vL{} is a vector of the form
\begin{equation}
    \vL = \left[\alpha_1, \beta_1, \alpha_2, \beta_2, \ldots, \alpha_n, \beta_B\right]^T.
    \label{eq:LinearSpaceArnoldiVector}
\end{equation}
The inner product between two piecewise linear in space fission sources is defined to be
\begin{equation}
    \langle \vP^{(j)},\vP^{(k)}\rangle = \sum_{b=1}^B \left(\alpha_b^{(j)}\alpha_b^{(k)} + \beta_b^{(j)}\beta_b^{(k)} \right).
    \label{eq:InnerProductLinearSources}
\end{equation}

\subsection{Sampling} \label{sec:SecondOrderSample}
The integral
\begin{equation}
    q_b = \int \left|\Lx\right| \dd x
    \label{eq:IntegratedSourceBin}
\end{equation}
represents the rate of fission neutrons generated in the range $\left[x_b, x_{b+1}\right)$ and its magnitude---relative to the integrals over every other bin---is the probability of sampling a neutron from that bin.  We can create a normalized, discrete distribution $p(x) = \left\{p_b\right\}_{b=1}^B$ where $p_b = q_b/Q$ and $Q = \sum_{b=1}^B q_b$ is the total source strength.  We can sample a bin from $p(x)$ as we did for a first-order fission source.  Once a bin has been chosen, the position of the neutron is sampled from within the bin with the distribution function defined as
\begin{equation}
    p_b(x) = \frac{1}{q_b} \left|\Lx\right|
    \label{eq:BinPDF}
\end{equation}
where $q_b$ is from \Fref{eq:IntegratedSourceBin}.  Once the position of the neutron has been sampled we give it a weight just as in \Fref{sec:NegativeSource}
\begin{equation}
    \omega = \begin{cases}
        1 & v(x_s) > 0 \\
        -1 & v(x_s) < 1.
    \end{cases}
    \label{eq:SecondOrderInitialWeight}
\end{equation}

\subsection{Determining the Expansion Coefficients $\alpha$ and $\beta$}
With the fission source being approximated by the function in \Fref{eq:SecondOrderApproximation} we turn our attention to determining the expansion coefficients $\alpha$ and $\beta$.  To do this we must evaluate two integrals, something that is is well suited for Monte Carlo methods.  We first define the midpoint of bin $b$
\begin{equation}
    \xmid = \frac{x_{b+1}+x_b}{2}.
    \label{eq:xmid}
\end{equation}
Taking the zeroth and first spatial moments over the bin
\begin{subequations}\label{eq:SpatialMoments}\begin{align}
        \int_{x_b}^{x_{b+1}} \Lx \dd x  &= \frac{1}{2}\left(x_{b+1} - x_b\right)\left[2\alpha_b + \beta_b\left(x_{b+1} + x_b\right)\right] \label{eq:ZerothMoment} \\[2ex]
        \int_{x_b}^{x_{b+1}} \left(x-\xmid\right)\Lx \dd x &= \frac{\beta_b}{12}\left(x_{b+1} - x_b\right)^3 \label{eq:FirstMoment}
    \end{align}
\end{subequations}
gives two equations for $\alpha_b$ and $\beta_b$.  The left-hand side of \Fref{eq:SpatialMoments} can be evaluated via Monte Carlo
\begin{subequations}\label{eq:SpatialMomentsMC}\begin{align}
    \int_{x_b}^{x_{b+1}} \Lx \dd x &= \frac{1}{N}\sum_{i=1}^N \omega_i  \label{eq:ZerothMomentMC} \\[2ex]
    \int_{x_b}^{x_{b+1}} \left(x_i-\xmid\right)\Lx \dd x &= \frac{1}{N}\sum_{i=1}^N \left(x-\xmid\right)\omega_i \label{eq:FirstMomentMC}
    \end{align}
\end{subequations}
where $N$ is the number of source particles and $\omega_i$ and $x_i$ are the weight and position of the particle that induces fission in bin $b$.  Note that $\omega_i$ can be negative.  By equating \Fref{eq:ZerothMoment} with \Fref{eq:ZerothMomentMC} and \Fref{eq:FirstMoment} with \Fref{eq:FirstMomentMC} we can obtain expressions for $\alpha_b$ and $\beta_b$
\begin{subequations}
    \begin{align}
        \alpha_b &= \frac{1}{x_{b+1}-x_b}\frac{1}{N} \sum_{i=1}^N \omega_i - \frac{\beta_b}{2}\left(x_{b+1}+x_b\right) \label{eq:alpha_b} \\
        \beta_b &= \frac{12}{\left(x_{b+1}-x_b\right)^3}\frac{1}{N} \sum_{i=1}^N \left(x_i-\xmid\right)\omega_i \label{eq:beta_b}
    \end{align}
    \label{eq:ExpansionCoefficients}
\end{subequations}
For Monte Carlo particle transport this means every time a fission is caused in bin $b$ the tallies $\omega_i$ and  $\left(x_i - \xmid\right)\omega_i$ are recorded.  At the end of the iteration, when the sampling and tallying are finished, the fission source is normalized similarly to the constant in space approximated source (\Fref{eq:SourceScaling})
\begin{equation}
    \vL^{(j+1)}(x) = \A \vL^{(j)}(x) \int |\vL^{(j)}(x)| \dd x.
    \label{eq:SecondOrderSourceScaling}
\end{equation}
Notice the difference between \Fref{eq:SecondOrderSourceScaling} and \Fref{eq:SourceScaling} is the term $1/N$ is missing here.  The source is still scaled by the number of source particles in \Fref{eq:alpha_b} and \Fref{eq:beta_b}.

\section{Numerical Results}
To demonstrate the difference between a first and second-order accurate approximation to the fission source a series of simulations, similar to those given in \Fref{sec:DiscretizationBias} has been performed.  In \Fref{sec:DiscretizationBias} the effect of the coarseness of the spatial discretization on the bias of the eigenvalue estimate was shown by performing the same calculation but varying the number of spatial bins.  Here, the same set of calculations is performed,  a second-order accurate, linear in space approximation is used to the fission source.  The results will be compared with the results from \Fref{sec:DiscretizationBias}.

The problem is a 20 mfp thick semi-infinite homogeneous slab of multiplying material with cross sections \mbox{$\nu\Sigma_f = 1.0$}, \mbox{$\Sigma_a = 0.2$}, and \mbox{$\Sigma_s = 0.8$}; \mbox{$\Sigma_t = 1.0$}.  In each iteration $10^5$ histories are tracked, 10 iterations per restart with 50 inactive restarts and 500 active restarts.  The number of spatial bins range from 10 to 150.  Both first and second order approximations start with a uniform source across the entire slab.  First-order accurate results are denoted with a subscript $\Pi$ and second-order accurate results are denoted with a subscript $\Lin$.

On the following pages I present tables showing the numerical results of the bias and uncertainty of the estimated eigenvalues.  Tables \ref{tab:Bias0Histogram} and \ref{tab:Bias0Linear} show the results for the fundamental eigenvalue for the first and second-order accurate approximations, respectively.  In each of these tables is the eigenvalue estimate ($\lambda$), the standard deviation ($\sigma$), the error in the eigenvalue estimate ($\mathcal{B}$) and the figure of merit (FOM).  The error is the absolute value of the difference between the estimated eigenvalue and the published reference values from \cite{Garis:1991One-s-0} and \cite{Dahl:1979Eigen-0}.

\begin{table} \centering
    \subfloat[First-order accurate ($\Pi$) spatial discretization]{%
    \begin{tabular}{cccccc}
        \toprule
        \# Bins & Bin Width (mfp) & $\lambda_{\Pi}$ & $\sigma_{\Pi}$ & $\mathcal{B}_{\Pi}$ & FOM ($\Pi$) \\
        \midrule
         10 & 2.00 & 4.8003 & 6.6\e{-4} & 2.7\e{-2} & 831.2 \\
         25 & 0.80 & 4.8224 & 6.8\e{-4} & 5.3\e{-3} & 773.2 \\
         40 & 0.50 & 4.8251 & 6.3\e{-4} & 2.6\e{-3} & 872.0 \\
         50 & 0.40 & 4.8273 & 6.5\e{-4} & 4.2\e{-4} & 829.0 \\
         60 & 0.33 & 4.8258 & 6.9\e{-4} & 2.0\e{-3} & 704.3 \\
         75 & 0.27 & 4.8275 & 6.7\e{-4} & 2.4\e{-4} & 753.0 \\
         90 & 0.22 & 4.8277 & 6.7\e{-4} & 4.2\e{-5} & 746.1 \\
        105 & 0.19 & 4.8277 & 6.9\e{-4} & 5.2\e{-5} & 698.3 \\
        120 & 0.17 & 4.8282 & 6.5\e{-4} & 4.1\e{-4} & 767.8 \\
        135 & 0.15 & 4.8274 & 7.0\e{-4} & 3.1\e{-4} & 656.9 \\
        150 & 0.13 & 4.8285 & 6.4\e{-4} & 7.5\e{-4} & 792.0 \\
        \bottomrule
    \end{tabular}
    \label{tab:Bias0Histogram}}

    \subfloat[Second-order accurate ($\Lin$) spatial discretization]{%
    \begin{tabular}{cccccc}
        \toprule
        \# Bins & Bin Width (mfp) & $\lambda_{\Lin}$ & $\sigma_{\Lin}$ & $\mathcal{B}_{\Lin}$ & FOM ($\Lin$) \\
        \midrule
         10 & 2.00 & 4.8302 & 1.2\e{-3} & 2.5\e{-3} & 259.5 \\
         25 & 0.80 & 4.8280 & 4.4\e{-4} & 2.1\e{-4} & 1765.7 \\
         40 & 0.50 & 4.8283 & 4.5\e{-4} & 5.7\e{-4} & 1675.6 \\
         50 & 0.40 & 4.8277 & 4.5\e{-4} & 6.2\e{-5} & 1470.6 \\
         60 & 0.33 & 4.8283 & 3.9\e{-4} & 5.4\e{-4} & 2171.6 \\
         75 & 0.27 & 4.8276 & 4.0\e{-4} & 1.5\e{-4} & 2069.3 \\
         90 & 0.22 & 4.8275 & 3.8\e{-4} & 2.0\e{-4} & 2251.3 \\
        105 & 0.19 & 4.8259 & 5.9\e{-4} & 1.8\e{-3} & 877.1 \\
        120 & 0.17 & 4.8172 & 1.3\e{-3} & 1.1\e{-2} & 189.4 \\
        135 & 0.15 & 4.8110 & 2.1\e{-3} & 1.7\e{-2} & 66.2 \\
        150 & 0.13 & 4.8102 & 2.0\e{-3} & 1.8\e{-2} & 73.0 \\
        \bottomrule
    \end{tabular}
    \label{tab:Bias0Linear}}
    \caption{Error ($\mathcal{B}$) in the fundamental eigenvalue estimate ($\lambda$) for first-order accurate \subref{tab:Bias0Histogram} and second-order accurate \subref{tab:Bias0Linear} discretization as a function of the bin width.  Figure of merit is also given for first and second-order accurate spatial discretizations.  1E5 particles were tracked in each iteration.}
\end{table}

\begin{comment}
\begin{table}[p] \centering
    \begin{tabular}{cccccc}
        \toprule
        \# Bins & Bin Width (mfp) & $\lambda_{\Pi}$ & $\sigma_{\Pi}$ & $\mathcal{B}_{\Pi}$ & FOM ($\Pi$) \\
        \midrule
         10 & 2.00 & 4.2839 & 6.4\e{-4} & 2.7\e{-2} & 831.2 \\
         25 & 0.80 & 4.3652 & 6.5\e{-4} & 5.3\e{-3} & 773.2 \\
         40 & 0.50 & 4.3754 & 6.1\e{-4} & 2.6\e{-3} & 872.0 \\
         50 & 0.40 & 4.3794 & 5.8\e{-4} & 4.2\e{-4} & 829.0 \\
         60 & 0.33 & 4.3796 & 6.3\e{-4} & 2.0\e{-3} & 704.3 \\
         75 & 0.27 & 4.3807 & 6.4\e{-4} & 2.4\e{-4} & 753.0 \\
         90 & 0.22 & 4.3819 & 6.3\e{-4} & 4.2\e{-5} & 746.1 \\
        105 & 0.19 & 4.3805 & 6.3\e{-4} & 5.2\e{-5} & 698.3 \\
        120 & 0.17 & 4.3819 & 6.1\e{-4} & 4.1\e{-4} & 767.8 \\
        135 & 0.15 & 4.3810 & 6.3\e{-4} & 3.1\e{-4} & 656.9 \\
        150 & 0.13 & 4.3827 & 6.3\e{-4} & 7.5\e{-4} & 792.0 \\
        \bottomrule
    \end{tabular}
    \caption{First higher order eigenvalue bias for first-order accurate ($\Pi$) spatial discretization.  }
    \label{tab:Bias1Histogram}
\end{table}
\begin{table}[p] \centering
    \begin{tabular}{cccccc}
        \toprule
        \# Bins & Bin Width (mfp) & $\lambda_{\Lin}$ & $\sigma_{\Lin}$ & $\mathcal{B}_{\Lin}$ & FOM ($\Lin$) \\
        \midrule
         10 & 2.00 & 4.3867 & 2.3\e{-3} & 2.5\e{-3} & 259.5 \\
         25 & 0.80 & 4.3832 & 6.6\e{-4} & 2.1\e{-4} & 1765.7 \\
         40 & 0.50 & 4.3825 & 6.6\e{-4} & 5.7\e{-4} & 1675.6 \\
         50 & 0.40 & 4.3839 & 6.0\e{-4} & 6.2\e{-5} & 1470.6 \\
         60 & 0.33 & 4.3835 & 6.2\e{-4} & 5.4\e{-4} & 2171.6 \\
         75 & 0.27 & 4.3814 & 8.7\e{-4} & 1.5\e{-4} & 2069.3 \\
         90 & 0.22 & 4.3744 & 2.1\e{-3} & 2.0\e{-4} & 2251.3 \\
        105 & 0.19 & 4.3544 & 1.7\e{-3} & 1.8\e{-3} & 877.1 \\
        120 & 0.17 & 4.2712 & 5.2\e{-3} & 1.1\e{-2} & 189.4 \\
        135 & 0.15 & 4.1913 & 1.0\e{-2} & 1.7\e{-2} & 66.2 \\
        150 & 0.13 & 3.9961 & 1.2\e{-2} & 1.8\e{-2} & 73.0 \\
        \bottomrule
    \end{tabular}
    \caption{First higher order eigenvalue bias for second-order accurate ($\Lin$) spatial discretization.  }
    \label{tab:Bias1Linear}
\end{table}

\begin{table}[p] \centering
    \begin{tabular}{cccccc}
        \toprule
        \# Bins & Bin Width (mfp) & $\lambda_{\Pi}$ & $\sigma_{\Pi}$ & $\mathcal{B}_{\Pi}$ & FOM ($\Pi$) \\
        \midrule
         10 & 2.00 & 3.6321 & 5.4\e{-4} & 2.7\e{-2} & 831.2 \\
         25 & 0.80 & 3.7826 & 6.2\e{-4} & 5.3\e{-3} & 773.2 \\
         40 & 0.50 & 3.8032 & 5.9\e{-4} & 2.6\e{-3} & 872.0 \\
         50 & 0.40 & 3.8091 & 5.8\e{-4} & 4.2\e{-4} & 829.0 \\
         60 & 0.33 & 3.8108 & 5.9\e{-4} & 2.0\e{-3} & 704.3 \\
         75 & 0.27 & 3.8127 & 6.1\e{-4} & 2.4\e{-4} & 753.0 \\
         90 & 0.22 & 3.8151 & 5.4\e{-4} & 4.2\e{-5} & 746.1 \\
        105 & 0.19 & 3.8148 & 5.7\e{-4} & 5.2\e{-5} & 698.3 \\
        120 & 0.17 & 3.8171 & 5.8\e{-4} & 4.1\e{-4} & 767.8 \\
        135 & 0.15 & 3.8167 & 5.6\e{-4} & 3.1\e{-4} & 656.9 \\
        150 & 0.13 & 3.8167 & 6.1\e{-4} & 7.5\e{-4} & 792.0 \\
        \bottomrule
    \end{tabular}
    \caption{Second higher order eigenvalue bias for first-order accurate ($\Pi$) spatial discretization.  }
    \label{tab:Bias2Histogram}
\end{table}
\begin{table}[p] \centering
    \begin{tabular}{cccccc}
        \toprule
        \# Bins & Bin Width (mfp) & $\lambda_{\Lin}$ & $\sigma_{\Lin}$ & $\mathcal{B}_{\Lin}$ & FOM ($\Lin$) \\
        \midrule
         10 & 2.00 & 3.8330 & 4.3\e{-3} & 2.5\e{-3} & 259.5 \\
         25 & 0.80 & 3.8192 & 1.0\e{-3} & 2.1\e{-4} & 1765.7 \\
         40 & 0.50 & 3.8157 & 1.0\e{-3} & 5.7\e{-4} & 1675.6 \\
         50 & 0.40 & 3.8155 & 1.1\e{-3} & 6.2\e{-5} & 1470.6 \\
         60 & 0.33 & 3.8162 & 1.2\e{-3} & 5.4\e{-4} & 2171.6 \\
         75 & 0.27 & 3.8089 & 2.0\e{-3} & 1.5\e{-4} & 2069.3 \\
         90 & 0.22 & 3.2808 & 4.6\e{-3} & 2.0\e{-4} & 2251.3 \\
        105 & 0.19 & 3.1759 & 4.3\e{-3} & 1.8\e{-3} & 877.1 \\
        120 & 0.17 & 2.8474 & 1.7\e{-2} & 1.1\e{-2} & 189.4 \\
        135 & 0.15 & 1.7544 & 2.0\e{-2} & 1.7\e{-2} & 66.2 \\
        150 & 0.13 & 1.4275 & 3.6\e{-3} & 1.8\e{-2} & 73.0 \\
        \bottomrule
    \end{tabular}
    \caption{Second higher order eigenvalue bias for second-order accurate ($\Lin$) spatial discretization.  }
    \label{tab:Bias2Linear}
\end{table}
\end{comment}

The purpose of going to a second-order accurate accurate approximation to the fission source is to reduce the error in the eigenvalue estimate associated with discretizing the fission source.  We can see from tables \ref{tab:Bias0Histogram} and \ref{tab:Bias0Linear} that for bin widths between 0.4 and 2.0 mfp thick the error in the eigenvalue estimate from the second-order accurate approximation is an order of magnitude smaller than the error from the first-order accurate approximation.  Thus, moving to a second-order accurate approximation to the fission source can greatly reduce the error.

The second-order accurate approximation has a smaller statistical uncertainty than the first-order accurate approximation for bin widths between 0.8 and 0.22 mfp and is fairly independent of the bin width in this range.  The uncertainty for the first-order accurate approximation appears to be independent of the size of the bin width over the whole range of bin widths.  The largest and three smallest bin widths from the second-order accurate approximation however have large errors in the eigenvalue estimate and large statistical uncertainties.  For thin bins, the number of neutrons that are born in those bins is small, causing the Monte Carlo noise to dominate the results.  The behavior of the linear-in-space approximation in the 2 mfp wide bins is a mystery.

The figure of merit is 2-3 times larger for the second-order accurate approximation than the first-order for bin widths between 0.8 and 0.22 mfp.  For very small bin widths or for the largest bin width, the figure of merit is smaller for the second-order accurate approximation than the first-order.  The figure of merit as a function of bin width is shown graphically in \Fref{fig:BiasFOM}.
\begin{sidewaysfigure} \centering
    \input{SpatialDiscretization/Data/BiasFOM}
    \caption{Figure of merit as a function of bin width for a slab of width 20 mfp and tracking 1E5 particles per iteration.  Included are results from a first-order ($\Pi$) and second-order ($\Lin$) approximation to the fission source.}
    \label{fig:BiasFOM}
\end{sidewaysfigure}

In the first-order accurate approximation, the shape of the eigenvectors were limited by the flat approximation in each bin.  Since the second-order accurate approximation is a linear approximation in each bin, we expect the second-order accurate approximation to have an improved eigenvector than the first-order accurate approximation.  In \Fref{fig:LinearVectors} the eigenvectors from the second-order accurate approximation with 60 spatial bins are shown.  In \Fref{fig:SpatialDiscretizationVectors}, the same eigenvectors are plotted along with the eigenvectors from the first-order accurate approximation to show they have the same shape.  From these figures we see that the second-order accurate approximation is a smooth approximation to the fission source and appears continuous across the bin boundaries.
\begin{sidewaysfigure} \centering
    \input{SpatialDiscretization/Data/LinearVectors}
    \caption{Estimates of the fundamental and first two harmonic eigenvectors, tracking 1E5 particles per iteration and, using 60 spatial bins with a second-order accurate approximation to the fission source.}
    \label{fig:LinearVectors}
\end{sidewaysfigure}

\begin{sidewaysfigure} \centering
    \input{SpatialDiscretization/Data/Vectors}
    \caption{Estimates of the fundamental and first two harmonic eigenvectors tracking 1E5 particles per iteration and using 60 spatial bins.  The sawtooth shaped curves use a  first-order accurate approximation while the smooth curves use a second-order accurate approximation to the fission source.}
    \label{fig:SpatialDiscretizationVectors}
\end{sidewaysfigure}

For small bin widths the second-order accurate approximation seems to have difficulties due to too few particles scoring in a bin.  If more particles were tracked in an iteration we expect more particles to score in each bin and the statistical uncertainty to improve.  The above simulations have been repeated, but have tracked 1E6 particles in each iteration---ten times more particles---to improve the statistics in each simulation.  The results for the first-order accurate approximation are given in \Fref{tab:Bias0Histogram1E6} and the results for the second-order accurate approximation  are given in \Fref{tab:Bias0Linear1E6}.

Tracking more particles in an iteration seems to have made a big improvement for the second-order accurate approximation with very small bin widths.  Now all the results, except the large bin width of 2 mfp, estimates the fundamental eigenvalue within statistical uncertainty.  Tracking ten times more particles per iteration has improved the poor results from the simulation with small bins and has reduced the standard deviation by approximately one-third, as we expect for the second-order accurate approximation.  The standard deviation was also reduced for the first-order accurate approximation simulations.  The error in the eigenvalue estimate is also significantly smaller for the second-order accurate approximation but remains essentially unchanged for the first-order accurate approximation.

In \Fref{fig:BiasFOM1E6} the figure of merit is shown for the first and second-order spatial approximations, where 1 million particles are tracked for each iteration.  We see that when tracking more particles in an iteration, the figure of merit improves for second-order accurate approximations with small bin widths.  This is because now we have an accurate estimate of the eigenvalue as well as a reduced standard deviation.  With the exception of simulations with very large bin widths, the figure of merit for second-order accurate approximations are two times larger than that for first-order accurate approximations.  It should be noted that the linear-in-space approximation is not only more efficient than the power method, but it is in fact computing 3 eigenpairs compared to the power methods single eigenvector.

The anomaly in these results is the second-order accurate approximation with a bin width of 2.0 mfp.  The error in the eigenvalue estimate is smaller than the error for the same problem but with a first-order accurate approximation, but the eigenvalue estimate is not within statistical uncertainty regardless of the number of particles tracked.  In addition, the error in the eigenvalue estimate is larger than for any other bin width.

\begin{comment}
\begin{sidewaysfigure} \centering
    \input{SpatialDiscretization/Data/BiasLinear1E6}
    \caption{Eigenvalue bias for second-order spatial discretization with 1 million particles tracked.}
    \label{fig:BiasSecondOrder1E6}
\end{sidewaysfigure}
\end{comment}

\begin{table}[p] \centering
    \subfloat[First-order ($\Pi$) spatial discretization]{%
    \begin{tabular}{cccccc}
        \toprule
        \# Bins & Bin Width (mfp) & $\lambda_{\Pi}$ & $\sigma_{\Pi}$ & $\mathcal{B}_{\Pi}$ & FOM ($\Pi$) \\
        \midrule
         10 & 2.00 & 4.8003 & 2.1\e{-4} & 2.7\e{-2} & 838.5 \\
         25 & 0.80 & 4.8232 & 2.2\e{-4} & 4.5\e{-3} & 751.1 \\
         40 & 0.50 & 4.8258 & 2.1\e{-4} & 1.9\e{-3} & 832.9 \\
         50 & 0.40 & 4.8267 & 2.1\e{-4} & 1.1\e{-3} & 796.1 \\
         60 & 0.33 & 4.8270 & 2.1\e{-4} & 7.3\e{-4} & 751.0 \\
         75 & 0.27 & 4.8269 & 2.1\e{-4} & 8.3\e{-4} & 787.5 \\
         90 & 0.22 & 4.8275 & 2.2\e{-4} & 2.7\e{-4} & 694.3 \\
        105 & 0.19 & 4.8274 & 2.1\e{-4} & 3.4\e{-4} & 768.8 \\
        120 & 0.17 & 4.8276 & 2.0\e{-4} & 1.6\e{-4} & 846.8 \\
        135 & 0.15 & 4.8275 & 2.0\e{-4} & 2.6\e{-4} & 793.9 \\
        150 & 0.13 & 4.8280 & 2.1\e{-4} & 2.7\e{-4} & 746.8 \\
        \bottomrule
    \end{tabular}
    \label{tab:Bias0Histogram1E6} }

    \subfloat[Second-order ($\Lin$) spatial discretization]{%
    \begin{tabular}{cccccc}
        \toprule
        \# Bins & Bin Width (mfp) & $\lambda_{\Lin}$ & $\sigma_{\Lin}$ & $\mathcal{B}_{\Lin}$ & FOM ($\Lin$) \\
        \midrule
         10 & 2.00 & 4.8329 & 4.1\e{-3} & 5.1\e{-3} & 2.0 \\
         25 & 0.80 & 4.8274 & 1.5\e{-4} & 3.1\e{-4} & 1607.8 \\
         40 & 0.50 & 4.8278 & 1.4\e{-4} & 6.8\e{-5} & 1742.0 \\
         50 & 0.40 & 4.8276 & 1.5\e{-4} & 1.7\e{-4} & 1512.8 \\
         60 & 0.33 & 4.8276 & 1.3\e{-4} & 1.1\e{-4} & 1832.8 \\
         75 & 0.27 & 4.8277 & 1.4\e{-4} & 5.2\e{-5} & 1692.6 \\
         90 & 0.22 & 4.8278 & 1.4\e{-4} & 7.8\e{-5} & 1730.6 \\
        105 & 0.19 & 4.8279 & 1.4\e{-4} & 1.1\e{-4} & 1701.9 \\
        120 & 0.17 & 4.8278 & 1.3\e{-4} & 4.8\e{-5} & 1985.2 \\
        135 & 0.15 & 4.8279 & 1.3\e{-4} & 1.9\e{-4} & 1757.3 \\
        150 & 0.13 & 4.8277 & 1.2\e{-4} & 6.2\e{-5} & 2015.0 \\
        \bottomrule
    \end{tabular}
    \label{tab:Bias0Linear1E6} }
    \caption{Error ($\mathcal{B}$) in the fundamental eigenvalue estimate ($\lambda$) for first-order \subref{tab:Bias0Histogram} and second-order \subref{tab:Bias0Linear} discretization as a function of the bin width.  Figure of merit is also given for first and second-order spatial discretizations.  1E6 particles were tracked in each iteration.}
\end{table}

\begin{comment}
\begin{table}[ht] \centering
    \begin{tabular}{cccccc}
        \toprule
        \# Bins & Bin Width (mfp) & $\lambda_{\Pi}$ & $\sigma_{\Pi}$ & $\mathcal{B}_{\Pi}$ & FOM ($\Pi$) \\
        \midrule
         10 & 2.00 & 4.2853 & 2.0\e{-4} & 2.7\e{-2} & 838.5 \\
         25 & 0.80 & 4.3658 & 1.9\e{-4} & 4.5\e{-3} & 751.1 \\
         40 & 0.50 & 4.3758 & 1.9\e{-4} & 1.9\e{-3} & 832.9 \\
         50 & 0.40 & 4.3784 & 1.9\e{-4} & 1.1\e{-3} & 796.1 \\
         60 & 0.33 & 4.3802 & 2.0\e{-4} & 7.3\e{-4} & 751.0 \\
         75 & 0.27 & 4.3811 & 2.1\e{-4} & 8.3\e{-4} & 787.5 \\
         90 & 0.22 & 4.3818 & 1.9\e{-4} & 2.7\e{-4} & 694.3 \\
        105 & 0.19 & 4.3820 & 2.1\e{-4} & 3.4\e{-4} & 768.8 \\
        120 & 0.17 & 4.3821 & 2.0\e{-4} & 1.6\e{-4} & 846.8 \\
        135 & 0.15 & 4.3823 & 2.0\e{-4} & 2.6\e{-4} & 793.9 \\
        150 & 0.13 & 4.3824 & 2.0\e{-4} & 2.7\e{-4} & 746.8 \\
        \bottomrule
    \end{tabular}
    \caption{First higher order eigenvalue bias for first-order ($\Pi$) spatial discretization with 1 million particles tracked.  }
    \label{tab:Bias1Histogram1E6}
\end{table}
\begin{table}[hb] \centering
    \begin{tabular}{cccccc}
        \toprule
        \# Bins & Bin Width (mfp) & $\lambda_{\Lin}$ & $\sigma_{\Lin}$ & $\mathcal{B}_{\Lin}$ & FOM ($\Lin$) \\
        \midrule
         10 & 2.00 & 4.3854 & 1.6\e{-3} & 5.1\e{-3} & 2.0 \\
         25 & 0.80 & 4.3830 & 2.1\e{-4} & 3.1\e{-4} & 1607.8 \\
         40 & 0.50 & 4.3834 & 2.1\e{-4} & 6.8\e{-5} & 1742.0 \\
         50 & 0.40 & 4.3829 & 2.0\e{-4} & 1.7\e{-4} & 1512.8 \\
         60 & 0.33 & 4.3830 & 2.1\e{-4} & 1.1\e{-4} & 1832.8 \\
         75 & 0.27 & 4.3831 & 2.2\e{-4} & 5.2\e{-5} & 1692.6 \\
         90 & 0.22 & 4.3833 & 2.1\e{-4} & 7.8\e{-5} & 1730.6 \\
        105 & 0.19 & 4.3830 & 2.1\e{-4} & 1.1\e{-4} & 1701.9 \\
        120 & 0.17 & 4.3828 & 2.0\e{-4} & 4.8\e{-5} & 1985.2 \\
        135 & 0.15 & 4.3832 & 2.1\e{-4} & 1.9\e{-4} & 1757.3 \\
        150 & 0.13 & 4.3832 & 2.5\e{-4} & 6.2\e{-5} & 2015.0 \\
        \bottomrule
    \end{tabular}
    \caption{First higher order eigenvalue bias for second-order ($\Lin$) spatial discretization with 1 million particles tracked.  }
    \label{tab:Bias1Linear1E6}
\end{table}

\begin{table}[ht] \centering
    \begin{tabular}{cccccc}
        \toprule
        \# Bins & Bin Width (mfp) & $\lambda_{\Pi}$ & $\sigma_{\Pi}$ & $\mathcal{B}_{\Pi}$ & FOM ($\Pi$) \\
        \midrule
         10 & 2.00 & 3.6321 & 1.7\e{-4} & 2.7\e{-2} & 838.5 \\
         25 & 0.80 & 3.7830 & 1.8\e{-4} & 4.5\e{-3} & 751.1 \\
         40 & 0.50 & 3.8037 & 1.8\e{-4} & 1.9\e{-3} & 832.9 \\
         50 & 0.40 & 3.8081 & 1.8\e{-4} & 1.1\e{-3} & 796.1 \\
         60 & 0.33 & 3.8111 & 1.9\e{-4} & 7.3\e{-4} & 751.0 \\
         75 & 0.27 & 3.8133 & 1.9\e{-4} & 8.3\e{-4} & 787.5 \\
         90 & 0.22 & 3.8148 & 1.9\e{-4} & 2.7\e{-4} & 694.3 \\
        105 & 0.19 & 3.8151 & 1.9\e{-4} & 3.4\e{-4} & 768.8 \\
        120 & 0.17 & 3.8159 & 1.8\e{-4} & 1.6\e{-4} & 846.8 \\
        135 & 0.15 & 3.8164 & 1.8\e{-4} & 2.6\e{-4} & 793.9 \\
        150 & 0.13 & 3.8166 & 1.9\e{-4} & 2.7\e{-4} & 746.8 \\
        \bottomrule
    \end{tabular}
    \caption{Second higher order eigenvalue bias for first-order ($\Pi$) spatial discretization with 1 million particles tracked.  }
    \label{tab:Bias2Histogram1E6}
\end{table}
\begin{table}[hb] \centering
    \begin{tabular}{cccccc}
        \toprule
        \# Bins & Bin Width (mfp) & $\lambda_{\Lin}$ & $\sigma_{\Lin}$ & $\mathcal{B}_{\Lin}$ & FOM ($\Lin$) \\
        \midrule
         10 & 2.00 & 3.8234 & 3.1\e{-3} & 5.1\e{-3} & 2.0 \\
         25 & 0.80 & 3.8171 & 3.2\e{-4} & 3.1\e{-4} & 1607.8 \\
         40 & 0.50 & 3.8177 & 3.1\e{-4} & 6.8\e{-5} & 1742.0 \\
         50 & 0.40 & 3.8174 & 3.1\e{-4} & 1.7\e{-4} & 1512.8 \\
         60 & 0.33 & 3.8169 & 3.2\e{-4} & 1.1\e{-4} & 1832.8 \\
         75 & 0.27 & 3.8168 & 3.2\e{-4} & 5.2\e{-5} & 1692.6 \\
         90 & 0.22 & 3.8174 & 3.4\e{-4} & 7.8\e{-5} & 1730.6 \\
        105 & 0.19 & 3.8179 & 3.4\e{-4} & 1.1\e{-4} & 1701.9 \\
        120 & 0.17 & 3.8172 & 3.7\e{-4} & 4.8\e{-5} & 1985.2 \\
        135 & 0.15 & 3.8178 & 4.2\e{-4} & 1.9\e{-4} & 1757.3 \\
        150 & 0.13 & 3.8165 & 5.8\e{-4} & 6.2\e{-5} & 2015.0 \\
        \bottomrule
    \end{tabular}
    \caption{Second higher order eigenvalue bias for second-order ($\Lin$) spatial discretization with 1 million particles tracked.  }
    \label{tab:Bias2Linear1E6}
\end{table}
\end{comment}

\begin{sidewaysfigure} \centering
    \input{SpatialDiscretization/Data/BiasFOM1E6}
    \caption{Figure of merit as a function of bin width for a slab of width 20 mfp and tracking 1E6 particles per iteration.  Included are results from a first-order ($\Pi$) and second-order ($\Lin$) approximation to the fission source.}
    \label{fig:BiasFOM1E6}
\end{sidewaysfigure}

\section{Summary} \label{sec:SpatialDiscretizationSummary}
In this chapter first and second-order accurate approximations to the fission source have been investigated.  These were demonstrated on a semi-infinite, homogeneous slab of multiplying material of width 20 mfp.  Both techniques have an error associated with the discretization.  The power method does not suffer from this kind of error.  It has been shown that for a sufficient number of spatial bins the error in the eigenvalue estimate is smaller than the standard deviation of the eigenvalue estimates.

Using a second-order accurate approximation for the fission source is a significant improvement over the first-order accurate approximation; the standard deviation is smaller and the error in the eigenvalue estimate is an order of magnitude smaller when a sufficient number of particles is used.  The standard deviation becomes smaller for both first and second-order accurate approximations as the number of particles tracked in an iteration increases.  The error in the eigenvalue estimate is not significantly improved for the first-order accurate approximation as the number of particles tracked increases, while the error decreases for the second-order accurate approximation.

The second-order accurate approximation has much better approximation to the eigenvectors.  Because the approximation is linear in space, the eigenvector approximation is smoother in the second-order accurate approximation than in the first-order accurate approximation.  The results shown in this chapter show that the eigenvectors are nearly continuous across bin boundaries for the second-order accurate approximation.

Both the first and second-order accurate approximations have errors in the eigenvalue estimate that are less than the statistical uncertainty for bin widths in the 0.5--0.2 mfp range.  If the spatial discretization is too coarse, too much information is lost; if the discretization is too fine, the Monte Carlo transport is too noisy within each bin to give good results.  In both extreme cases an error eigenvalue estimates arises.  In the second-order accurate approximation, the figure of merit significantly decreases in these extreme case because the variance of the mean of the eigenvalue estimates is larger.

Using a moderate number of spatial bins can give excellent results.  When tracking more particles per iteration, a finer discretization can be used.  Further work needs to be performed to identify---if possible---a general rule for the granularity of the discretization.

ext: tex

max_stars_repo_name: jlconlin/PhDThesis

max_issues_repo_name: jlconlin/PhDThesis

max_forks_repo_name: jlconlin/PhDThesis


text:
\section{Conclusions}

We show that the sensitivity matrix associated with the equivalent layer technique
for processing gravity data has a BTTB structure when the following conditions are
satisfied: (1) the observed data are disposed at a regular grid on a horizontal plane
and (2) the equivalent sources (point masses) are placed at a constant depth, one directly
beneath each observation point.
By exploring the BTTB structure of the sensitivity matrix, we formulate the forward modeling as a
FFT convolution that requires only one column of the sensitivity matrix;
hence, the forward modeling uses, in practice, a single equivalent source,
which results in a drastic reduction of the required RAM memory.
Next, we propose an efficient approach for optimizing the computational time of an
iterative method called fast equivalent-layer technique.
This iterative method is grounded on the excess mass constraint and does not demand the solution of
linear systems.
Compared to the fast equivalent-layer technique,
our approach greatly reduces the number of flops and the RAM memory necessary to estimate a
2D mass distribution within a planar equivalent layer that fits the observed gravity data.
For example, the number of flops is reduced by two orders
of magnitude when processing one million of observations by using our approach.
Traditionally, such amount of data impractically requires $7.6$ TB of memory to handle
the full sensitivity matrix whereas our method takes only $61.035$ MB.
We successfully applied the proposed method to compute the upward/downward continuations of
synthetic gravity data.
The results show that our method produces considerably smaller border effects and
noise amplification compared to the classical Fourier approach,
which computes the Fourier transform of the observed data.
Application to field data over the Caraj{\'a}s Province, north of Brazil,
confirms the potential of our approach in processing an airborne gravity data set with $250,000$ observations in approximately $0.2$ s.
Our method can also be applied to process large marine gravity data sets.
Further studies need to be carried out to apply our method to process
other potential-field data.


text:
%**************************************************************
% Lab 06: Counter
%**************************************************************
\chapter{Counters}

Counters are perhaps the most commonly-used circuits in electronic devices. They are found in virtually all electronics systems, from the simplest embedded computers to massive mainframes. Counters are designed to cycle through a specific predefined sequence of binary numbers when an input pulse is applied. Typically, counters simply count up or down from given start and end numbers, but they can be designed to produce unique output patterns for special uses.

Counters, though, are used for more than simple counting. They can measure time so devices like alarm clocks and watches include counters. They are used as frequency dividers so a fast input frequency can be output at a slower rate. In devices with memory they are used to increment memory addresses as a program steps through some process. They can activate a series of subcircuits in sequence as part of a complex process. They are, in short, one of the most important workhorses of the digital logic world.

\section{Purpose}

This lab has two goals:

\begin{enumerate}
	\item Develop several different common counters using \textit{D} flip-flops. Because there are two main families of counters, asynchronous and synchronous, this lab includes examples of both.
	\item Introduce the \LE chronogram feature that generates a timing diagram as a sequential circuit functions.
\end{enumerate}

\section{Procedure}

\subsection{Asynchronous Up Counter}

A counter is built from a series of flip-flops and where the output from each flip-flop is combined to create the counter output, trigger the next flip-flop, or both. Each flip-flop is considered a ``stage'' of the counter. A counter is triggered by a clock signal that is typically supplied by a timer with a regularly-recurring pattern of high/low levels, but it can also be triggered by an event of some sort, like the press of a button or the completion of a process.

\marginpar{In all Counter circuits in this manual flip-flop U0 provides the Least Significant Bit to the output and U3 provides the Most Significant Bit.}One of the simplest counters is illustrated in Figure \ref{fig:06-01}. This is an asynchronous four-stage up counter. A counter is is considered ``asynchronous'' if the input clock signal is applied to only the first stage and then that signal ripples through each flip-flop in turn. Thus, an asynchronous counter is frequently called a ``ripple'' counter.

\begin{figure}[H]
	\centering
	\includegraphics[width=\maxwidth{.95\linewidth}]{gfx/06-01}
	\caption{Asynchronous Up Counter}
	\label{fig:06-01}
\end{figure}

The following list describes the operation of the counter in Figure \ref{fig:06-01}. Students should open the counter circuit with \LE then use the ``poke'' tool to set the clock high then low (one complete clock cycle) as they follow the description below.

\begin{description}
	\item [Reset is Activated] All flip-flops are reset so \textit{Q} is low and \textit{Q'} is high.

	%%%%%%%%%%%%%%%
	\item [Tick 1] \textit{U0} clocked: \textit{Q0} \textuparrow \: \textemdash \: \textit{Q'0} \textdownarrow

	%%%%%%%%%%%%%%%
	\item [Tick 2] \textit{U0} clocked: \textit{Q0} \textdownarrow \: \textemdash \: \textit{Q'0} \textuparrow

	\hspace{14pt}\textit{U1} clocked: \textit{Q1} \textuparrow \: \textemdash \: \textit{Q'1} \textdownarrow

	%%%%%%%%%%%%%%%
	\item [Tick 3] \textit{U0} clocked: \textit{Q0} \textuparrow \: \textemdash \: \textit{Q'0} \textdownarrow

	%%%%%%%%%%%%%%%
	\item [Tick 4] \textit{U0} clocked: \textit{Q0} \textdownarrow \: \textemdash \: \textit{Q'0} \textuparrow

	\hspace{14pt}\textit{U1} clocked: \textit{Q1} \textdownarrow \: \textemdash \: \textit{Q'1} \textuparrow

	\hspace{14pt}\textit{U2} clocked: \textit{Q2} \textuparrow \: \textemdash \: \textit{Q'2} \textdownarrow

	%%%%%%%%%%%%%%%
	\item [Tick 5] \textit{U0} clocked: \textit{Q0} \textuparrow \: \textemdash \: \textit{Q'0} \textdownarrow

	%%%%%%%%%%%%%%%
	\item [Tick 6] \textit{U0} clocked: \textit{Q0} \textdownarrow \: \textemdash \: \textit{Q'0} \textuparrow

	\hspace{14pt}\textit{U1} clocked: \textit{Q1} \textuparrow \: \textemdash \: \textit{Q'1} \textdownarrow

	%%%%%%%%%%%%%%%
	\item [Tick 7] \textit{U0} clocked: \textit{Q0} \textuparrow \: \textemdash \: \textit{Q'0} \textdownarrow

	%%%%%%%%%%%%%%%
	\item [Tick 8] \textit{U0} clocked: \textit{Q0} \textdownarrow \: \textemdash \: \textit{Q'0} \textuparrow

	\hspace{14pt}\textit{U1} clocked: \textit{Q1} \textdownarrow \: \textemdash \: \textit{Q'1} \textuparrow

	\hspace{14pt}\textit{U2} clocked: \textit{Q2} \textdownarrow \: \textemdash \: \textit{Q'2} \textuparrow

	\hspace{14pt}\textit{U3} clocked: \textit{Q3} \textuparrow \: \textemdash \: \textit{Q'3} \textdownarrow

\end{description}

As the clock continues the counter would cycle through the binary values 1001 - 1111. The following table lists the \textit{Up} counter output as indicated by the \textit{Q} values at each tick listed above.

\begin{table}[H]
	\sffamily
	\newcommand{\head}[1]{\textcolor{white}{\textbf{#1}}}
	\begin{center}
		\rowcolors{2}{gray!10}{white} % Color every other line a light gray
		\begin{tabular}{cc}
			\rowcolor{black!75}
			\head{Tick} & \head{Output} \\
			Reset & 0000 \\
			1 & 0001 \\
			2 & 0010 \\
			3 & 0011 \\
			4 & 0100 \\
			5 & 0101 \\
			6 & 0110 \\
			7 & 0111 \\
			8 & 1000
		\end{tabular}
	\end{center}
	\caption{Up Counter Output}
	\label{tab0601}
\end{table}

\subsection{Asynchronous Down Counter}

The asynchronous down counter illustrated in Figure \ref{fig:06-02} is very similar to the up counter in Figure \ref{fig:06-01} except the stages are triggered from the \textit{Q} output of the preceding stage rather than \textit{Q'} and the \textit{Reset} signal is applied to the flip-flop \textit{S} input rather than \textit{R}.

\begin{figure}[H]
	\centering
	\includegraphics[width=\maxwidth{.95\linewidth}]{gfx/06-02}
	\caption{Asynchronous Down Counter}
	\label{fig:06-02}
\end{figure}

The following list describes the operation of the counter in Figure \ref{fig:06-02}. Students should open the counter circuit with \LE then use the ``poke'' tool to set the clock high then low (one complete clock cycle) as they follow the description below.

\begin{description}
	\item [Reset is activated] All flip-flops are set so \textit{Q} is high and \textit{Q'} is low.

	\item [Tick 1] \textit{U0} clocked: \textit{Q0} \textdownarrow \: \textemdash \: \textit{Q'0} \textuparrow

	%%%%%%%%%%%%%%%
	\item [Tick 2] \textit{U0} clocked: \textit{Q0} \textuparrow \: \textemdash \: \textit{Q'0} \textdownarrow

	\hspace{14pt}\textit{U1} clocked: \textit{Q1} \textdownarrow \: \textemdash \: \textit{Q'1} \textuparrow

	%%%%%%%%%%%%%%%
	\item [Tick 3] \textit{U0} clocked: \textit{Q0} \textdownarrow \: \textemdash \: \textit{Q'0} \textuparrow

	%%%%%%%%%%%%%%%
	\item [Tick 4] \textit{U0} clocked: \textit{Q0} \textuparrow \: \textemdash \: \textit{Q'0} \textdownarrow

	\hspace{14pt}\textit{U1} clocked: \textit{Q1} \textuparrow \: \textemdash \: \textit{Q'1} \textdownarrow

	\hspace{14pt}\textit{U2} clocked: \textit{Q2} \textdownarrow \: \textemdash \: \textit{Q'2} \textuparrow

	%%%%%%%%%%%%%%%
	\item [Tick 5] \textit{U0} clocked: \textit{Q0} \textdownarrow \: \textemdash \: \textit{Q'0} \textuparrow

	%%%%%%%%%%%%%%%
	\item [Tick 6] \textit{U0} clocked: \textit{Q0} \textuparrow \: \textemdash \: \textit{Q'0} \textdownarrow

	\hspace{14pt}\textit{U1} clocked: \textit{Q1} \textdownarrow \: \textemdash \: \textit{Q'1} \textuparrow

	%%%%%%%%%%%%%%%
	\item [Tick 7] \textit{U0} clocked: \textit{Q0} \textdownarrow \: \textemdash \: \textit{Q'0} \textuparrow

	%%%%%%%%%%%%%%%
	\item [Tick 8] \textit{U0} clocked: \textit{Q0} \textuparrow \: \textemdash \: \textit{Q'0} \textdownarrow

	\hspace{14pt}\textit{U1} clocked: \textit{Q1} \textuparrow \: \textemdash \: \textit{Q'1} \textdownarrow

	\hspace{14pt}\textit{U2} clocked: \textit{Q2} \textuparrow \: \textemdash \: \textit{Q'2} \textdownarrow

	\hspace{14pt}\textit{U3} clocked: \textit{Q3} \textdownarrow \: \textemdash \: \textit{Q'3} \textuparrow

\end{description}

As the clock continues the counter would cycle through the binary values 0110 - 0000. The following table lists the \textit{Down} counter output as indicated by the \textit{Q} values at each tick listed above.

\begin{table}[H]
	\sffamily
	\newcommand{\head}[1]{\textcolor{white}{\textbf{#1}}}
	\begin{center}
		\rowcolors{2}{gray!10}{white} % Color every other line a light gray
		\begin{tabular}{cc}
			\rowcolor{black!75}
			\head{Tick} & \head{Output} \\
			Reset & 1111 \\
			1 & 1110 \\
			2 & 1101 \\
			3 & 1100 \\
			4 & 1011 \\
			5 & 1010 \\
			6 & 1001 \\
			7 & 1000 \\
			8 & 0111
		\end{tabular}
	\end{center}
	\caption{Down Counter Output}
	\label{tab0602}
\end{table}

\subsection{Asynchronous Decade Counter}

Binary counters, like those considered in Figure \ref{fig:06-01} and Figure \ref{fig:06-02} are only able to count to a value that is a power of two but it is often necessary to build a counter that stops at some other value. These types of counters are called ``mod'' counters (short for ``modulus'') since they count up to a preset value then reset and start over, like modulus math. One of the most common mod counters is one that has ten states (it counts from zero to nine) and then resets, and that type of counter is generally referred to as a decade counter. Decade counters are found in any application that has to count in decimal for easy human interpretation.

The logic of a  mod counter is to add an \texttt{AND} gate on the flip-flop outputs such that the output of the \texttt{AND} gate is high when the flip-flop outputs equal the mod number. For example, the \texttt{AND} gate for a decade counter would go high when the count reaches ten and that signal would immediately reset the counter back to zero.

\begin{figure}[H]
	\centering
	\includegraphics[width=\maxwidth{.95\linewidth}]{gfx/06-03}
	\caption{Asynchronous Decade Counter}
	\label{fig:06-03}
\end{figure}

The following list describes the operation of the counter in Figure \ref{fig:06-03}:

\begin{description}
	\item [Reset is activated] All flip-flops are reset so \textit{Q} is low and \textit{Q'} is high.

	%%%%%%%%%%%%%%%
	\item [Tick 1] \textit{U0} clocked: \textit{Q0} \textuparrow \: \textemdash \: \textit{Q'0} \textdownarrow

	%%%%%%%%%%%%%%%
	\item [Tick 2] \textit{U0} clocked: \textit{Q0} \textdownarrow \: \textemdash \: \textit{Q'0} \textuparrow

	\hspace{14pt}\textit{U1} clocked: \textit{Q1} \textuparrow \: \textemdash \: \textit{Q'1} \textdownarrow

	%%%%%%%%%%%%%%%
	\item [Tick 3] \textit{U0} clocked: \textit{Q0} \textuparrow \: \textemdash \: \textit{Q'0} \textdownarrow

	%%%%%%%%%%%%%%%
	\item [Tick 4] \textit{U0} clocked: \textit{Q0} \textdownarrow \: \textemdash \: \textit{Q'0} \textuparrow

	\hspace{14pt}\textit{U1} clocked: \textit{Q1} \textdownarrow \: \textemdash \: \textit{Q'1} \textuparrow

	\hspace{14pt}\textit{U2} clocked: \textit{Q2} \textuparrow \: \textemdash \: \textit{Q'2} \textdownarrow

	%%%%%%%%%%%%%%%
	\item [Tick 5] \textit{U0} clocked: \textit{Q0} \textuparrow \: \textemdash \: \textit{Q'0} \textdownarrow

	%%%%%%%%%%%%%%%
	\item [Tick 6] \textit{U0} clocked: \textit{Q0} \textdownarrow \: \textemdash \: \textit{Q'0} \textuparrow

	\hspace{14pt}\textit{U1} clocked: \textit{Q1} \textuparrow \: \textemdash \: \textit{Q'1} \textdownarrow

	%%%%%%%%%%%%%%%
	\item [Tick 7] \textit{U0} clocked: \textit{Q0} \textuparrow \: \textemdash \: \textit{Q'0} \textdownarrow

	%%%%%%%%%%%%%%%
	\item [Tick 8] \textit{U0} clocked: \textit{Q0} \textdownarrow \: \textemdash \: \textit{Q'0} \textuparrow

	\hspace{14pt}\textit{U1} clocked: \textit{Q1} \textdownarrow \: \textemdash \: \textit{Q'1} \textuparrow

	\hspace{14pt}\textit{U2} clocked: \textit{Q2} \textdownarrow \: \textemdash \: \textit{Q'2} \textuparrow

	\hspace{14pt}\textit{U3} clocked: \textit{Q3} \textuparrow \: \textemdash \: \textit{Q'3} \textdownarrow

	%%%%%%%%%%%%%%%
	\item [Tick 9] \textit{U0} clocked: \textit{Q0} \textuparrow \: \textemdash \: \textit{Q'0} \textdownarrow

	%%%%%%%%%%%%%%%
	\item [Tick 10] \textit{U1} clocked: \textit{Q0} \textuparrow \: \textemdash \: \textit{Q'0} \textdownarrow

	\noindent Both inputs for the \texttt{AND} gate are momentarily high and that sends a reset signal that causes all outputs to go low.

\end{description}

As the clock continues the counter would cycle through the binary values 0000 - 1001. The following table lists the \textit{Decade} counter output as indicated by the \textit{Q} values at each tick listed above.

\begin{table}[H]
	\sffamily
	\newcommand{\head}[1]{\textcolor{white}{\textbf{#1}}}
	\begin{center}
		\rowcolors{2}{gray!10}{white} % Color every other line a light gray
		\begin{tabular}{cc}
			\rowcolor{black!75}
			\head{Tick} & \head{Output} \\
			Reset & 0000 \\
			1 & 0001 \\
			2 & 0010 \\
			3 & 0011 \\
			4 & 0100 \\
			5 & 0101 \\
			6 & 0110 \\
			7 & 0111 \\
			8 & 1000 \\
			9 & 1001 \\
		 10 & 0000
		\end{tabular}
	\end{center}
	\caption{Decade Counter Output}
	\label{tab0603}
\end{table}

\subsection{Synchronous Ring Counter}

In a ring counter the high bit is shifted through all of the bits one at a time. This counter is very useful in controlling subcircuits since the high bit in the counter can activate the next subcircuit in the sequence.

The ring counter presented here is also a synchronous circuit; that is, each clock pulse is applied to all of the flip-flops instead of just the first stage. The \textit{Q} output from each flip-flop is used but \textit{Q'} is not needed at all. Also, there is a feedback line from \textit{U3} to the data input port of \textit{U0} so when the \textit{Q} output of \textit{U3} goes high that is made available to \textit{U0} and loop that value back through the circuit.

\begin{figure}[H]
	\centering
	\includegraphics[width=\maxwidth{.95\linewidth}]{gfx/06-04}
	\caption{Synchronous Ring Counter}
	\label{fig:06-04}
\end{figure}

The following list describes the operation of the counter in Figure \ref{fig:06-04}. Students should open the counter circuit with \LE then use the ``poke'' tool to set the clock high then low (one complete clock cycle) as they follow the description below.

\begin{description}
	\item [Reset is activated] \textit{U0} is set and \textit{U1}-\textit{U3} are reset so the counter is seeded with a single high bit to shift.

	%%%%%%%%%%%%%%%
	\item [Tick 1] \textit{Q0} \textdownarrow \: \textemdash \: \textit{Q1} \textuparrow

	%%%%%%%%%%%%%%%
	\item [Tick 2] \textit{Q1} \textdownarrow \: \textemdash \: \textit{Q2} \textuparrow

	%%%%%%%%%%%%%%%
	\item [Tick 3] \textit{Q2} \textdownarrow \: \textemdash \: \textit{Q3} \textuparrow

	%%%%%%%%%%%%%%%
	\item [Tick 4] \textit{Q3} \textdownarrow \: \textemdash \: \textit{Q1} \textuparrow

\end{description}

As the clock continues the counter would cycle through the binary values 0001 - 1000. The following table lists the \textit{ring} counter output as indicated by the \textit{Q} values at each tick listed above.

\begin{table}[H]
	\sffamily
	\newcommand{\head}[1]{\textcolor{white}{\textbf{#1}}}
	\begin{center}
		\rowcolors{2}{gray!10}{white} % Color every other line a light gray
		\begin{tabular}{cc}
			\rowcolor{black!75}
			\head{Tick} & \head{Output} \\
			Reset & 0001 \\
			1 & 0010 \\
			2 & 0100 \\
			3 & 1000 \\
			4 & 0001 \\
			5 & 0010 \\
			6 & 0100 \\
			7 & 1000 \\
			8 & 0001
		\end{tabular}
	\end{center}
	\caption{Ring Counter Output}
	\label{tab0604}
\end{table}

\subsection{Synchronous Johnson Counter}

A Johnson Counter is similar to a ring counter in that a high bit value is shifted through the entire binary word. The difference is that the feedback loop comes from the \textit{Q'} output of the last stage rather than the \textit{Q} output. This type of counter is sometimes called a ``twisted tail'' counter since the \textit{Q'} output is fedback.

\begin{figure}[H]
	\centering
	\includegraphics[width=\maxwidth{.95\linewidth}]{gfx/06-05}
	\caption{Synchronous Johnson Counter}
	\label{fig:06-05}
\end{figure}

The following list describes the operation of the counter in Figure \ref{fig:06-05}. Students should open the counter circuit with \LE then use the ``poke'' tool to set the clock high then low (one complete clock cycle) as they follow the description below.

\begin{description}
	\item [Reset is activated] \textit{U0} is set and \textit{U1}-\textit{U3} are reset so the counter is seeded with a single high bit to shift.

	%%%%%%%%%%%%%%%
	\item [Tick 1] \textit{Q1} \textuparrow

	%%%%%%%%%%%%%%%
	\item [Tick 2] \textit{Q2} \textuparrow

	%%%%%%%%%%%%%%%
	\item [Tick 3] \textit{Q3} \textuparrow

	%%%%%%%%%%%%%%%
	\item [Tick 4] \textit{Q0} \textdownarrow

	%%%%%%%%%%%%%%%
	\item [Tick 5] \textit{Q1} \textdownarrow

	%%%%%%%%%%%%%%%
	\item [Tick 6] \textit{Q2} \textdownarrow

	%%%%%%%%%%%%%%%
	\item [Tick 7] \textit{Q3} \textdownarrow

	%%%%%%%%%%%%%%%
	\item [Tick 8] \textit{Q0} \textuparrow

\end{description}

As the clock continues the counter would cycle through the binary values 0000 - 1111. The following table lists the \textit{Johnson} counter output as indicated by the \textit{Q} values at each tick listed above.

\begin{table}[H]
	\sffamily
	\newcommand{\head}[1]{\textcolor{white}{\textbf{#1}}}
	\begin{center}
		\rowcolors{2}{gray!10}{white} % Color every other line a light gray
		\begin{tabular}{cc}
			\rowcolor{black!75}
			\head{Tick} & \head{Output} \\
			Reset & 0001 \\
			1 & 0011 \\
			2 & 0111 \\
			3 & 1111 \\
			4 & 1110 \\
			5 & 1100 \\
			6 & 1000 \\
			7 & 0000 \\
			8 & 0001
		\end{tabular}
	\end{center}
	\caption{Johnson Counter Output}
	\label{tab0605}
\end{table}

\subsection{Main}

The \lstinline[columns=fixed]|main| circuit provides a human interface to try out each of the counters by dropping them in place of the \textit{Up} counter.

\begin{figure}[H]
	\centering
	\includegraphics[width=\maxwidth{.95\linewidth}]{gfx/06-06}
	\caption{Main Circuit}
	\label{fig:06-06}
\end{figure}

Notice that there are two clocks in the \lstinline[columns=fixed]|main| circuit. \textit{Clk} is linked to the counter being tested and is used within the counter circuit to advance the count. \textit{Sysclk} is used by the \LE chronogram as described in the next section of this document.

\subsection{Chronogram}

\LE can generate a timing diagram, called a \textit{chronogram}, for a sequential circuit. That is a representation of the various signals in a circuit and how those signals change over time. Figure \ref{fig:06-07} is the timing diagram for an Up counter.

\begin{figure}[H]
	\centering
	\includegraphics[width=\maxwidth{.95\linewidth}]{gfx/06-07}
	\caption{Timing Diagram for Up Counter}
	\label{fig:06-07}
\end{figure}

At the top of Figure \ref{fig:06-07} is a scale that indicates the number of seconds that the counter has been operating. The first trace is the input clk signal. The clock goes high at the start of each second and then goes low at the half-second mark. Under the clock is the ``Probe1'' signal. Because that is a four-bit number \LE displays the number, but under that number is a breakout of the four bits that make up that number. Thus, at time zero ``Probe1'' is 0001 and ``Probe1\_s\_0'' (that stands for ``Probe 1, Signal 0'') is high while the other bits are low. The \LE \textit{chronogram} includes a cursor indicated by a red line (found just before the five second tick in Figure \ref{fig:06-07}) that can be placed anywhere along the diagram. The cursor sets the values of each signal in the area on the left edge of the diagram, so the cursor in Figure \ref{fig:06-07} is pointing to a spot where the \textit{clk} is low, \textit{Probe1} is at 0101, and so forth.

Follow the next steps to use the chronogram. Notes: the chronogram will only check subcircuits that are found on the  \lstinline[columns=fixed]|main| subcircuit. Therefore, in order to create a timing diagram all subcircuits need to be combined on \lstinline[columns=fixed]|main|. The labs completed in this manual have been designed to use the \lstinline[columns=fixed]|main| subcircuit as the human interface so the chronogram feature will work well with these circuits.

\begin{enumerate}
	\item In the \lstinline[columns=fixed]|main| subcircuit, add a ``sampling clock'' labeled \textit{sysclk} (this name is important, do not change it to something else). The sampling clock is only used by the \textit{chronogram} and will not show up in the timing diagram. It should not be connected to any other components and can be placed anywhere on \lstinline[columns=fixed]|main|. Set the properties for \textit{sysclk} to a 1 Tick high duration and a 1 Tick low duration (this is the default).
	\item Add a circuit master clock labeled \textit{clk}. This is the clock that will be used to trigger all components in the circuit. Set the properties for \textit{clk} to a 4 Tick high duration and a 4 Tick low duration.
	\item Set \textsc{Simulate -> Tick Frequency} to 4 Hertz. This will simulate a clock that ticks once per second, as in Figure \ref{fig:06-07}. While the actual tick frequency can be changed later to ``speed up'' the circuit, a one-second tick is useful for learning how the \textit{chronogram} works.
	\item Click \textsc{Simulate -> Chronogram} to set up the \textit{chronogram}. Figure \ref{fig:06-08} illustrates the initial setup screen for the \textit{chronogram}.

	\begin{figure}[H]
		\centering
		\includegraphics[width=\maxwidth{.95\linewidth}]{gfx/06-08}
		\caption{Set Up Chronogram}
		\label{fig:06-08}
	\end{figure}

	\item Click \textit{sysclk} in the left panel and then click \textit{Add >>} to add that signal to the \textit{chronogram}. The ``-2'' following the \textit{sysclk} name in the right panel indicates that it is a binary signal.\marginpar{NOTE: \textit{sysclk} must be added to the \textit{chronogram} or it will not sample the circuit; however, the \textit{sysclk} signal will not actually show up in the timing diagram.} It is probably best to add the \textit{sysclk} signal first so it is not overlooked.
	\item Click \textit{clk} in the left panel and then click \textit{Add >>} to add that signal to the \textit{chronogram}.
	\item Click \textit{Probe1} in the left panel and then click \textit{Add >>} to add that signal to the \textit{chronogram}.
	\item Click ``Enable time selection'' and chose \textit{clk} as the clock with a frequency of 1 Hertz.
	\item The \textit{chronogram} setup should look like Figure \ref{fig:06-09}.

	\begin{figure}[H]
		\centering
		\includegraphics[width=\maxwidth{.95\linewidth}]{gfx/06-09}
		\caption{Chronogram Ready}
		\label{fig:06-09}
	\end{figure}

	\item Click \textit{Start Chronogram} and the screen illustrated in Figure \ref{fig:06-10} pops up.

	\begin{figure}[H]
		\centering
		\includegraphics[width=\maxwidth{.95\linewidth}]{gfx/06-10}
		\caption{Chronogram Starting}
		\label{fig:06-10}
	\end{figure}

	\item Right-click on the \textit{Probe1} signal and set the format for binary. The format can be set for any radix but to match this lab binary numbers should be specified.
	\item Right-click on the \textit{Probe1} signal and enable \textit{Expand} to see all four signals that create \textit{Probe1}.
	\item At this point, the chronogram should look like Figure \ref{fig:06-11}.

	\begin{figure}[H]
		\centering
		\includegraphics[width=\maxwidth{.95\linewidth}]{gfx/06-11}
		\caption{Chronogram At Zero Time}
		\label{fig:06-11}
	\end{figure}

	\item The \textit{chronogram} has five buttons that control the simulator.

	\begin{figure}[H]
		\centering
		\includegraphics[width=\maxwidth{.95\linewidth}]{gfx/06-12}
		\caption{Chronogram Controls}
		\label{fig:06-12}
	\end{figure}

	\begin{itemize}
		\item Button One: Start/Stop the simulation.
		\item Button Two: Simulate one step.
		\item Button Three: Start/Stop \textit{sysclk}. This will ``turn on'' the chronogram and begin creating a timing diagram.
		\item Button Four: Step one \textit{sysclk} tick. This will tick the \textit{sysclk} one time. Since this lab set up the \textit{sysclk} for four ticks per second this button would need to be clicked four times to extend the timing diagram one second.
		\item Button Five: Step one \textit{clk} tick. This extends the timing diagram by one complete clock tick, or one second in this circuit.
	\end{itemize}

	\item Click button three to start the \textit{chronogram} and watch the timing diagram unfold. After a few seconds click that button a second time to stop the \textit{chronogram}.

	\item The following can be done once the timing diagram is complete.

	\begin{itemize}
		\item Click on the timing diagram to set the cursor (indicated by a red line). Once the cursor is set the values for each signal at the cursor's location are printed next to the signal's label on the left edge of the timing diagram.
		\item Hover the mouse over the timing diagram and roll the mouse wheel to zoom the timing diagram appearance.
		\item Click ``Export'' to save the timing diagram signal levels in a text file. That file can later be loaded to reevaluate the timing diagram.
		\item Click ``Export as image'' to save the timing diagram as a PNG file.
	\end{itemize}

\end{enumerate}

\section{Challenge}

This lab includes several different timers. Place all of them on a single subcircuit named \lstinline[columns=fixed]|Universal| that includes an output mux so a user can select the type of counter output desired. Place the \lstinline[columns=fixed]|Universal| circuit on \lstinline[columns=fixed]|main| and wire appropriate inputs and outputs.

Set up the chronogram for the ring counter and create a ten-second timing diagram for that counter. Save the timing diagram as a PNG image named ``RingCounter.''

\section{Deliverable}

To receive a grade for this lab, complete the Challenge. Be sure the standard identifying information is at the top left of the \lstinline{main} circuit:

\bigskip
% The minipage environment keeps the three lines together - no page break.
\begin{minipage}{\linewidth}
	\begin{verbatim}
	George Self
	Lab 06: Counters
	March 17, 2018
	\end{verbatim}
\end{minipage}
\bigskip

Save the circuit with this name: \textit{Lab07\_counter} and submit that along with \textit{RingCounter.PNG} for grading.


text:
\documentclass{article}
\usepackage[utf8]{inputenc}

\documentclass{article}
\usepackage[utf8]{inputenc}

\title{PS7_Gao}
\author{ningjing gao }
\date{March 2019}

\begin{document}

\maketitle

\section{Summary Table}
\begin{table}[!htbp] \centering
  \caption{}
  \label{}
\begin{tabular}{@{\extracolsep{5pt}}lccccccc}
\\[-1.8ex]\hline
\hline \\[-1.8ex]
Statistic & \multicolumn{1}{c}{N} & \multicolumn{1}{c}{Mean} & \multicolumn{1}{c}{St. Dev.} & \multicolumn{1}{c}{Min} & \multicolumn{1}{c}{Pctl(25)} & \multicolumn{1}{c}{Pctl(75)} & \multicolumn{1}{c}{Max} \\
\hline \\[-1.8ex]
logwage & 1,669 & 1.625 & 0.386 & 0.005 & 1.362 & 1.936 & 2.261 \\
hgc & 2,229 & 13.101 & 2.524 & 0 & 12 & 15 & 18 \\
tenure & 2,229 & 5.971 & 5.507 & 0.000 & 1.583 & 9.333 & 25.917 \\
age & 2,229 & 39.152 & 3.062 & 34 & 36 & 42 & 46 \\
\hline \\[-1.8ex]
\end{tabular}
\end{table}

Logwages are missing as 560 are missing out of 2229 observations in the table. the missing rate is 560/2229=0.2512. it should be MNAR. The variable is most likely to be MNAR.

\section{}
I prefer the Mice. the real β1 = 0.093. others are away from the 0.093 of the dependent variables.

\begin{table}[!htbp] \centering
  \caption{}
  \label{}
\begin{tabular}{@{\extracolsep{5pt}}lccc}
\\[-1.8ex]\hline
\hline \\[-1.8ex]
 & \multicolumn{3}{c}{\textit{Dependent variable:}} \\
\cline{2-4}
\\[-1.8ex] & \multicolumn{3}{c}{logwage} \\
\\[-1.8ex] & (1) & (2) & (3)\\
\hline \\[-1.8ex]
 hgc & 0.062$^{***}$ & 0.049$^{***}$ & 0.062$^{***}$ \\
  & (0.005) & (0.004) & (0.005) \\
  & & & \\
 collegenot college grad & 0.146$^{***}$ & 0.160$^{***}$ & 0.145$^{***}$ \\
  & (0.035) & (0.026) & (0.034) \\
  & & & \\
 tenure & 0.023$^{***}$ & 0.015$^{***}$ & 0.050$^{***}$ \\
  & (0.002) & (0.001) & (0.005) \\
  & & & \\
 I(tenure$\hat{\mkern6mu}$2) &  &  & $-$0.002$^{***}$ \\
  &  &  & (0.0003) \\
  & & & \\
 age & $-$0.001 & $-$0.001 & 0.0004 \\
  & (0.003) & (0.002) & (0.003) \\
  & & & \\
 marriedsingle & $-$0.024 & $-$0.029$^{**}$ & $-$0.022 \\
  & (0.018) & (0.014) & (0.018) \\
  & & & \\
 Constant & 0.639$^{***}$ & 0.833$^{***}$ & 0.534$^{***}$ \\
  & (0.146) & (0.115) & (0.146) \\
  & & & \\
\hline \\[-1.8ex]
Observations & 1,669 & 2,229 & 1,669 \\
R$^{2}$ & 0.195 & 0.132 & 0.208 \\
Adjusted R$^{2}$ & 0.192 & 0.130 & 0.206 \\
Residual Std. Error & 0.346 (df = 1663) & 0.311 (df = 2223) & 0.344 (df = 1662) \\
F Statistic & 80.508$^{***}$ (df = 5; 1663) & 67.496$^{***}$ (df = 5; 2223) & 72.917$^{***}$ (df = 6; 1662) \\
\hline
\hline \\[-1.8ex]
\textit{Note:}  & \multicolumn{3}{r}{$^{*}$p$<$0.1; $^{**}$p$<$0.05; $^{***}$p$<$0.01} \\
\end{tabular}
\end{table}

\section{Question 8}
i need to tell you honestly, i have not get any useful alaysis. Even I do not want to disappoint you. i am doing coronavirus alaysis. but it is hard to get what i want like a graph. I can general growth rate for presumptive case. and compare the different state data.
i swear, i will focus on the project furing spring break. hope i can do better after that time.

\end{document}