Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/matlab/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 将3d sigmoid拟合到数据_Python_Matlab_Curve Fitting_Data Fitting_Interpolation - Fatal编程技术网

Python 将3d sigmoid拟合到数据

Python 将3d sigmoid拟合到数据,python,matlab,curve-fitting,data-fitting,interpolation,Python,Matlab,Curve Fitting,Data Fitting,Interpolation,我有关于多变量S形函数的数据:x y r(x,y) 我想知道是否有一个sigmoid函数,我可以用来适应我的3D数据。 我找到了这个答案,但我无法扩展它来解决我的问题 我想在我看来,辅助函数可能是这样的: f(x,y)=1\(1+e^(-A0 x+A1))*( 1\(1+e^(-A2 y+A3)) with A0=A2 and A1=A3 我不知道如何从这里开始思考 如果有任何见解或建议,我将不胜感激,因为我现在完全无能为力。在您的情况下,输出变量(我将表示为r_xy)似乎在[0 1]范围内。

我有关于多变量S形函数的数据:x y r(x,y)

我想知道是否有一个sigmoid函数,我可以用来适应我的3D数据。 我找到了这个答案,但我无法扩展它来解决我的问题

我想在我看来,辅助函数可能是这样的:

f(x,y)=1\(1+e^(-A0 x+A1))*( 1\(1+e^(-A2 y+A3)) with A0=A2 and A1=A3
我不知道如何从这里开始思考


如果有任何见解或建议,我将不胜感激,因为我现在完全无能为力。

在您的情况下,输出变量(我将表示为
r_xy
)似乎在[0 1]范围内。在这种情况下,可以如下模拟多变量乙状结肠:

x = -10:0.5:10;
y = -10:0.5:10;

x_grid = reshape(repmat(x, numel(x), 1), 1, numel(x) ^ 2);
y_grid = repmat(y, 1, numel(y));

% Add some noise
x_noise = x_grid + randn(size(x_grid));
y_noise = y_grid + randn(size(y_grid));

% Randomly define the B parameter of the sigmoid, with the number of
% variables and an offset.
B = randn(1, 3) + 1;

% Calculate the sample data
r_xy = (1 ./ (1+exp(-B * ([ones(size(x_noise)); x_noise; y_noise]))));

% Plot the data
figure
scatter3(x_grid, y_grid, r_xy)
% Fit the model
model = fitglm([x_grid; y_grid]', r_xy', 'linear', 'Distribution', 'binomial', 'Link', 'logit');

% Plot the model on the scatter plot
hold on;
mesh(x, y, reshape(predict(model, [x_grid; y_grid]'), numel(x), numel(y)), 'LineWidth', 0.5)
在三维空间中,这看起来像一个乙状结肠:

这可以看作是一个广义线性模型,具有二项分布和logit链接函数

Matlab可以使用
fitglm
函数拟合广义线性模型,如下所示:

x = -10:0.5:10;
y = -10:0.5:10;

x_grid = reshape(repmat(x, numel(x), 1), 1, numel(x) ^ 2);
y_grid = repmat(y, 1, numel(y));

% Add some noise
x_noise = x_grid + randn(size(x_grid));
y_noise = y_grid + randn(size(y_grid));

% Randomly define the B parameter of the sigmoid, with the number of
% variables and an offset.
B = randn(1, 3) + 1;

% Calculate the sample data
r_xy = (1 ./ (1+exp(-B * ([ones(size(x_noise)); x_noise; y_noise]))));

% Plot the data
figure
scatter3(x_grid, y_grid, r_xy)
% Fit the model
model = fitglm([x_grid; y_grid]', r_xy', 'linear', 'Distribution', 'binomial', 'Link', 'logit');

% Plot the model on the scatter plot
hold on;
mesh(x, y, reshape(predict(model, [x_grid; y_grid]'), numel(x), numel(y)), 'LineWidth', 0.5)
导致以下匹配:


模型的参数可以从
模型
变量中读取。

能否发布一些3D数据,请。。。请把方程适当地缩进。有关格式设置的帮助,请参阅。感谢您的回复。我添加了一些数据。