sigmoid_simd

Function sigmoid_simd 

Source
pub fn sigmoid_simd<F>(x: &ArrayView1<'_, F>) -> Array1<F>
where F: Float + SimdUnifiedOps,
Expand description

Compute the element-wise sigmoid (logistic) function of an array.

The sigmoid function is defined as: σ(x) = 1 / (1 + exp(-x))

This is critical for neural networks, logistic regression, and probability modeling. The implementation is numerically stable, avoiding overflow for large |x|.

§Properties

  • Range: (0, 1)
  • σ(0) = 0.5
  • σ(-x) = 1 - σ(x)
  • Derivative: σ’(x) = σ(x)(1 - σ(x))

§Examples

use scirs2_core::ndarray_ext::elementwise::sigmoid_simd;
use scirs2_core::ndarray::array;

let x = array![0.0f64, 1.0, -1.0];
let result = sigmoid_simd(&x.view());
assert!((result[0] - 0.5).abs() < 1e-10);  // sigmoid(0) = 0.5