Skip to content

Commit

Permalink
[Term Entry] Data Science Data Distributions: Exponential Distribution
Browse files Browse the repository at this point in the history
* Created the entry

* Update content/data-science/concepts/data-distributions/terms/exponential-distribution/exponential-distribution.md

Co-authored-by: Aditya Raj <41803857+raditya1117@users.noreply.github.com>

* Minor changes

---------
  • Loading branch information
dakshdeepHERE authored Mar 3, 2025
1 parent 6c0bd6c commit 21b0012
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
---
Title: 'Exponential Distribution'
Description: 'The exponential distribution is a probability distribution often used to model the time between events in a Poisson process.'
Subjects:
- 'Data Science'
- 'Statistics'
Tags:
- 'Data Distributions'
- 'Exponential'
CatalogContent:
- 'learn-data-science'
- 'paths/data-science'
---

The **exponential distribution** models the time between independent events that occur at a fixed average rate. It is frequently used in reliability analysis, queuing theory, and survival analysis. The distribution is defined by a single parameter, the rate λ which determines how quickly events occur.

The exponential distribution formula is given by:

$$f(x|λ) = λ e^{-λ x}$$

- `λ`: The rate parameter that represents the number of events per unit time.
- `x`: A random variable that represents the time between events.

## Example

The example below demonstrates how to generate random samples from an exponential distribution using NumPy and visualize the results with a histogram using Matplotlib:

```python
import numpy as np
import matplotlib.pyplot as plt

# Set the rate parameter (lambda)
rate = 1.5 # Events per unit time

# Generate 1,000 random samples from the exponential distribution
data = np.random.exponential(scale=1/rate, size=1000)

# Plot the histogram of the generated data
plt.hist(data, bins=30, density=True, alpha=0.6, color='teal', edgecolor='black')
plt.title(f"Exponential Distribution (rate = {rate})")
plt.xlabel("Time Between Events")
plt.ylabel("Density")
plt.show()
```

The above code produces the following output:

![The output for the above example](https://raw.githubusercontent.com/Codecademy/docs/main/media/exponential-distribution.png)
1 change: 1 addition & 0 deletions documentation/tags.md
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,7 @@ Visibility
VR
Vue
Web3
Exponential
WebRTC
Weight & Bias
While
Expand Down
Binary file added media/exponential-distribution.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 21b0012

Please sign in to comment.