Made normalization prettier

This commit is contained in:
Dominik Moritz Roth 2023-09-10 14:46:38 +02:00
parent 04e4364482
commit c68fd1635d

View File

@ -4,6 +4,7 @@ import colorednoise as cn
from perlin_noise import PerlinNoise
from torch.distributions import Normal
PI = 3.1415926535897932384626433
class Colored_Noise():
def __init__(self, known_shape=None, beta=1, num_samples=2**14, random_state=None):
@ -102,9 +103,9 @@ class Perlin_Noise():
self.known_shape = known_shape
self.scale = scale
self.octave = octave
self.magic = 3.141592653589 # Axis offset, should be (kinda) irrational
self.magic = PI # Axis offset, should be (kinda) irrational
# We want to genrate samples, that approx ~N(0,1)
self.normal_factor = 14/99
self.normal_factor = PI/20
self.clear_cache_every = 128
self.reset()
@ -112,7 +113,7 @@ class Perlin_Noise():
if shape == None:
shape = self.known_shape
self.index += 1
noise = [self.noise([self.index*self.scale, self.magic*(1+a)]) / self.normal_factor
noise = [self.noise([self.index*self.scale, self.magic+(2*a)]) / self.normal_factor
for a in range(shape[-1])]
if self.index % self.clear_cache_every == 0:
self.noise.cache = {}