スタートアップから大手まで。
調達・受発注をAIで標準化。

相見積比較も進捗管理もAIが下支え。取引先は招待で完全無料。

14日間 無料で試すクレカ不要・1分/招待企業は完全無料

投稿日:2025年3月12日

Basics of particle filters and practical time series data analysis using Python

Understanding Particle Filters

💡 こうした調達・受発注の属人化、newji なら「ひとつの画面」で解決。見積依頼から発注・進捗・承認までAIが下支えします。
14日間 無料で試す →

Particle filters are a powerful tool in the field of statistics and signal processing.
They are used to estimate states in dynamic systems.
These filters are also known as Sequential Monte Carlo methods.
The main idea is to use a set of particles, or random samples, to represent the distribution of possible states.

Each particle represents a possible state of the system.
The particles are updated over time using a process called “resampling.”
This involves discarding some particles and duplicating others based on their weights.
The weights of the particles are updated based on how well they match the actual observed data.

How Particle Filters Work

Particle filters work by following a simple algorithm:
1. **Initialization:** Start with an initial set of particles.
2. **Prediction:** Use the model to predict the next state for each particle.
3. **Updating Weights:** Compare these predictions with actual observations.
Update the weights of the particles based on how closely they match the observation.
4. **Resampling:** Select particles based on their weights.
Particles with higher weights are more likely to be selected.
Create a new set of particles by duplicating higher weight particles and discarding lower weight ones.
5. **Repeat:** Continue the process for each time step as new observations become available.

Applications of Particle Filters

Particle filters have wide-ranging applications across various fields.

Robotics and Navigation

In robotics, particle filters are used for localization and navigation.
A robot uses sensor data to maintain a probability distribution of its location.
The filter updates its location estimates as it receives new sensor data.
This helps the robot navigate accurately in an uncertain environment.

Finance and Economics

Financial analysts use particle filters to track and predict stock prices and economic indicators.
The filters help in modeling the latent variables underlying observed financial data.
Economists apply particle filters to understand business cycles and forecast economic growth.

Signal Processing

In signal processing, particle filters are used in applications such as radar, sonar, and communications.
They help in noise reduction and in extracting relevant features from noisy signals.

Implementing Particle Filters Using Python

Python is a popular language for data analysis and statistics.
There are several libraries available that make the implementation of particle filters straightforward.
One of such libraries is NumPy, which supports numerical operations.
Let’s go through a basic implementation of a particle filter using Python.

Step-by-Step Implementation

1. **Initialize Particles:**

“`python
import numpy as np

num_particles = 1000
particles = np.random.uniform(low=0.0, high=1.0, size=(num_particles,))
weights = np.ones(num_particles) / num_particles
“`

2. **Prediction Step:**

“`python
def predict(particles, std_dev):
particles += np.random.normal(0, std_dev, size=particles.shape)
return particles
“`

3. **Update Weights:**

“`python
def update_weights(particles, measurement, std_dev):
weights = np.exp(-((particles – measurement) ** 2) / (2 * std_dev ** 2))
weights += 1.e-300 # To avoid division by zero
weights /= sum(weights)
return weights
“`

4. **Resampling Step:**

“`python
def resample(particles, weights):
indices = np.random.choice(len(particles), size=len(particles), replace=True, p=weights)
particles = particles[indices]
weights.fill(1.0 / len(weights))
return particles, weights
“`

5. **Particle Filter Function:**

“`python
def particle_filter(measurements, num_particles=1000, std_dev=0.1):
particles = np.random.uniform(low=0.0, high=1.0, size=(num_particles,))
weights = np.ones(num_particles) / num_particles

for measurement in measurements:
particles = predict(particles, std_dev)
weights = update_weights(particles, measurement, std_dev)
particles, weights = resample(particles, weights)

return particles, weights
“`

Using the Function

You can use the `particle_filter` function with a list of measurements to predict the state.
Adjust the `num_particles` and `std_dev` parameters according to your system and noise level.

Conclusion

Particle filters provide a robust framework for dealing with uncertainty in dynamic systems.
They are highly flexible and can be adapted to a wide range of problems.
By using Python, you can easily implement these filters to analyze time series data effectively.
With practice, you’ll be able to leverage the power of particle filters to solve complex problems in your field of interest.

WHITE PAPER

この記事の理解を深める
無料ホワイトペーパーをプレゼント

製造業の現場で使える実務資料(PDF)を無料でお届けします。"こんな資料が届きます" ↓ 下のボタンからどうぞ。

PRODUCT — 製造業向け 調達・受発注クラウド

この記事の課題、
newji で解決しませんか?

newji は、製造業の調達・受発注に特化したクラウド/AIエージェント。見積依頼・発注書作成・進捗管理・承認をひとつの画面に集約し、AIが比較と異常検知を担当。最後の「GO」だけ人が押す仕組みです。

  • 見積〜発注〜納期を一元管理。催促・転記のムダをゼロに
  • AIが相見積もり比較と異常検知。あなたは判断だけに集中
  • 取引先は「招待」で完全無料。自社コストだけで取引先ごとデジタル化

※ 取引先から招待された企業様は完全無料でご利用いただけます

調達購買アウトソーシング

調達購買アウトソーシング

調達が回らない、手が足りない。
その悩みを、外部リソースで“今すぐ解消“しませんか。
サプライヤー調査から見積・納期・品質管理まで一括支援します。

対応範囲を確認する

OEM/ODM 生産委託

アイデアはある。作れる工場が見つからない。
試作1個から量産まで、加工条件に合わせて最適提案します。
短納期・高精度案件もご相談ください。

加工可否を相談する

NEWJI DX

現場のExcel・紙・属人化を、止めずに改善。業務効率化・自動化・AI化まで一気通貫で設計します。
まずは課題整理からお任せください。

DXプランを見る

受発注AIエージェント

受発注が増えるほど、入力・確認・催促が重くなる。
受発注管理を“仕組み化“して、ミスと工数を削減しませんか。
見積・発注・納期まで一元管理できます。

機能を確認する

You cannot copy content of this page