README.md (3188B)
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 # Quantile Function 22 23 > [Raised cosine][cosine-distribution] distribution [quantile function][quantile-function]. 24 25 <section class="intro"> 26 27 <!-- /.intro --> 28 29 <section class="usage"> 30 31 ## Usage 32 33 ```javascript 34 var quantile = require( '@stdlib/stats/base/dists/cosine/quantile' ); 35 ``` 36 37 #### quantile( p, mu, s ) 38 39 Evaluates the [quantile function][quantile-function] for a [raised cosine][cosine-distribution] distribution with parameters `mu` (location parameter) and `s` (scale parameter). 40 41 ```javascript 42 var y = quantile( 0.5, 0.0, 1.0 ); 43 // returns ~0.0 44 45 y = quantile( 0.2, 4.0, 2.0 ); 46 // returns ~3.345 47 ``` 48 49 If provided a probability `p` outside the interval `[0,1]`, the function returns `NaN`. 50 51 ```javascript 52 var y = quantile( 1.9, 0.0, 1.0 ); 53 // returns NaN 54 55 y = quantile( -0.1, 0.0, 1.0 ); 56 // returns NaN 57 ``` 58 59 If provided `NaN` as any argument, the function returns `NaN`. 60 61 ```javascript 62 var y = quantile( NaN, 0.0, 1.0 ); 63 // returns NaN 64 65 y = quantile( 0.0, NaN, 1.0 ); 66 // returns NaN 67 68 y = quantile( 0.0, 0.0, NaN ); 69 // returns NaN 70 ``` 71 72 If provided `s < 0`, the function returns `NaN`. 73 74 ```javascript 75 var y = quantile( 0.4, 0.0, -1.0 ); 76 // returns NaN 77 ``` 78 79 If provided `s = 0`, the function evaluates the [quantile function][quantile-function] of a [degenerate distribution][degenerate-distribution] centered at `mu`. 80 81 ```javascript 82 var y = quantile( 0.3, 8.0, 0.0 ); 83 // returns 8.0 84 85 y = quantile( 0.9, 8.0, 0.0 ); 86 // returns 8.0 87 ``` 88 89 #### quantile.factory( mu, s ) 90 91 Returns a function for evaluating the [quantile function][quantile-function] of a [raised cosine][cosine-distribution] distribution with parameters `mu` and `s`. 92 93 ```javascript 94 var myQuantile = quantile.factory( 10.0, 2.0 ); 95 96 var y = myQuantile( 0.2 ); 97 // returns ~9.345 98 99 y = myQuantile( 0.9 ); 100 // returns ~10.964 101 ``` 102 103 </section> 104 105 <!-- /.usage --> 106 107 <section class="examples"> 108 109 ## Examples 110 111 <!-- eslint no-undef: "error" --> 112 113 ```javascript 114 var randu = require( '@stdlib/random/base/randu' ); 115 var quantile = require( '@stdlib/stats/base/dists/cosine/quantile' ); 116 117 var mu; 118 var s; 119 var p; 120 var y; 121 var i; 122 123 for ( i = 0; i < 10; i++ ) { 124 p = randu(); 125 mu = randu() * 10.0; 126 s = randu() * 10.0; 127 y = quantile( p, mu, s ); 128 console.log( 'p: %d, µ: %d, s: %d, Q(p;µ,s): %d', p, mu, s, y ); 129 } 130 ``` 131 132 </section> 133 134 <!-- /.examples --> 135 136 <section class="links"> 137 138 [cosine-distribution]: https://en.wikipedia.org/wiki/Raised_cosine_distribution 139 140 [quantile-function]: https://en.wikipedia.org/wiki/Quantile_function 141 142 [degenerate-distribution]: https://en.wikipedia.org/wiki/Degenerate_distribution 143 144 </section> 145 146 <!-- /.links -->