time-to-botec

Benchmark sampling in different programming languages
Log | Files | Refs | README

index.js (1950B)


      1 /**
      2 * @license Apache-2.0
      3 *
      4 * Copyright (c) 2018 The Stdlib Authors.
      5 *
      6 * Licensed under the Apache License, Version 2.0 (the "License");
      7 * you may not use this file except in compliance with the License.
      8 * You may obtain a copy of the License at
      9 *
     10 *    http://www.apache.org/licenses/LICENSE-2.0
     11 *
     12 * Unless required by applicable law or agreed to in writing, software
     13 * distributed under the License is distributed on an "AS IS" BASIS,
     14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     15 * See the License for the specific language governing permissions and
     16 * limitations under the License.
     17 */
     18 
     19 'use strict';
     20 
     21 /**
     22 * Compute an unbiased sample covariance matrix incrementally.
     23 *
     24 * @module @stdlib/stats/incr/covmat
     25 *
     26 * @example
     27 * var Float64Array = require( '@stdlib/array/float64' );
     28 * var ndarray = require( '@stdlib/ndarray/ctor' );
     29 * var incrcovmat = require( '@stdlib/stats/incr/covmat' );
     30 *
     31 * // Create an output covariance matrix:
     32 * var buffer = new Float64Array( 4 );
     33 * var shape = [ 2, 2 ];
     34 * var strides = [ 2, 1 ];
     35 * var offset = 0;
     36 * var order = 'row-major';
     37 *
     38 * var cov = ndarray( 'float64', buffer, shape, strides, offset, order );
     39 *
     40 * // Create a covariance matrix accumulator:
     41 * var accumulator = incrcovmat( cov );
     42 *
     43 * var out = accumulator();
     44 * // returns null
     45 *
     46 * // Create a data vector:
     47 * buffer = new Float64Array( 2 );
     48 * shape = [ 2 ];
     49 * strides = [ 1 ];
     50 *
     51 * var vec = ndarray( 'float64', buffer, shape, strides, offset, order );
     52 *
     53 * // Provide data to the accumulator:
     54 * vec.set( 0, 2.0 );
     55 * vec.set( 1, 1.0 );
     56 *
     57 * out = accumulator( vec );
     58 * // returns <ndarray>
     59 *
     60 * var bool = ( out === cov );
     61 * // returns true
     62 *
     63 * vec.set( 0, -5.0 );
     64 * vec.set( 1, 3.14 );
     65 *
     66 * out = accumulator( vec );
     67 * // returns <ndarray>
     68 *
     69 * // Retrieve the covariance matrix:
     70 * out = accumulator();
     71 * // returns <ndarray>
     72 */
     73 
     74 // MODULES //
     75 
     76 var incrcovmat = require( './main.js' );
     77 
     78 
     79 // EXPORTS //
     80 
     81 module.exports = incrcovmat;