<jupyter_start><jupyter_text>Усреднение по 4<jupyter_code>import numpy as np
T = np.zeros((8,8))
for i in range(8):
    for j in range(8):
        if i == 0 or i == 7 or j == 7 or j == 0:
            T[i, j] = 100

def step(T):
    res = np.zeros(T.shape)
    dr = [[0,1], [1,0], [-1, 0], [0, -1]]
    for i in range(T.shape[0]):
        for j in range(T.shape[1]):
            for bias in dr:
                indy = bias[0] + i
                indx = bias[1] + j
                if 0<= indx<T.shape[1] and 0<=indy<T.shape[0]:
                    res[i,j] += T[indy, indx]/4
    return res

frames = [{'data': [{'z': T, 'type' : "heatmap"}]}]
for i in range(100):
    frames.append( {'data': [{'z': step(frames[i]['data'][0]['z']),'type': 'heatmap'}]})

trace = go.Heatmap(
    x=[0,1,2,3,4,5,6,7,8],
    y=[0,1,2,3,4,5,6,7,8],
    z=T,
    zmax=100,
    zmin=0
)
fig = go.Figure(data=[trace], frames=frames)
iplot(fig)<jupyter_output><empty_output><jupyter_text>НАЧАЛО-СЕРЕДИНА-КОНЕЦ<jupyter_code>fb = go.Heatmap(
    x=[0,1,2,3,4,5,6,7,8],
    y=[0,1,2,3,4,5,6,7,8],
    z=frames[0]['data'][0]['z'],
    zmax=100,
    zmin=0
)
fm = go.Heatmap(
    x=[0,1,2,3,4,5,6,7,8],
    y=[0,1,2,3,4,5,6,7,8],
    z=frames[25]['data'][0]['z'],
    zmax=100,
    zmin=0
)
fe = go.Heatmap(
    x=[0,1,2,3,4,5,6,7,8],
    y=[0,1,2,3,4,5,6,7,8],
    z=frames[-1]['data'][0]['z'],
    zmax=100,
    zmin=0
)
from plotly.subplots import make_subplots
import plotly.graph_objects as go

fig = make_subplots(rows=1, cols=3)

fig.add_trace(
    fb,
    row=1, col=1
)
fig.add_trace(
    fm,
    row=1, col=2
)
fig.add_trace(
    fe,
    row=1, col=3
)

fig.update_layout(height=600, width=800)
fig.show()<jupyter_output><empty_output><jupyter_text>Усреднение по 8<jupyter_code>import plotly.graph_objects as go
import numpy as np
from plotly.offline import download_plotlyjs, init_notebook_mode, plot, iplot
T = np.zeros((20,20))
for i in range(20):
    for j in range(20):
#         if i == 0 or i == 19 or j == 19 or j == 0:
        T[i, j] = 10000

def step(T):
    res = np.zeros(T.shape)
    dr = [[0,1], [1,0], [-1, 0], [0, -1]]
    dr_ad = [[1,1], [-1,-1], [-1, 1], [1, -1]]
    for i in range(T.shape[0]):
        for j in range(T.shape[1]):
            for bias in dr:
                indy = bias[0] + i
                indx = bias[1] + j
                if 0<= indx<T.shape[1] and 0<=indy<T.shape[0]:
                    res[i,j] += T[indy, indx]/5
            for bias in dr_ad:
                indy = bias[0] + i
                indx = bias[1] + j
                if 0<= indx<T.shape[1] and 0<=indy<T.shape[0]:
                    res[i,j] += T[indy, indx]/20
    return res

frames = [{'data': [{'z': T, 'type' : "heatmap"}]}]
for i in range(30):
    frames.append( {'data': [{'z': step(frames[i]['data'][0]['z']),'type': 'heatmap'}]})

trace = go.Heatmap(
    x=[0,1,2,3,4,5,6,7,8],
    y=[0,1,2,3,4,5,6,7,8],
    z=T,
    zmax=100,
    zmin=0
)
fig = go.Figure(data=[trace], frames=frames)
iplot(fig)<jupyter_output><empty_output><jupyter_text>НАЧАЛО-СЕРЕДИНА-КОНЕЦ<jupyter_code>fb = go.Heatmap(
    x=[0,1,2,3,4,5,6,7,8],
    y=[0,1,2,3,4,5,6,7,8],
    z=frames[0]['data'][0]['z'],
    zmax=100,
    zmin=0
)
fm = go.Heatmap(
    x=[0,1,2,3,4,5,6,7,8],
    y=[0,1,2,3,4,5,6,7,8],
    z=frames[25]['data'][0]['z'],
    zmax=100,
    zmin=0
)
fe = go.Heatmap(
    x=[0,1,2,3,4,5,6,7,8],
    y=[0,1,2,3,4,5,6,7,8],
    z=frames[-1]['data'][0]['z'],
    zmax=100,
    zmin=0
)
from plotly.subplots import make_subplots
import plotly.graph_objects as go

fig = make_subplots(rows=1, cols=3)

fig.add_trace(
    fb,
    row=1, col=1
)
fig.add_trace(
    fm,
    row=1, col=2
)
fig.add_trace(
    fe,
    row=1, col=3
)

fig.update_layout(height=600, width=800)
fig.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.22283755274261605, 'fraction_numerical': 0.08095991561181434, 'mean_word_length': 2.766633565044687, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '606008', 'license': 'MIT', 'n_tokens_mistral': 1894, 'n_tokens_neox': 1797, 'n_words': 319, 'path': '10.ipynb', 'repo_name': 'mansasha21/phys-math-modeling', 'size': '3792'}