|
| 1 | +<!-- |
| 2 | +
|
| 3 | +@license Apache-2.0 |
| 4 | +
|
| 5 | +Copyright (c) 2024 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 | +# Normalized Hermite Polynomial |
| 22 | + |
| 23 | +> Evaluate a normalized [Hermite polynomial][hermite-polynomial] using single-precision floating-point arithmetic. |
| 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 normalized (aka "probabilist") [Hermite polynomials][hermite-polynomial] are given by |
| 30 | + |
| 31 | +<!-- <equation class="equation" label="eq:normalized_hermite_polynomials" align="center" raw="He_{n}(x)=(-1)^{n} e^{\frac{x^2}{2}} \frac{\mathrm d^{n}}{\mathrm d x^{n}} e^{-\frac{x^2}{2}}" alt="Equation for normalized Hermite polynomials."> --> |
| 32 | + |
| 33 | +```math |
| 34 | +He_{n}(x)=(-1)^{n} e^{\frac{x^2}{2}} \frac{\mathrm d^{n}}{\mathrm d x^{n}} e^{-\frac{x^2}{2}} |
| 35 | +``` |
| 36 | + |
| 37 | +<!-- <div class="equation" align="center" data-raw-text="He_{n}(x)=(-1)^{n} e^{\frac{x^2}{2}} \frac{\mathrm{d}^{n}}{\mathrm{d}x^n} e^{-\frac{x^2}{2}}" data-equation="eq:normalized_hermite_polynomials"> |
| 38 | + <img src="https://cdn.jsdelivr.net/gh/stdlib-js/stdlib@bea0101eb61892f160eec8d97dc79188fd937523/lib/node_modules/@stdlib/math/base/tools/normhermitepoly/docs/img/equation_normalized_hermite_polynomials.svg" alt="Equation for normalized Hermite polynomials."> |
| 39 | + <br> |
| 40 | +</div> --> |
| 41 | + |
| 42 | +<!-- </equation> --> |
| 43 | + |
| 44 | +</section> |
| 45 | + |
| 46 | +<!-- /.intro --> |
| 47 | + |
| 48 | +<!-- Package usage documentation. --> |
| 49 | + |
| 50 | +<section class="usage"> |
| 51 | + |
| 52 | +## Usage |
| 53 | + |
| 54 | +```javascript |
| 55 | +var normhermitepolyf = require( '@stdlib/math/base/tools/normhermitepolyf' ); |
| 56 | +``` |
| 57 | + |
| 58 | +#### normhermitepolyf( n, x ) |
| 59 | + |
| 60 | +Evaluates a normalized [Hermite polynomial][hermite-polynomial] of degree `n` using single-precision floating-point arithmetic. |
| 61 | + |
| 62 | +```javascript |
| 63 | +var v = normhermitepolyf( 1, 1.0 ); |
| 64 | +// returns 1.0 |
| 65 | + |
| 66 | +v = normhermitepolyf( 1, 0.5 ); |
| 67 | +// returns 0.5 |
| 68 | + |
| 69 | +v = normhermitepolyf( 0, 0.5 ); |
| 70 | +// returns 1.0 |
| 71 | + |
| 72 | +v = normhermitepolyf( 2, 0.5 ); |
| 73 | +// returns -0.75 |
| 74 | + |
| 75 | +v = normhermitepolyf( -1, 0.5 ); |
| 76 | +// returns NaN |
| 77 | +``` |
| 78 | + |
| 79 | +#### normhermitepolyf.factory( n ) |
| 80 | + |
| 81 | +Returns a function for evaluating a normalized [Hermite polynomial][hermite-polynomial] of degree `n` using single-precision floating-point arithmetic. |
| 82 | + |
| 83 | +```javascript |
| 84 | +var polyval = normhermitepolyf.factory( 2 ); |
| 85 | + |
| 86 | +var v = polyval( 0.5 ); |
| 87 | +// returns -0.75 |
| 88 | +``` |
| 89 | + |
| 90 | +</section> |
| 91 | + |
| 92 | +<!-- /.usage --> |
| 93 | + |
| 94 | +<!-- Package usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> |
| 95 | + |
| 96 | +<section class="notes"> |
| 97 | + |
| 98 | +</section> |
| 99 | + |
| 100 | +<!-- /.notes --> |
| 101 | + |
| 102 | +<!-- Package usage examples. --> |
| 103 | + |
| 104 | +<section class="examples"> |
| 105 | + |
| 106 | +## Examples |
| 107 | + |
| 108 | +<!-- eslint no-undef: "error" --> |
| 109 | + |
| 110 | +```javascript |
| 111 | +var uniform = require( '@stdlib/random/array/uniform' ); |
| 112 | +var zeros = require( '@stdlib/array/zeros' ); |
| 113 | +var smap = require( '@stdlib/strided/base/smap' ); |
| 114 | +var logEach = require( '@stdlib/console/log-each' ); |
| 115 | +var normhermitepolyf = require( '@stdlib/math/base/tools/normhermitepolyf' ); |
| 116 | + |
| 117 | +// Generate random values at which to evaluate a polynomial: |
| 118 | +var x = uniform( 10, -50.0, 50.0, { |
| 119 | + 'dtype': 'float32' |
| 120 | +}); |
| 121 | + |
| 122 | +// Create a polynomial function of degree 1: |
| 123 | +var f = normhermitepolyf.factory( 1 ); |
| 124 | + |
| 125 | +// Allocate an output array: |
| 126 | +var y = zeros( x.length, 'float32' ); |
| 127 | + |
| 128 | +// Evaluate the polynomial: |
| 129 | +smap( x.length, x, 1, y, 1, f ); |
| 130 | +logEach( 'He_%d(%.3f) = %.3f', 1, x, y ); |
| 131 | + |
| 132 | +// Create a polynomial function of degree 2: |
| 133 | +f = normhermitepolyf.factory( 2 ); |
| 134 | + |
| 135 | +// Allocate an output array: |
| 136 | +y = zeros( x.length, 'float32' ); |
| 137 | + |
| 138 | +// Evaluate the polynomial: |
| 139 | +smap( x.length, x, 1, y, 1, f ); |
| 140 | +logEach( 'He_%d(%.3f) = %.3f', 2, x, y ); |
| 141 | + |
| 142 | +// Create a polynomial function of degree 3: |
| 143 | +f = normhermitepolyf.factory( 3 ); |
| 144 | + |
| 145 | +// Allocate an output array: |
| 146 | +y = zeros( x.length, 'float32' ); |
| 147 | + |
| 148 | +// Evaluate the polynomial: |
| 149 | +smap( x.length, x, 1, y, 1, f ); |
| 150 | +logEach( 'He_%d(%.3f) = %.3f', 3, x, y ); |
| 151 | +``` |
| 152 | + |
| 153 | +</section> |
| 154 | + |
| 155 | +<!-- /.examples --> |
| 156 | + |
| 157 | +<!-- 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. --> |
| 158 | + |
| 159 | +<section class="references"> |
| 160 | + |
| 161 | +</section> |
| 162 | + |
| 163 | +<!-- /.references --> |
| 164 | + |
| 165 | +<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. --> |
| 166 | + |
| 167 | +<section class="related"> |
| 168 | + |
| 169 | +</section> |
| 170 | + |
| 171 | +<!-- /.related --> |
| 172 | + |
| 173 | +<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> |
| 174 | + |
| 175 | +<section class="links"> |
| 176 | + |
| 177 | +[hermite-polynomial]: https://en.wikipedia.org/wiki/Hermite_polynomials |
| 178 | + |
| 179 | +</section> |
| 180 | + |
| 181 | +<!-- /.links --> |
0 commit comments