time-to-botec

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

README.md (3730B)


      1 <!--
      2 
      3 @license Apache-2.0
      4 
      5 Copyright (c) 2018 The Stdlib Authors.
      6 
      7 Licensed under the Apache License, Version 2.0 (the "License");
      8 you may not use this file except in compliance with the License.
      9 You may obtain a copy of the License at
     10 
     11    http://www.apache.org/licenses/LICENSE-2.0
     12 
     13 Unless required by applicable law or agreed to in writing, software
     14 distributed under the License is distributed on an "AS IS" BASIS,
     15 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     16 See the License for the specific language governing permissions and
     17 limitations under the License.
     18 
     19 -->
     20 
     21 # Entropy
     22 
     23 > [Rayleigh][rayleigh-distribution] distribution [differential entropy][entropy].
     24 
     25 <!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
     26 
     27 <section class="intro">
     28 
     29 The [differential entropy][entropy] (in [nats][nats]) for a [Rayleigh][rayleigh-distribution] random variable is
     30 
     31 <!-- <equation class="equation" label="eq:rayleigh_entropy" align="center" raw="h\left( X \right) = 1+\ln \left({\frac {\sigma }{\sqrt {2}}}\right)+{\frac {\gamma }{2}}" alt="Differential entropy for a Rayleigh distribution."> -->
     32 
     33 <div class="equation" align="center" data-raw-text="h\left( X \right) = 1+\ln \left({\frac {\sigma }{\sqrt {2}}}\right)+{\frac {\gamma }{2}}" data-equation="eq:rayleigh_entropy">
     34     <img src="https://cdn.jsdelivr.net/gh/stdlib-js/stdlib@51534079fef45e990850102147e8945fb023d1d0/lib/node_modules/@stdlib/stats/base/dists/rayleigh/entropy/docs/img/equation_rayleigh_entropy.svg" alt="Differential entropy for a Rayleigh distribution.">
     35     <br>
     36 </div>
     37 
     38 <!-- </equation> -->
     39 
     40 where `σ > 0` is the scale parameter.
     41 
     42 </section>
     43 
     44 <!-- /.intro -->
     45 
     46 <!-- Package usage documentation. -->
     47 
     48 <section class="usage">
     49 
     50 ## Usage
     51 
     52 ```javascript
     53 var entropy = require( '@stdlib/stats/base/dists/rayleigh/entropy' );
     54 ```
     55 
     56 #### entropy( sigma )
     57 
     58 Returns the [differential entropy][entropy] of a [Rayleigh][rayleigh-distribution] distribution with scale `sigma` (in [nats][nats]).
     59 
     60 ```javascript
     61 var y = entropy( 9.0 );
     62 // returns ~3.139
     63 
     64 y = entropy( 3.5 );
     65 // returns ~2.195
     66 ```
     67 
     68 If provided `sigma < 0`, the function returns `NaN`.
     69 
     70 ```javascript
     71 var y = entropy( -1.0 );
     72 // returns NaN
     73 ```
     74 
     75 </section>
     76 
     77 <!-- /.usage -->
     78 
     79 <!-- Package usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
     80 
     81 <section class="notes">
     82 
     83 </section>
     84 
     85 <!-- /.notes -->
     86 
     87 <!-- Package usage examples. -->
     88 
     89 <section class="examples">
     90 
     91 ## Examples
     92 
     93 <!-- eslint no-undef: "error" -->
     94 
     95 ```javascript
     96 var randu = require( '@stdlib/random/base/randu' );
     97 var round = require( '@stdlib/math/base/special/round' );
     98 var entropy = require( '@stdlib/stats/base/dists/rayleigh/entropy' );
     99 
    100 var sigma;
    101 var y;
    102 var i;
    103 
    104 for ( i = 0; i < 10; i++ ) {
    105     sigma = randu() * 20.0;
    106     y = entropy( sigma );
    107     console.log( 'sigma: %d, h(X,v): %d', sigma.toFixed( 4 ), y.toFixed( 4 ) );
    108 }
    109 ```
    110 
    111 </section>
    112 
    113 <!-- /.examples -->
    114 
    115 <!-- Section to include cited references. If references are included, add a horizontal rule *before* the section. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
    116 
    117 <section class="references">
    118 
    119 </section>
    120 
    121 <!-- /.references -->
    122 
    123 <!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
    124 
    125 <section class="links">
    126 
    127 [rayleigh-distribution]: https://en.wikipedia.org/wiki/Student%27s_t-distribution
    128 
    129 [entropy]: https://en.wikipedia.org/wiki/Entropy_%28information_theory%29
    130 
    131 [nats]: https://en.wikipedia.org/wiki/Nat_%28unit%29
    132 
    133 </section>
    134 
    135 <!-- /.links -->