亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

Python繪制牛奶凍曲線(xiàn)(高木曲線(xiàn))案例

 更新時(shí)間:2022年08月26日 17:00:21   作者:微小冷  
這篇文章主要介紹了Python繪制牛奶凍曲線(xiàn)(高木曲線(xiàn))案例,文章圍繞主題展開(kāi)詳細(xì)的內(nèi)容介紹,具有一定的參考價(jià)值,需要的小伙伴可以參考一下

前言:

牛奶凍曲線(xiàn)(blancmange curve),因在1901年由高木貞治所研究,又稱(chēng)高木曲線(xiàn)。

在單位區(qū)間內(nèi),牛奶凍函數(shù)定義為:

分形曲線(xiàn)的輪廓會(huì)隨著階數(shù)的增多而填充細(xì)節(jié),即對(duì)于下面的來(lái)說(shuō), N的變化會(huì)增添曲線(xiàn)的自相似特性

import numpy as np
import matplotlib.pyplot as plt
s = lambda x : np.min([x-np.floor(x), np.ceil(x)-x],0)
x = np.arange(1000).reshape(-1,1)/1000
N = np.arange(30).reshape(1,-1)      #2^N已經(jīng)很大了,精度足夠
b = np.sum(s(2**N*x)/2**N,1)
plt.plot(b)
plt.show()

如圖所示:

牛奶凍曲線(xiàn)是一種典型的分形曲線(xiàn),即隨著區(qū)間的不斷縮小,其形狀幾乎不發(fā)生什么變化,例如更改自變量的范圍,令

x = np.arange(0.25,0.5,1e-3).reshape(-1,1)

最終得到的牛奶凍曲線(xiàn)在觀(guān)感上是沒(méi)什么區(qū)別的。

接下來(lái)繪制一下,當(dāng)區(qū)間發(fā)生變化時(shí),牛奶凍曲線(xiàn)的變化過(guò)程

繪圖代碼為:

from aniDraw import *

# 三角波函數(shù)
s = lambda x : min(np.ceil(x)-x, x-np.floor(x))
s = lambda x : np.min([x-np.floor(x), np.ceil(x)-x],0)
x = np.arange(1000).reshape(-1,1)/1000
N = np.arange(30).reshape(1,-1)      #2^N已經(jīng)很大了,精度足夠
b = np.sum(s(2**N*x)/2**N,1)
fig = plt.figure(figsize=(12,8))
ax = fig.add_subplot()
# n為坐標(biāo)軸參數(shù)
def bcFunc(n):
    st = 1/3 - (1/3)**n
    ed = 1/3 + (2/3)**n
    x = np.linspace(st,ed,1000).reshape(-1,1)
    b = np.sum(s(2**N*x)/2**N,1)
    return (x,b)

line, = ax.plot([],[],lw=1)

def animate(n):
    x,y = bcFunc(n)
    line.set_data(x,y)
    plt.xlim(x[0],x[-1])
    plt.ylim(np.min(y),np.max(y))
    return line, 

Ns = np.arange(1,10,0.1)
ani = animation.FuncAnimation(fig, animate, Ns, 
    interval=125, blit=False)
plt.show()

到此這篇關(guān)于Python繪制牛奶凍曲線(xiàn)(高木曲線(xiàn))案例的文章就介紹到這了,更多相關(guān)Python 牛奶凍曲線(xiàn)內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

最新評(píng)論