(Python3)- Use Turtle to make graphics- Random function to draw graphs

(Python3)- Use Turtle to make graphics- Random function to draw graphs

(Python3)- Use Turtle to make graphics- Random function to draw graphs

Kimo, which was often used in the past, and now Yahoo intellectuals, also stopped serving this year. I thought I would sort it out by myself, and I would also publish an English version for practicing English. If there is a grammatical error, please include more.

Random function to draw graphs:

from numpy import *
from random import random
import turtle
turtle.reset()
x = array([[.5],[.5]])
p = [0.85,0.92,0.99,1.00]
A1 = array([[.85, 0.04],
      [-0.04,.85]])
b1 = array([[0],[1.6]])
A2 = array([[0.20,-0.26],
      [0.23,0.22]])
b2 = array([[0],[1.6]])
A3 = array([[-0.15,0.28],
      [0.26,0.24]])
b3 = array([[0],[0.44]])
 
A4 = array([[0,0],
      [0,0.16]])
 
turtle.color("blue")
cnt = 1
while True:
  cnt += 1
  if cnt == 2000:
    break
  r = random()
  if r < p[0]:
    x = dot(A1 , x) + b1
  elif r < p[1]:
    x = dot(A2 , x) + b2
  elif r < p[2]:
    x = dot(A3 , x) + b3
  else:
    x = dot(A4 , x)
  #print x[1]
  turtle.up()
  turtle.goto(x[0][0] * 50,x[1][0] * 40 - 240)
  turtle.down()
  turtle.dot()

Disclaimer:

1. This image file is collected and reproduced from the Internet, and does not assume any technical and copyright issues.

2. If there is a download link for broadband testing and research purposes only, please delete it within 24 hours after downloading, and do not use it for commercial use.

3. If you have violated your legal rights, please write to us and we will delete it in time. We apologize for the inconvenience caused to you.


1 thought on “(Python3)- Use Turtle to make graphics- Random function to draw graphs”

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *