thesffs/data.py

63 lines
1.3 KiB
Python
Raw Permalink Normal View History

2021-12-30 09:23:31 +01:00
import numpy as np
#obvious solution
#(nicer version of:)
#[[ 0.95911082 0.27747321 0.0558132 ]
# [-0.14426784 0.64893967 -0.74703693]]
#(maybe)
#[[ 0.97660659 0.20377678 0.06866321]
# [-0.09744323 0.70403038 -0.70345294]]
#saw one (but did not copy) that looked like
#[[ 1.0, 0.0, 0.0],
# [ 0.0, 0.7,-0.7]]
#but there is a secondary solution
#[[ 0.34055104 0.35392664 -0.87106881]
# [-0.64936382 0.75853476 0.0543288 ]]
#x,x**2+y+z,z
#translated into
#a=x+x**2+y+z-2.5*z
#b=x**2+y+z-(13/15)*x
#find a(b)
#a-const*b=const
#x-(13/15)*x
#+(x**2+y+z)-(x**2+y+z)
#-2.5*z
#=2x/15-2.5z
#not great, but...
#tertiary solution
#[[ 0.86908816 0.3797459 -0.31698411]
# [-0.49261647 0.60629139 -0.62429142]]
#which looks like a mirrored version of
#[[ 0.93229881 -0.19299482 0.30589537]
# [ 0.3481528 0.70805987 -0.61436217]]
#which of course makes some sense
def data(n=1000):
"""
Generate 3d data, where a and b have a relation, but x=x(a,b), y=y(a,b), z=z(a,b) will be returned
"""
a=np.random.uniform(-1.0,1.0,n)
b=a**2+np.random.uniform(-0.2,0.2,n)
c=np.random.uniform(-1.0,1.0,n)
x=a
y=b+c
z=c
return x,y,z
if __name__ == '__main__':
x,y,z=data()
from plt import plt
plt.plot(x,y,'.')
plt.show()
#print(x,y,z)