Made normalization prettier
This commit is contained in:
parent
04e4364482
commit
c68fd1635d
@ -4,6 +4,7 @@ import colorednoise as cn
|
|||||||
from perlin_noise import PerlinNoise
|
from perlin_noise import PerlinNoise
|
||||||
from torch.distributions import Normal
|
from torch.distributions import Normal
|
||||||
|
|
||||||
|
PI = 3.1415926535897932384626433
|
||||||
|
|
||||||
class Colored_Noise():
|
class Colored_Noise():
|
||||||
def __init__(self, known_shape=None, beta=1, num_samples=2**14, random_state=None):
|
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.known_shape = known_shape
|
||||||
self.scale = scale
|
self.scale = scale
|
||||||
self.octave = octave
|
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)
|
# 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.clear_cache_every = 128
|
||||||
self.reset()
|
self.reset()
|
||||||
|
|
||||||
@ -112,7 +113,7 @@ class Perlin_Noise():
|
|||||||
if shape == None:
|
if shape == None:
|
||||||
shape = self.known_shape
|
shape = self.known_shape
|
||||||
self.index += 1
|
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])]
|
for a in range(shape[-1])]
|
||||||
if self.index % self.clear_cache_every == 0:
|
if self.index % self.clear_cache_every == 0:
|
||||||
self.noise.cache = {}
|
self.noise.cache = {}
|
||||||
|
Loading…
Reference in New Issue
Block a user