import numpy as np
[docs]
def generate_green_hydrogen_price_series(start_price=5.0, length=100, trend=-0.02, volatility=0.1):
"""
Generates a time series for green hydrogen prices with a downward trend and random fluctuations.
Parameters:
- start_price (float): Initial price of green hydrogen per kg.
- length (int): Number of time steps (e.g., days or months) for the time series.
- trend (float): Long-term trend (negative for decreasing prices).
- volatility (float): Magnitude of random fluctuations around the trend.
Returns:
- pd.DataFrame: A DataFrame containing the generated time series.
"""
# Initialize the price series
prices = [start_price]
# Generate the price series
for i in range(1, length):
# Calculate the new price based on the previous one, adding a trend and some random noise
new_price = prices[-1] + trend + np.random.normal(0, volatility)
# Ensure the price doesn't go below a certain threshold (e.g., zero)
new_price = max(new_price, 0.1)
prices.append(new_price)
return prices