
In real-world scenarios like drone delivery, robotics navigation, or sensor error modeling, we often deal with uncertainty. Even if a system is designed to land at a target point, small errors due to wind, GPS inaccuracies, or mechanical drift can cause deviations.
To quantify these uncertainties and make predictions, we use probability distributions. Specifically, a joint probability density function (PDF) helps us answer questions like:
- ā āWhat is the chance that a package lands within 1 meter of the intended drop point?ā
- ā āHow likely is it for a drone to land near the edge of the target zone?ā
A PDF allows us to:
- Model how likely different outcomes are,
- Compute probabilities for regions (not just single points),
- Simulate random drops consistent with observed patterns,
- Optimize systems based on risk and reliability.
š Real-World Example: Drone Delivery Landing Zone
We are modeling the landing positions of packages dropped by a drone over a rectangular area of size 20m Ć 10m:
- Let xā[0,20] meters (length of the rectangle)
- Let yā[0,10] meters (width of the rectangle)
The center of the rectangle is at (x0ā,y0ā)=(10,5). Based on empirical data, we observe that:
- Landings are more concentrated around the center,
- Less likely near the edges ā suggesting a Gaussian-like spread.
However, since the drone cannot drop outside the rectangle, we truncate the Gaussian distribution to fit inside this domain.
š Mathematical Model of the PDF
We define a bivariate truncated Gaussian-like joint PDF:

Where:
- Ļxā=Ļyā=3 m (standard deviation in both directions),
- C is the normalization constant such that:

This ensures that the total probability over the rectangle equals 1, which is a requirement for any valid PDF.
š§® Why Normalize?
Normalization is essential because raw Gaussian functions integrate to 1 over the entire plane , not just our finite rectangle. Since our drone cannot drop outside the defined rectangle, we must truncate the function and rescale it so that the integral over our domain equals 1.
Without normalization, the probabilities would not sum to 1, and we couldnāt interpret them correctly.
š§Ŗ Python Code Implementation
Now letās implement this in Python, using numpy, scipy, and matplotlib.
ā Requirements:
pip install numpy scipy matplotlib
š§āš» Full Python Code
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
import numpy as np from scipy.integrate import dblquad import matplotlib.pyplot as plt from matplotlib.colors import LogNorm  # === Step 1: Define Parameters === # x_min, x_max = 0, 20 y_min, y_max = 0, 10 x_center, y_center = 10, 5 sigma_x, sigma_y = 3.0, 3.0  # Define the unnormalized PDF def pdf_unnorm(x, y):     return np.exp(-((x - x_center)**2 / (2 * sigma_x**2) +                     (y - y_center)**2 / (2 * sigma_y**2)))  # === Step 2: Compute Normalization Constant C === # # Use double integration over the rectangle [x_min, x_max] à [y_min, y_max] integral_value, integral_error = dblquad(pdf_unnorm, y_min, y_max, lambda _: x_min, lambda _: x_max) C = 1.0 / integral_value  print(f"Normalization constant C = {C:.6f}")  # Define the full normalized PDF def pdf(x, y):     if x < x_min or x > x_max or y < y_min or y > y_max:         return 0.0     else:         return C * pdf_unnorm(x, y)  # Vectorize it for plotting pdf_vec = np.vectorize(pdf)  # === Step 3: Create a Grid for Visualization === # X = np.linspace(x_min, x_max, 200) Y = np.linspace(y_min, y_max, 200) X_grid, Y_grid = np.meshgrid(X, Y) Z = pdf_vec(X_grid, Y_grid)  # === Step 4: Plot the PDF as a Heatmap === # plt.figure(figsize=(10, 5)) plt.pcolormesh(X_grid, Y_grid, Z, cmap='viridis', shading='auto', norm=LogNorm()) plt.colorbar(label="Probability Density") plt.title("Normalized PDF of Package Drop Locations") plt.xlabel("x (meters)") plt.ylabel("y (meters)") plt.grid(True, linestyle='--', alpha=0.5) plt.tight_layout() plt.show()  # === Step 5: Compute Probability Within a Subregion === # # Area of interest: square from (8,3) to (12,7) prob, prob_err = dblquad(pdf, 3, 7, lambda _: 8, lambda _: 12)  print(f"\nProbability of landing within [8 ⤠x ⤠12] and [3 ⤠y ⤠7]: {prob:.6f}") |
š Output Interpretation
š¹ Normalization Constant C
This ensures that the total volume under the PDF surface equals 1. Without this, we wouldnāt be able to interpret values as probabilities.
š¹ PDF Heatmap
- Shows higher probability near the center (10,5)
- Lower near the edges
- Visualizes where most drops are expected

š¹ Probability Calculation
Example output after running the code is:
Normalization constant C = 0.019570
Probability of landing within [8 ⤠x ⤠12] and [3 ⤠y ⤠7]: 0.271169
This means thereās about a 27.11% chance that a package lands within the central 4Ć4 square.
šÆ Applications of This PDF
Once you have the PDF, you can:
- š Simulate many drone drops and analyze landing statistics.
- š Compute expected values: Where does the drone typically land?
- š”ļø Risk analysis: What is the probability of landing too close to an obstacle?
- š§ Optimization: Adjust drone path or sensor calibration to reduce landing variance.
š§© Summary
| Concept | Explanation |
|---|---|
| Describes likelihood of landing at each point in the rectangle | |
| Truncation | Ensures no probability outside the defined landing zone |
| Normalization | Makes sure total probability = 1 |
| Integration | Used to compute probabilities for subregions |
| Simulation | Enables testing and planning under uncertainty |
I hope this tutorial will create a good foundation for you. If you want tutorials on anotherĀ GIS topic or you have any queries, please send an mail atĀ contact@spatial-dev.guru.
