LoginSignup
2
2

More than 5 years have passed since last update.

人工データ集合(正弦関数)

Posted at
sine_function_data.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import numpy as np
import matplotlib.pyplot as plt

N = 10
SCALE = 0.3

x = np.linspace(0, 1, N)
t = np.sin(2 * np.pi * x) + np.random.normal(0, SCALE, x.size)
plt.plot(x, t, 'bo')

curve_x = np.linspace(0, 1, 100)
curve_t = np.sin(2 * np.pi * curve_x)
plt.plot(curve_x, curve_t, 'g-')

plt.xlabel('$x$')
plt.ylabel('$t$')
plt.axis([-0.05, 1.05, -1.5, 1.5])
plt.savefig('sine_function_data.png')
2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2