python - Fitting 3d sigmoid to data -


i have data relating multivariant sigmoidal function: x y r(x,y)

x           y         r(x,y)  0.468848997 0.487599    0 0.468848997 0.512929    0 0.468848997 0.538259    0 0.468848997 0.563589    0 0.468848997 0.588918    0 0.468848997 0.614248    0 0.468848997 0.639578    0 0.468848997 0.664908    0.000216774 0.468848997 0.690238    0.0235043 0.468848997 0.715568    0.319768 0.468848997 0.740897    0.855861 0.468848997 0.766227    0.994637 0.468848997 0.791557    0.999524 0.468848997 0.816887    0.99954 0.468848997 0.842217    0.99958 0.468848997 0.867547    0.999572 0.468848997 0.892876    0.999634 0.468848997 0.918206    0.999566 0.468848997 0.943536    0.999656 0.468848997 0.968866    0.999637 0.468848997 0.994196    0.999685 .           .            . .           .            . .           .            . 0.481520591 0.487599    0 0.481520591 0.512929    0 0.481520591 0.538259    0 0.481520591 0.563589    0 0.481520591 0.588918    0 0.481520591 0.614248    0 0.481520591 0.639578    1.09e-06 0.481520591 0.664908    0.000755042 0.481520591 0.690238    0.0498893 0.481520591 0.715568    0.449531 0.481520591 0.740897    0.919786 0.481520591 0.766227    0.998182 0.481520591 0.791557    0.99954 

i wonder if there sigmoid function can use fit 3d data. came across answer for 2d data i'm not able extend problem.

i think in guess auxiliary function this:

f(x,y)=1\(1+e^(-a0 x+a1))*( 1\(1+e^(-a2 y+a3)) a0=a2 , a1=a3 

i don't know how proceed here thought.

i grateful insight or suggestion i'm helpless now.

in case, output variable, denote r_xy, appears within range [0 1]. in case, multivariate sigmoid can simulated follows:

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 noise x_noise = x_grid + randn(size(x_grid)); y_noise = y_grid + randn(size(y_grid));  % randomly define b parameter of sigmoid, number of % variables , offset. b = randn(1, 3) + 1;  % calculate sample data r_xy = (1 ./ (1+exp(-b * ([ones(size(x_noise)); x_noise; y_noise]))));  % plot data figure scatter3(x_grid, y_grid, r_xy) 

this can seen appear sigmoid in 3 dimensions:

enter image description here

this can thought of generalised linear model, binomial distribution , logit link function.

matlab can fit generalised linear models using fitglm function follows:

% fit model model = fitglm([x_grid; y_grid]', r_xy', 'linear', 'distribution', 'binomial', 'link', 'logit');  % plot model on scatter plot hold on; mesh(x, y, reshape(predict(model, [x_grid; y_grid]'), numel(x), numel(y)), 'linewidth', 0.5) 

resulting in following fit:

enter image description here

the parameters of model can read model variable.


Comments

Popular posts from this blog

angularjs - Showing an empty as first option in select tag -

qt - Change color of QGraphicsView rubber band -

c++ - Print Preview in Qt -