[PYTHON] Wind-like dummy data generation in Markov process

background

Suppose you want to use time series data of wind power as a material. Here, we will create dummy data in Python 3 so that you do not have to worry about copyright. A simple random number looks like a fake, so we use a Markov process.

policy

Consider the following three states and determine the transition probability appropriately. In addition, the data for each state will be a uniform random number when the upper limit is changed.

Implementation

import numpy as np
import matplotlib.pyplot as plt

sts = [0, 1, 2] #Nothing,Low,High
coe = [0, 30, 80] #upper limit
M = np.array([[0.93, 0.07, 0.0], #Transition probability
              [0.45, 0.3, 0.25],
              [0.0, 0.07, 0.93]])
st = 0 #initial state
res = [] #result
np.random.seed(16)
for i in range(400):
    res.append(np.random.rand() * coe[st])
    st, = np.random.choice(sts, 1, p=M[st])
plt.bar(range(len(res)), res)

result

It became like that. ダウンロード (1).png

Recommended Posts

Wind-like dummy data generation in Markov process
Python dummy data generation (address edition)
Preprocessing in machine learning 1 Data analysis process
Data set generation
Sampling in imbalanced data