網(wǎng)站首頁(yè) 編程語(yǔ)言 正文
前言:
牛奶凍曲線(blancmange curve),因在1901年由高木貞治所研究,又稱高木曲線。
在單位區(qū)間內(nèi),牛奶凍函數(shù)定義為:
分形曲線的輪廓會(huì)隨著階數(shù)的增多而填充細(xì)節(jié),即對(duì)于下面的來說, N的變化會(huì)增添曲線的自相似特性
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()
如圖所示:
牛奶凍曲線是一種典型的分形曲線,即隨著區(qū)間的不斷縮小,其形狀幾乎不發(fā)生什么變化,例如更改自變量的范圍,令
x = np.arange(0.25,0.5,1e-3).reshape(-1,1)
最終得到的牛奶凍曲線在觀感上是沒什么區(qū)別的。
接下來繪制一下,當(dāng)區(qū)間發(fā)生變化時(shí),牛奶凍曲線的變化過程
繪圖代碼為:
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()
原文鏈接:https://blog.csdn.net/m0_37816922/article/details/126517261
相關(guān)推薦
- 2024-07-22 @Resource和 @Autowired注解的區(qū)別
- 2022-09-18 Go實(shí)現(xiàn)文件分片上傳_Golang
- 2022-10-28 React?this.setState方法使用原理分析介紹_React
- 2022-05-25 Entity?Framework?Core使用控制臺(tái)程序生成數(shù)據(jù)庫(kù)表_實(shí)用技巧
- 2022-12-04 詳解Golang中g(shù)cache模塊的基本使用_Golang
- 2022-08-22 C++實(shí)現(xiàn)字符串切割的兩種方法_C 語(yǔ)言
- 2022-09-17 Golang中的包及包管理工具go?mod詳解_Golang
- 2024-07-15 Spring中的單例模式應(yīng)用詳解
- 最近更新
-
- window11 系統(tǒng)安裝 yarn
- 超詳細(xì)win安裝深度學(xué)習(xí)環(huán)境2025年最新版(
- Linux 中運(yùn)行的top命令 怎么退出?
- MySQL 中decimal 的用法? 存儲(chǔ)小
- get 、set 、toString 方法的使
- @Resource和 @Autowired注解
- Java基礎(chǔ)操作-- 運(yùn)算符,流程控制 Flo
- 1. Int 和Integer 的區(qū)別,Jav
- spring @retryable不生效的一種
- Spring Security之認(rèn)證信息的處理
- Spring Security之認(rèn)證過濾器
- Spring Security概述快速入門
- Spring Security之配置體系
- 【SpringBoot】SpringCache
- Spring Security之基于方法配置權(quán)
- redisson分布式鎖中waittime的設(shè)
- maven:解決release錯(cuò)誤:Artif
- restTemplate使用總結(jié)
- Spring Security之安全異常處理
- MybatisPlus優(yōu)雅實(shí)現(xiàn)加密?
- Spring ioc容器與Bean的生命周期。
- 【探索SpringCloud】服務(wù)發(fā)現(xiàn)-Nac
- Spring Security之基于HttpR
- Redis 底層數(shù)據(jù)結(jié)構(gòu)-簡(jiǎn)單動(dòng)態(tài)字符串(SD
- arthas操作spring被代理目標(biāo)對(duì)象命令
- Spring中的單例模式應(yīng)用詳解
- 聊聊消息隊(duì)列,發(fā)送消息的4種方式
- bootspring第三方資源配置管理
- GIT同步修改后的遠(yuǎn)程分支