Stats Lab Report
Stats Lab Report
Q1
A random permutation is a random ordering of a set of objects, that is, a permutation-valued random vari-
able. The use of random permutations is often fundamental to fields that use randomized algorithms such
as coding theory, cryptography, and simulation
Fixed points
The probability distribution of the number of fixed points in a uniformly distributed random permutation ap-
proaches a Poisson distribution with expected value 1 as n grows. In particular, it is an elegant application of
the inclusion–exclusion principle to show that the probability that there are no fixed points approaches 1/e.
When n is big enough, the probability distribution of fixed points is almost the Poisson distribution with ex-
pected value 1. The first n moments of this distribution are exactly those of the Poisson distribution.
Randomness testing
As with all random processes, the quality of the resulting distribution of an implementation of a randomized
algorithm such as the Knuth shuffle (i.e., how close it is to the desired uniform distribution) depends on the
quality of the underlying source of randomness, such as a pseudorandom number generator. There are many
possible randomness tests for random permutations, such as some of the Diehard tests. A typical example of
such a test is to take some permutation statistic for which the distribution is known and test whether the dis-
tribution of this statistic on a set of randomly generated permutations closely approximates the true distribu-
tion.
The provided code generates a random permutation of the first n natural numbers and then plots it. Let's
break down the process:
The code starts by defining the value of n, which represents the number of natural numbers to be permuted.
It generates a random permutation of the first n natural numbers using the sample(.) function in R. This func-
tion randomly shuffles the elements of a vector without replacement, effectively generating a random permu-
tation.
Randomness Testing and Statistics on Random Permutations:
Random permutations are widely used in various fields, including coding theory, cryptography, and simula-
tion. They serve as a fundamental element in randomized algorithms.
Statistics on random permutations include the distribution of fixed points. The probability distribution of the
number of fixed points in a uniformly distributed random permutation approaches a Poisson distribution with
an expected value of 1 as n grows. This concept is often demonstrated using principles like the inclusion-ex-
clusion principle.
Quality testing of randomness is essential in ensuring the reliability of algorithms that utilize random permu-
tations. This involves testing the distribution of permutation statistics against known distributions, typically
using randomness tests such as the Diehard tests.
Implementation:
The code implements a permutation algorithm known as the Fisher-Yates shuffle or Knuth shuffle. It itera-
tively shuffles the permutation by randomly selecting an index and swapping elements, following specific
rules until all elements are shuffled.
Plotting:
After generating the random permutation, the code plots it using the plot(.) function. It creates a scatter plot
where the x-axis represents the indices of the permutation, and the y-axis represents the values of the permu-
tation. Additional parameters like main, xlab, and ylab are used to provide titles and labels for the plot.
Q2
Poisson Process
The Poisson process is one of the most widely-used counting processes. It is usually used in scenarios where
we are counting the occurrences of certain events that appear to happen at a certain rate, but completely at
random (without a certain structure). For example, suppose that from historical data, we know that earth-
quakes occur in a certain area with a rate of 22 per month. Other than this information, the timings of earth-
quakes seem to be completely random. Thus, we conclude that the Poisson process might be a good model
for earthquakes. In practice, the Poisson process or its extensions have been used to model [24]
• the number of car accidents at a site or in an area;
• the location of users in a wireless network;
• the requests for individual documents on a web server;
• the outbreak of wars;
• photons landing on a photodiode.
Code Implementation:
The provided R code includes two functions: generate_poisson_process and histogram_poisson_process. The
generate_poisson_process function generates a Stationary Poisson Process given a rate parameter (lambda)
and a maximum time (T). The process involves generating random times between events using the inverse
transform sampling method. The resulting event times are then utilized by the histogram_poisson_process
function to create a histogram, providing a visual representation of the Poisson Process.
Algorithm Overview:
Event Occurrence Modeling: Poisson processes are commonly used in various fields, including telecom-
munications, biology, and finance, to model the occurrence of events such as phone calls, radioactive decay,
or financial transactions.
Concept of Rate (λ): The rate parameter (λ) determines the average number of events occurring per unit
time. A higher λ implies a more frequent occurrence of events.
Stationarity: In a Stationary Poisson Process, the rate of event occurrences remains constant over time. This
makes it a valuable tool for modeling scenarios where events happen independently and at a consistent rate.
Visualization: The histogram generated from the Poisson Process provides a visual representation of the dis-
tribution of event times, helping analysts and researchers gain insights into the temporal patterns of the mod-
eled process.
Conclusion:
Generating Stationary Poisson Processes in R offers a powerful tool for simulating and understanding the oc-
currence of events over time. Whether used for research, simulations, or modeling real-world phenomena,
the Stationary Poisson Process provides a versatile framework with applications in a wide range of domains.
The combination of R's statistical capabilities and the discussed algorithm empowers users to explore and an-
alyze temporal event patterns efficiently.
Q3
A non-stationary Poisson process is a stochastic process where the rate of events occurring over time is not
constant but varies according to some function of time. In a Poisson process, events occur randomly over
time, but in a non-stationary Poisson process, the rate at which events occur changes over time, making it a
more flexible and realistic model for many real-world phenomena.
1. Time-Varying Intensity Function: The key characteristic of a non-stationary Poisson process is its time-
varying intensity function. This function, denoted as λ(t), specifies the rate at which events occur at time t.
λ(t) can be any function of time, allowing the process to capture changes in event rates over time.
2. Random Event Occurrence: Like in a standard Poisson process, events occur randomly in a non-station-
ary Poisson process. However, the likelihood of events occurring at different times varies according to the
intensity function λ(t). Higher values of λ(t) indicate a higher event rate, while lower values indicate a lower
event rate.
3. Independent Increments: Similar to stationary Poisson processes, non-stationary Poisson processes ex-
hibit the property of independent increments. This means that the number of events occurring in disjoint time
intervals is independent of each other.
Practical Applications:
1. Financial Modeling: Non-stationary Poisson processes are used in finance to model the arrival of market
events such as trades, order placements, or price changes. The intensity function may vary based on factors
such as market volatility, trading volume, or time of day.
3. Healthcare Systems: Non-stationary Poisson processes are employed in healthcare to model the arrival of
patients at hospitals, clinics, or emergency departments. The intensity function may vary based on factors
such as disease outbreaks, seasonal variations, or public health campaigns.
4. Traffic Engineering: Traffic flow on roads and highways can be modeled using non-stationary Poisson
processes. The intensity function may depend on factors such as time of day, weather conditions, or special
events, allowing for better traffic management and infrastructure planning.
5. Manufacturing Processes: In manufacturing, non-stationary Poisson processes can model the occurrence
of machine breakdowns, defects, or maintenance events on a production line. The intensity function may be
influenced by factors such as machine usage, production schedules, or environmental conditions.
Algorithm Overview:
Both algorithms are used to simulate the arrival times of events in a non-stationary Poisson process. The
process is characterized by a time-varying intensity function λ(t), where λ(t) represents the rate of events oc-
curring at time t.
Algorithm 1:
Similar to Algorithm 1 but keeps track of the interval J and increments it as time progresses beyond its
boundaries.
Generates random numbers to determine the time of the next event and updates time t accordingly.
If the next event time exceeds T, stop.
Otherwise, generate another random number to determine if an event occurs at time t based on the intensity
function.
If the time t exceeds the current interval J, increment J and continue.