|
1185 | 1185 | [/codeblocks] |
1186 | 1186 | </description> |
1187 | 1187 | </method> |
| 1188 | + <method name="sigmoid"> |
| 1189 | + <return type="float" /> |
| 1190 | + <param index="0" name="x" type="float" /> |
| 1191 | + <description> |
| 1192 | + Computes the sigmoid for [param x], which maps the input value into the range (0, 1). |
| 1193 | + The sigmoid function is defined as: |
| 1194 | + [codeblock] |
| 1195 | + sigmoid(x) = 1 / (1 + exp(-x)) |
| 1196 | + [/codeblock] |
| 1197 | + This is the most accurate implementation of the sigmoid. |
| 1198 | + [codeblock] |
| 1199 | + var result = sigmoid(0.0) # result is 0.5 |
| 1200 | + var result = sigmoid(1.0) # result is approximately 0.7310 |
| 1201 | + var result = sigmoid(-1.0) # result is approximately 0.2689 |
| 1202 | + var result = sigmoid(5.0) # result is approximately 0.9933 |
| 1203 | + [/codeblock] |
| 1204 | + [b]Note:[/b] For faster but less accurate approximation, see [method sigmoid_approx]. |
| 1205 | + </description> |
| 1206 | + </method> |
| 1207 | + <method name="sigmoid_affine"> |
| 1208 | + <return type="float" /> |
| 1209 | + <param index="0" name="x" type="float" /> |
| 1210 | + <param index="1" name="amplitude" type="float" /> |
| 1211 | + <param index="2" name="y_translation" type="float" /> |
| 1212 | + <description> |
| 1213 | + Computes an affine-transformed sigmoid for [param x], which allows scaling by [param amplitude] and translation by [param y_translation]. |
| 1214 | + The affine sigmoid function is defined as: |
| 1215 | + [codeblock] |
| 1216 | + sigmoid_affine(x, amplitude, y_translation) = (amplitude / (1 + exp(-x))) + y_translation |
| 1217 | + [/codeblock] |
| 1218 | + This function modifies the standard sigmoid by introducing scaling and vertical translation. |
| 1219 | + [codeblock] |
| 1220 | + var result = sigmoid_affine(0.0, 1.0, 0.0) # result is 0.5 |
| 1221 | + var result = sigmoid_affine(1.0, 2.0, -1.0) # result is approximately 0.4621 |
| 1222 | + var result = sigmoid_affine(-1.0, 3.0, 2.0) # result is approximately 2.8068 |
| 1223 | + var result = sigmoid_affine(1.0, 2.0, 2.5) # result is approximately 3.9621 |
| 1224 | + [/codeblock] |
| 1225 | + [b]Note:[/b] This is a more accurate but computationally heavier version of the affine sigmoid. For faster approximations, see [method sigmoid_affine_approx]. |
| 1226 | + </description> |
| 1227 | + </method> |
| 1228 | + <method name="sigmoid_affine_approx"> |
| 1229 | + <return type="float" /> |
| 1230 | + <param index="0" name="x" type="float" /> |
| 1231 | + <param index="1" name="amplitude" type="float" /> |
| 1232 | + <param index="2" name="y_translation" type="float" /> |
| 1233 | + <description> |
| 1234 | + Computes an approximation of the affine-transformed sigmoid function for [param x], allowing scaling by [param amplitude] and translation by [param y_translation]. |
| 1235 | + The approximation function is defined as: |
| 1236 | + [codeblock] |
| 1237 | + affine_sigmoid_approx(x, amplitude, y_translation) = amplitude * (0.5 + (x / (4 + abs(x)))) + y_translation |
| 1238 | + [/codeblock] |
| 1239 | + This function approximates the affine sigmoid, offering faster computation at the cost of some precision. It is useful in performance-sensitive environments where both transformation and speed are needed. |
| 1240 | + [codeblock] |
| 1241 | + var result = sigmoid_affine_approx(0.0, 1.0, 0.0) # result is 0.5 |
| 1242 | + var result = sigmoid_affine_approx(2.0, 2.0, 1.0) # result is approximately 2.6667 |
| 1243 | + var result = sigmoid_affine_approx(-1.0, 3.0, 0.5) # result is 1.4 |
| 1244 | + var result = sigmoid_affine_approx(1.0, 2.0, 2.5) # result is 3.9 |
| 1245 | + [/codeblock] |
| 1246 | + </description> |
| 1247 | + </method> |
| 1248 | + <method name="sigmoid_approx"> |
| 1249 | + <return type="float" /> |
| 1250 | + <param index="0" name="x" type="float" /> |
| 1251 | + <description> |
| 1252 | + Computes an approximation of the sigmoid function for [param x], which maps the input value into the range (0, 1). |
| 1253 | + The approximation function is defined as: |
| 1254 | + [codeblock] |
| 1255 | + sigmoid_approx(x) = 0.5 + (x / (4 + abs(x))) |
| 1256 | + [/codeblock] |
| 1257 | + This function is faster than the standard [method sigmoid], especially useful in performance-sensitive environments where a balance between accuracy and speed is desired. |
| 1258 | + [codeblock] |
| 1259 | + var result = sigmoid_approx(0.0) # result is 0.5 |
| 1260 | + var result = sigmoid_approx(2.0) # result is approximately 0.8333 |
| 1261 | + var result = sigmoid_approx(-1.0) # result is 0.3 |
| 1262 | + var result = sigmoid_approx(5.0) # result is approximately 1.0555 |
| 1263 | + [/codeblock] |
| 1264 | + </description> |
| 1265 | + </method> |
1188 | 1266 | <method name="sign"> |
1189 | 1267 | <return type="Variant" /> |
1190 | 1268 | <param index="0" name="x" type="Variant" /> |
|
0 commit comments