function [sigmoid_output, weighted_sum, binary_output] = sigmoid_with_sum(x1, x2, x3)
% 重みとバイアスを事前に設定(ここでは例として設定)
w1 = 0.5; % x1に対する重み
w2 = -0.3; % x2に対する重み
w3 = 0.8; % x3に対する重み
bias = 0.4; % バイアス項
% 重み付き入力の合計
weighted_sum = w1 * x1 + w2 * x2 + w3 * x3 + bias;
% シグモイド関数
sigmoid_output = 1 / (1 + exp(-weighted_sum)); % シグモイド関数の適用
% ビット生成出力: sigmoid_output が 0.5 より小さいなら 0、そうでなければ 1 を出力
if sigmoid_output < 0.5
binary_output = 0;
else
binary_output = 1;
end
end
More than 1 year has passed since last update.
Register as a new user and use Qiita more conveniently
- You get articles that match your needs
- You can efficiently read back useful information
- You can use dark theme

