# NDWasmOptimize

## Namespace

#### NDWasmOptimize

Description:

  - Namespace for Optimization functions using Go WASM.

Source:
  - ndwasm_optimize.js, line 28

### Methods

#### (static) linearRegression(x, y) → {Object}

Description:

  - Fits a simple linear regression model: Y = alpha + beta*X.

Source:
  - ndwasm_optimize.js, line 130

##### Parameters:

Name | Type | Description
--- | --- | ---
`x` | NDArray | The independent variable (1D NDArray of float64).
`y` | NDArray | The dependent variable (1D NDArray of float64).

##### Throws:

If WASM runtime is not loaded or inputs are invalid.

Type
  Error

##### Returns:

- An object containing the intercept (alpha) and slope (beta) of the fitted line.

Type
  Object

#### (static) linprog(c, G, h, A, b, bounds) → {Object}

Description:

  - Provides Optimization capabilities by wrapping Go WASM functions. minimize cᵀ * x s.t G * x <= h A * x = b lower <= x <= upper

Source:
  - ndwasm_optimize.js, line 48

##### Parameters:

Name | Type | Description
--- | --- | ---
`c` | NDArray | Coefficient vector for the objective function (1D NDArray of float64).
`G` | NDArray | null | Coefficient matrix for inequality constraints (2D NDArray of float64).
`h` | NDArray | null | Right-hand side vector for inequality constraints (1D NDArray of float64).
`A` | NDArray | null | Coefficient matrix for equality constraints (2D NDArray of float64).
`b` | NDArray | null | Right-hand side vector for equality constraints (1D NDArray of float64).
`bounds` | Array | Optional variable bounds as an array of [lower, upper] pairs. Use null for unbounded. [0, null] for all for default.

##### Throws:

If WASM runtime is not loaded or inputs are invalid.

Type
  Error

##### Returns:

- The optimization result.

Type
  Object

#### (static) minimize(func, x0, optionsopt) → {Object}

Description:

  - Finds the minimum of a scalar function of one or more variables using an L-BFGS optimizer.

Source:
  - ndwasm_optimize.js, line 159

##### Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---
`func` | function |  | The objective function to be minimized. It must take a 1D `Float64Array` `x` (current point) and return a single number (the function value at `x`).
`x0` | NDArray |  | The initial guess for the optimization (1D NDArray of float64).
`options` | Object | <optional> | Optional parameters. ###### Properties
Name | Type | Attributes | Description
--- | --- | --- | ---
`grad` | function | <optional> | The gradient of the objective function. Must take `x` (a 1D `Float64Array`) and write the result into the second argument `grad_out` (a 1D `Float64Array`). This function should not return a value.

##### Returns:

The optimization result.

Type
  Object