92 lines
2.3 KiB
Python
92 lines
2.3 KiB
Python
|
# -*- coding: utf-8 -*-
|
||
|
"""
|
||
|
Created on Tue Aug 30 14:25:12 2022
|
||
|
|
||
|
@author: timof
|
||
|
"""
|
||
|
|
||
|
import sys
|
||
|
import os
|
||
|
import json
|
||
|
|
||
|
from plot import qtplot
|
||
|
from phi import MIP,calc_mips,smartMIP
|
||
|
|
||
|
import math as m
|
||
|
import numpy as np
|
||
|
from datetime import datetime
|
||
|
|
||
|
vect = np.vectorize
|
||
|
|
||
|
@vect
|
||
|
def log2(x):
|
||
|
try:
|
||
|
return m.log2(x)
|
||
|
except ValueError:
|
||
|
if x==0:
|
||
|
return float(0)
|
||
|
else:
|
||
|
raise
|
||
|
|
||
|
def new_folder(path):
|
||
|
if not os.path.exists(path):
|
||
|
os.makedirs(path)
|
||
|
return path
|
||
|
|
||
|
path = '/cloud/Public/_data/neuropercolation/1lay/steps=1000100/'
|
||
|
suffix = ''
|
||
|
|
||
|
chi = chr(967)
|
||
|
vareps = chr(949)
|
||
|
varphi = chr(981)
|
||
|
|
||
|
vals = [[],[]]
|
||
|
|
||
|
runsteps = 1000100
|
||
|
|
||
|
eps_space = np.linspace(0.005, 0.5, 100)
|
||
|
eps_space = eps_space[1::2]
|
||
|
|
||
|
dims = list(range(3,10))#+[16,49]
|
||
|
|
||
|
mode='density'
|
||
|
ma=[]
|
||
|
s=[]
|
||
|
k=[]
|
||
|
mk=[]
|
||
|
lastkurt=None
|
||
|
phinum=10000
|
||
|
PHIS=[]
|
||
|
for dim in dims[:1]:
|
||
|
dimpath = new_folder(path + f'dim={dim:02}/')
|
||
|
for epsilon in eps_space:
|
||
|
try:
|
||
|
with open(dimpath+f"eps={round(epsilon,3):.3f}_phi_{phinum}.txt", 'r', encoding='utf-8') as f:
|
||
|
phis=json.load(f)
|
||
|
PHIS.append(np.average(phis))
|
||
|
print(f'Loaded and Done eps={epsilon:.3f} with dim={dim} at {datetime.now()}')
|
||
|
except:
|
||
|
with open(dimpath+f"eps={round(epsilon,3):.3f}_states.txt", 'r', encoding='utf-8') as f:
|
||
|
states = np.array(json.load(f)[100:phinum+100])
|
||
|
|
||
|
phis = [smartMIP(dim,state.translate(str.maketrans('','','.-=')),epsilon)[1] for state in states]
|
||
|
with open(dimpath+f"eps={round(epsilon,3):.3f}_phi_{phinum}.txt", 'w', encoding='utf-8') as f:
|
||
|
json.dump(phis, f, indent=1)
|
||
|
PHIS.append(np.average(phis))
|
||
|
print(f'Generated and Done eps={epsilon:.3f} with dim={dim} at {datetime.now()}')
|
||
|
#%%
|
||
|
qtplot(f"Average phi for different noise parameters",
|
||
|
[eps_space],
|
||
|
[PHIS],
|
||
|
[''],
|
||
|
colors='w',
|
||
|
x_tag = f'noise level {vareps}',
|
||
|
y_tag = f'effect integration {varphi}',
|
||
|
export=False,
|
||
|
path=dimpath+"evolution/",
|
||
|
filename=f'eps={round(epsilon,3):.3f}_evolution.png',
|
||
|
close=False)
|
||
|
|
||
|
mode = 'density'
|
||
|
#%%
|