網站首頁 編程語言 正文
前言:
牛奶凍曲線(blancmange curve),因在1901年由高木貞治所研究,又稱高木曲線。
在單位區間內,牛奶凍函數定義為:
分形曲線的輪廓會隨著階數的增多而填充細節,即對于下面的來說, 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已經很大了,精度足夠
b = np.sum(s(2**N*x)/2**N,1)
plt.plot(b)
plt.show()
如圖所示:
牛奶凍曲線是一種典型的分形曲線,即隨著區間的不斷縮小,其形狀幾乎不發生什么變化,例如更改自變量的范圍,令
x = np.arange(0.25,0.5,1e-3).reshape(-1,1)
最終得到的牛奶凍曲線在觀感上是沒什么區別的。
接下來繪制一下,當區間發生變化時,牛奶凍曲線的變化過程
繪圖代碼為:
from aniDraw import *
# 三角波函數
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已經很大了,精度足夠
b = np.sum(s(2**N*x)/2**N,1)
fig = plt.figure(figsize=(12,8))
ax = fig.add_subplot()
# n為坐標軸參數
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
相關推薦
- 2022-09-09 使用PyTorch實現隨機搜索策略_python
- 2023-05-16 Golang的鎖機制使用及說明_Golang
- 2022-05-05 Redis數據類型string和Hash詳解_Redis
- 2022-05-28 使用pandas計算環比和同比的方法實例_python
- 2022-03-16 C#中獲取二維數組的行數和列數以及多維數組各個維度的長度_C#教程
- 2022-02-27 解決 idea突然使用debug功能時項目啟動一半卡住沒反應也不報錯
- 2022-05-16 C#中關于序列化與反序列化的三種方法_C#教程
- 2023-05-23 docker-compose統一管理多個容器使用詳解_docker
- 最近更新
-
- window11 系統安裝 yarn
- 超詳細win安裝深度學習環境2025年最新版(
- Linux 中運行的top命令 怎么退出?
- MySQL 中decimal 的用法? 存儲小
- get 、set 、toString 方法的使
- @Resource和 @Autowired注解
- Java基礎操作-- 運算符,流程控制 Flo
- 1. Int 和Integer 的區別,Jav
- spring @retryable不生效的一種
- Spring Security之認證信息的處理
- Spring Security之認證過濾器
- Spring Security概述快速入門
- Spring Security之配置體系
- 【SpringBoot】SpringCache
- Spring Security之基于方法配置權
- redisson分布式鎖中waittime的設
- maven:解決release錯誤:Artif
- restTemplate使用總結
- Spring Security之安全異常處理
- MybatisPlus優雅實現加密?
- Spring ioc容器與Bean的生命周期。
- 【探索SpringCloud】服務發現-Nac
- Spring Security之基于HttpR
- Redis 底層數據結構-簡單動態字符串(SD
- arthas操作spring被代理目標對象命令
- Spring中的單例模式應用詳解
- 聊聊消息隊列,發送消息的4種方式
- bootspring第三方資源配置管理
- GIT同步修改后的遠程分支