mirror of
https://github.com/shizand/statapp.git
synced 2025-04-03 16:13:44 +03:00
refactor: создана функция generate_x_values
This commit is contained in:
parent
6da0487500
commit
6879747938
@ -1,5 +1,30 @@
|
|||||||
import numpy as np
|
import numpy as np
|
||||||
|
|
||||||
|
DIRECT_LINK = 0
|
||||||
|
INDIRECT_LINK = 1
|
||||||
|
|
||||||
|
def generate_x_values(mean, std, typeConnection, y):
|
||||||
|
yMean = np.mean(y)
|
||||||
|
values = []
|
||||||
|
for cur_y in y:
|
||||||
|
k = np.abs(cur_y / yMean)
|
||||||
|
if k > 1:
|
||||||
|
k = 2 - 1 / k
|
||||||
|
if typeConnection == INDIRECT_LINK:
|
||||||
|
k = 1 / k
|
||||||
|
if std == 0:
|
||||||
|
k = 1
|
||||||
|
|
||||||
|
x = np.random.normal(mean * (k ** 3), std * k)
|
||||||
|
values.append(x)
|
||||||
|
# if (x > gfw.mat and cur_y > yMat) or (x < gfw.mat and cur_y < yMat):
|
||||||
|
# dd = np.append(dd, 1)
|
||||||
|
# else:
|
||||||
|
# dd = np.append(dd, 0)
|
||||||
|
|
||||||
|
# x_arr = x_arr.reshape(len(x_arr), 1)
|
||||||
|
|
||||||
|
return np.array(values)
|
||||||
|
|
||||||
def variance_analysis(data):
|
def variance_analysis(data):
|
||||||
return np.array([
|
return np.array([
|
||||||
|
@ -3,6 +3,7 @@ from PySide2.QtCore import Slot, QLocale, QSize
|
|||||||
from PySide2.QtGui import QIcon
|
from PySide2.QtGui import QIcon
|
||||||
from PySide2.QtWidgets import QMainWindow, QMessageBox, QApplication
|
from PySide2.QtWidgets import QMainWindow, QMessageBox, QApplication
|
||||||
|
|
||||||
|
from statapp.calculations import generate_x_values
|
||||||
from statapp.generate_factor_window import GenerateFactorWindow, INDIRECT_LINK
|
from statapp.generate_factor_window import GenerateFactorWindow, INDIRECT_LINK
|
||||||
from statapp.models.input_values_model import InputValuesModel
|
from statapp.models.input_values_model import InputValuesModel
|
||||||
from statapp.generate_window import GenerateWindow
|
from statapp.generate_window import GenerateWindow
|
||||||
@ -81,36 +82,12 @@ class MainWindow(QMainWindow):
|
|||||||
def on_generateXaction_triggered(self):
|
def on_generateXaction_triggered(self):
|
||||||
gfw = GenerateFactorWindow()
|
gfw = GenerateFactorWindow()
|
||||||
|
|
||||||
# dd = np.array([])
|
|
||||||
|
|
||||||
if gfw.exec():
|
if gfw.exec():
|
||||||
y = self.model.getY()
|
|
||||||
yMat = np.mean(y)
|
|
||||||
|
|
||||||
x_arr = np.array([])
|
|
||||||
|
|
||||||
for cur_y in y:
|
|
||||||
k = np.abs(cur_y / yMat)
|
|
||||||
if k > 1:
|
|
||||||
k = 2 - 1 / k
|
|
||||||
if gfw.typeConnection == INDIRECT_LINK:
|
|
||||||
k = 1 / k
|
|
||||||
if gfw.deviation == 0:
|
|
||||||
k = 1
|
|
||||||
|
|
||||||
x = np.random.normal(gfw.mat * (k ** 3), gfw.deviation * k, size=1)
|
|
||||||
x_arr = np.append(x_arr, x)
|
|
||||||
# if (x > gfw.mat and cur_y > yMat) or (x < gfw.mat and cur_y < yMat):
|
|
||||||
# dd = np.append(dd, 1)
|
|
||||||
# else:
|
|
||||||
# dd = np.append(dd, 0)
|
|
||||||
|
|
||||||
data = self.model.getData()
|
data = self.model.getData()
|
||||||
|
y = self.model.getY()
|
||||||
|
x_arr = generate_x_values(gfw.mat, gfw.deviation, gfw.typeConnection, y)
|
||||||
x_arr = x_arr.reshape(len(x_arr), 1)
|
x_arr = x_arr.reshape(len(x_arr), 1)
|
||||||
# dd = dd.reshape(len(dd), 1)
|
|
||||||
data = np.concatenate((data, x_arr), axis=1)
|
data = np.concatenate((data, x_arr), axis=1)
|
||||||
# data = np.concatenate((data, dd), axis=1)
|
|
||||||
self.model.updateAllData(data)
|
self.model.updateAllData(data)
|
||||||
self.isDataChanged = True
|
self.isDataChanged = True
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user