AI - 4th Unit
AI - 4th Unit
Reasoning with uncertainty and time is the ability to draw logical conclusions and
make decisions based on incomplete, inconsistent, or uncertain information that
may change over time. For example, a self-driving car needs to reason about the
traffic situation, the road conditions, the weather, and the intentions of other
drivers and pedestrians, all of which are uncertain and may vary over time.
Reasoning with uncertainty and time is essential for AI systems that operate in
real-world environments.
One of the main challenges for reasoning with uncertainty and time is how to
represent and manipulate probabilistic and temporal knowledge in a
computationally efficient and scalable way. There are many different formalisms
and languages for expressing uncertainty and time, such as Bayesian networks,
Markov decision processes, temporal logic, and fuzzy logic, but each of them has
its own advantages and limitations
2. Moving Average Models (MA): Moving average models use past forecast
errors in a regression-like model. It assumes that the output variable depends
linearly on the current and various past values of the stochastic (randomly
determined) terms.
5. Hidden Markov Models (HMMs): These are statistical models where the
system being modeled is assumed to be a Markov process with unobserved
(hidden) states. HMMs are particularly known for their application in temporal
pattern recognition such as speech, handwriting, gesture recognition, part-of-
speech tagging, and bioinformatics.
6. Dynamic Bayesian Networks (DBNs): These are models for time series data
that generalize Bayesian networks to dynamic processes. Unlike simple
Bayesian networks, DBNs can represent conditional dependencies between
different time points.
7. State Space Models and Kalman Filters: These are recursive models that
estimate the linear dynamic system’s state from a series of noisy
measurements. They are widely used in engineering, especially for signal
processing and control systems.
Mathematical Representation:
P(X_t∣O_1,O_2,…,O_t)
Where,
X_t is the state at time t and O_1,O_2,…,O_t are the observations up to time t.
1. Initialization: Start with an initial probability distribution for the first state.
2. Recursion: Update the state probability using the transition probabilities and
the new observation.
Common Filtering Methods
1. Kalman Filter: An efficient recursive filter for linear Gaussian state-space
models that minimizes the mean squared error.
2. Extended Kalman Filter (EKF): A nonlinear extension of the Kalman filter
that linearizes the state and observation models around the current estimate.
3. Particle Filter: A sequential Monte Carlo method that approximates the
posterior distribution of the hidden states using weighted samples, suitable for
nonlinear and non-Gaussian models.
2. Smoothing
Smoothing, or hindsight analysis, involves computing the state probabilities
given all the observations in the sequence, past and future relative to the state
being estimated. It provides a more accurate estimate than filtering as it
incorporates more information.
Mathematical Representation:
3. Prediction
Prediction involves forecasting future observations based on current state
estimates and model parameters.
Mathematical Representation:
P(X_{t+k}| O_1, O_2, …, O_t)
where,
k is the number of steps ahead from the current time t.
Types of Prediction
1. One-Step-Ahead Prediction: Forecasts the next observation based on the
current state estimate.
2. Multi-Step Prediction: Extends the forecasting horizon by predicting multiple
future observations, often using iterative methods or directly modeling the
multi-step dependencies.
4. Most Likely Sequence (Viterbi Algorithm)
The Viterbi Algorithm is used to find the most likely sequence of states that leads
to a set of observations. This is particularly useful in scenarios like speech
recognition, where the goal is to decode the spoken words into text.
Mathematical Representation:
1. Finance: Time series models forecast stock prices, assess risk, and manage
portfolios. Kalman filters and ARIMA models are widely used for trading
strategies and economic forecasting.
2. Healthcare: Temporal models monitor patient health, predict disease
progression, and optimize treatment plans. Hidden Markov Models (HMMs)
and state-space models track patient states over time.
3. Climate Science: State-space models and RNNs predict weather patterns,
monitor climate change, and assess environmental impacts.
4. Manufacturing: Temporal models detect anomalies, predict machine failures,
and optimize maintenance schedules. Particle filters and Kalman filters are
employed for real-time monitoring and control.
The hidden Markov Model (HMM) is a statistical model that is used to describe
the probabilistic relationship between a sequence of observations and a sequence
of hidden states.
An HMM consists of two types of variables: hidden states and observations.
The hidden states are the underlying variables that generate the observed
data, but they are not directly observable.
The observations are the variables that are measured and observed.
The relationship between the hidden states and the observations is modeled using
a probability distribution. The Hidden Markov Model (HMM) is the relationship
between the hidden states and the observations using two sets of probabilities: the
transition probabilities and the emission probabilities.
Moveordering
------------------
Move ordering in AI, particularly in the context of games like chess or checkers,
refers to the strategy of deciding the sequence in which potential moves( a possible
move that a player can make ) are evaluated during a search algorithm. Proper
move ordering can significantly enhance the efficiency of search algorithms,
especially those that use techniques like minimax or alpha-beta pruning.
- This is a search algorithm that seeks to minimize the number of nodes evaluated
in the minimax algorithm. Good move ordering can help achieve more effective
pruning. If the best moves are considered first, the algorithm can eliminate
branches that are clearly worse more quickly.
3. Heuristic Evaluation:
4. Historical Data:
5. Tactical Motifs:
- Recognizing common tactical patterns (e.g., forks, pins) can influence move
ordering. Moves that create immediate tactical threats may be prioritized over
others.
6. Transposition Tables:
7. Dynamic Adjustments:
Kalmanfilter
--------------
The Kalman filter is a powerful mathematical tool used in AI and control systems
for estimating the state of a dynamic system from a series of noisy measurements.
It is particularly valuable in applications where precise measurements are
difficult to obtain, such as robotics, navigation, and time-series analysis.
1. State Estimation:
- The Kalman filter maintains an estimate of the state of a system (e.g., position,
velocity) and updates this estimate based on new measurements.
2. Predict-Update Cycle:
- Prediction Step: The filter predicts the next state of the system based on the
current state and a model of the system dynamics. This includes estimating the
uncertainty associated with the prediction.
- Update Step: When a new measurement is received, the filter updates the
predicted state using the measurement, weighing the prediction and the
measurement based on their uncertainties.
3. Noise Handling:
- The Kalman filter assumes that both the system dynamics and the
measurements contain Gaussian noise. It models this uncertainty and provides
optimal estimates by minimizing the mean of the squared errors.
4. Linear Systems:
- The standard Kalman filter is designed for linear systems. However, there are
extensions for non-linear systems, such as the Extended Kalman Filter (EKF) and
the Unscented Kalman Filter (UKF).
Applications in AI:
1. Robotics:
- Used for estimating the position and orientation of robots, particularly in tasks
like simultaneous localization and mapping (SLAM).
2. Navigation:
- Commonly applied in GPS and inertial navigation systems to filter out noise
from sensor readings and provide accurate location data.
3. Computer Vision:
4. Time-Series Analysis:
- Utilized in forecasting and smoothing time-series data by filtering out noise and
making predictions based on observed trends.
5. Finance:
- Used for estimating hidden states in financial models, such as trends in stock
prices.
Advantages
Limitations
- Assumptions: The standard Kalman filter assumes linear dynamics and Gaussian
noise, which may not hold in all applications.
1. Handling Complex and Strategic Games: MCTS excels in games with large
search spaces, complex dynamics, and strategic decision-making. It has been
successfully applied to games like Go, chess, shogi, poker, and many others,
achieving remarkable performance that often surpasses human expertise.
MCTS can effectively explore and evaluate different moves or actions, leading
to strong gameplay and decision-making in such games.
7. Dom
8. ain Independence: MCTS is relatively domain-independent. It does not
require domain-specific knowledge or heuristics to operate. Although domain-
specific enhancements can be made to improve performance, the basic MCTS
algorithm can be applied to a wide range of problem domains without
significant modifications.
Monte Carlo Tree Search (MCTS) is a heuristic search algorithm( Heuristic search is a method
for finding the best solution to a problem by searching a solution space using a set of rules or
method to move from one possible solution to a
nother.) used primarily for making decisions in game-playing AI. It combines the principles of
random sampling and tree search to evaluate the potential outcomes of moves in a game.
Selection: In this process, the MCTS algorithm traverses the current tree from
the root node using a specific strategy. The strategy uses an evaluation
function to optimally select nodes with the highest estimated value. MCTS
uses the Upper Confidence Bound (UCB) formula. It balances the exploration-
exploitation trade-off. During tree traversal, a node is selected based on some
parameters that return the maximum value.
where;
Si = value of a node i
xi = empirical mean of a node i
C = a constant
When traversing a tree during the selection process, the child node that returns
the greatest value from the above equation will be one that will get selected.
During traversal, once a child node is found which is also a leaf node, the
MCTS jumps into the expansion step.
Expansion: In this process, a new child node is added to the tree to that node
which was optimally reached during the selection process.
Backpropagation: After determining the value of the newly added node, the
remaining tree must be updated. So, the backpropagation process is
performed, where it backpropagates from the new node to the root node.
During the process, the number of simulation stored in each node is
incremented.
The above steps can be visually understood by the diagram given below:
Pseudo-code for Monte Carlo Tree search:
Python3
def monte_carlo_tree_search(root):
leaf = traverse(root)
simulation_result = rollout(leaf)
backpropagate(leaf, simulation_result)
return best_child(root)
def traverse(node):
while fully_expanded(node):
node = best_uct(node)
def rollout(node):
while non_terminal(node):
node = rollout_policy(node)
return result(node)
# function for randomly selecting a child node
def rollout_policy(node):
return pick_random(node.children)
if is_root(node) return
backpropagate(node.parent)
def best_child(node):
1. As the tree growth becomes rapid after a few iterations, it requires a huge
amount of memory.
2. There is a bit of a reliability issue with Monte Carlo Tree Search. In certain
scenarios, there might be a single branch or path, that might lead to loss
against the opposition when implemented for those turn-based games.
3. MCTS algorithm needs a huge number of iterations to be able to effectively
decide the most efficient path. So, there is a bit of a speed issue there.
4. Heuristic Design: MCTS relies on heuristics to guide the search and prioritize
actions or nodes. Designing effective and domain-specific heuristics can be
challenging, and the quality of the heuristics directly affects the algorithm’s
performance
5. Computation and Memory Requirements: MCTS can be computationally
intensive, especially in games with long horizons or complex dynamics. The
algorithm’s performance depends on the available computational resources,
and in resource-constrained environments, it may not be feasible to run MCTS
with a sufficient number of simulations