README.md (6446B)
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 # Cosine 22 23 > Raised cosine distribution constructor. 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 </section> 30 31 <!-- /.intro --> 32 33 <!-- Package usage documentation. --> 34 35 <section class="usage"> 36 37 ## Usage 38 39 ```javascript 40 var Cosine = require( '@stdlib/stats/base/dists/cosine/ctor' ); 41 ``` 42 43 #### Cosine( \[mu, s] ) 44 45 Returns a [raised cosine][cosine-distribution] distribution object. 46 47 ```javascript 48 var cosine = new Cosine(); 49 50 var mu = cosine.mean; 51 // returns 0.0 52 ``` 53 54 By default, `mu = 0.0` and `s = 1.0`. To create a distribution having a different `mu` (location parameter) and `s` (scale parameter), provide the corresponding arguments. 55 56 ```javascript 57 var cosine = new Cosine( 2.0, 4.0 ); 58 59 var mu = cosine.mean; 60 // returns 2.0 61 ``` 62 63 * * * 64 65 ## cosine 66 67 A [raised cosine][cosine-distribution] distribution object has the following properties and methods... 68 69 ### Writable Properties 70 71 #### cosine.mu 72 73 Location parameter of the distribution. 74 75 ```javascript 76 var cosine = new Cosine(); 77 78 var mu = cosine.mu; 79 // returns 0.0 80 81 cosine.mu = 3.0; 82 83 mu = cosine.mu; 84 // returns 3.0 85 ``` 86 87 #### cosine.s 88 89 Scale parameter of the distribution. `s` **must** be a positive number. 90 91 ```javascript 92 var cosine = new Cosine( 2.0, 4.0 ); 93 94 var s = cosine.s; 95 // returns 4.0 96 97 cosine.s = 3.0; 98 99 s = cosine.s; 100 // returns 3.0 101 ``` 102 103 * * * 104 105 ### Computed Properties 106 107 #### Cosine.prototype.kurtosis 108 109 Returns the [excess kurtosis][kurtosis]. 110 111 ```javascript 112 var cosine = new Cosine( 4.0, 12.0 ); 113 114 var kurtosis = cosine.kurtosis; 115 // returns ~-0.594 116 ``` 117 118 #### Cosine.prototype.mean 119 120 Returns the [expected value][expected-value]. 121 122 ```javascript 123 var cosine = new Cosine( 4.0, 12.0 ); 124 125 var mu = cosine.mean; 126 // returns 4.0 127 ``` 128 129 #### Cosine.prototype.median 130 131 Returns the [median][median]. 132 133 ```javascript 134 var cosine = new Cosine( 4.0, 12.0 ); 135 136 var median = cosine.median; 137 // returns 4.0 138 ``` 139 140 #### Cosine.prototype.mode 141 142 Returns the [mode][mode]. 143 144 ```javascript 145 var cosine = new Cosine( 4.0, 12.0 ); 146 147 var mode = cosine.mode; 148 // returns 4.0 149 ``` 150 151 #### Cosine.prototype.skewness 152 153 Returns the [skewness][skewness]. 154 155 ```javascript 156 var cosine = new Cosine( 4.0, 12.0 ); 157 158 var skewness = cosine.skewness; 159 // returns 0.0 160 ``` 161 162 #### Cosine.prototype.stdev 163 164 Returns the [standard deviation][standard-deviation]. 165 166 ```javascript 167 var cosine = new Cosine( 4.0, 12.0 ); 168 169 var s = cosine.stdev; 170 // returns ~4.338 171 ``` 172 173 #### Cosine.prototype.variance 174 175 Returns the [variance][variance]. 176 177 ```javascript 178 var cosine = new Cosine( 4.0, 12.0 ); 179 180 var s2 = cosine.variance; 181 // returns ~18.819 182 ``` 183 184 * * * 185 186 ### Methods 187 188 #### Cosine.prototype.cdf( x ) 189 190 Evaluates the [cumulative distribution function][cdf] (CDF). 191 192 ```javascript 193 var cosine = new Cosine( 2.0, 4.0 ); 194 195 var y = cosine.cdf( 0.5 ); 196 // returns ~0.165 197 ``` 198 199 #### Cosine.prototype.logcdf( x ) 200 201 Evaluates the natural logarithm of the [cumulative distribution function][cdf] (CDF). 202 203 ```javascript 204 var cosine = new Cosine( 2.0, 4.0 ); 205 206 var y = cosine.logcdf( 0.5 ); 207 // returns ~-1.799 208 ``` 209 210 #### Cosine.prototype.logpdf( x ) 211 212 Evaluates the natural logarithm of the [probability density function][pdf] (PDF). 213 214 ```javascript 215 var cosine = new Cosine( 2.0, 4.0 ); 216 217 var y = cosine.logpdf( 0.8 ); 218 // returns ~-1.617 219 ``` 220 221 #### Cosine.prototype.mgf( t ) 222 223 Evaluates the [moment-generating function][mgf] (MGF). 224 225 ```javascript 226 var cosine = new Cosine( 2.0, 4.0 ); 227 228 var y = cosine.mgf( 0.2 ); 229 // returns ~1.555 230 ``` 231 232 #### Cosine.prototype.pdf( x ) 233 234 Evaluates the [probability density function][pdf] (PDF). 235 236 ```javascript 237 var cosine = new Cosine( 2.0, 4.0 ); 238 239 var y = cosine.pdf( 2.0 ); 240 // returns 0.25 241 ``` 242 243 #### Cosine.prototype.quantile( p ) 244 245 Evaluates the [quantile function][quantile-function] at probability `p`. 246 247 ```javascript 248 var cosine = new Cosine( 2.0, 4.0 ); 249 250 var y = cosine.quantile( 0.9 ); 251 // returns ~3.929 252 253 y = cosine.quantile( 1.9 ); 254 // returns NaN 255 ``` 256 257 </section> 258 259 <!-- /.usage --> 260 261 <!-- Package usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> 262 263 <section class="notes"> 264 265 </section> 266 267 <!-- /.notes --> 268 269 <!-- Package usage examples. --> 270 271 * * * 272 273 <section class="examples"> 274 275 ## Examples 276 277 <!-- eslint no-undef: "error" --> 278 279 ```javascript 280 var Cosine = require( '@stdlib/stats/base/dists/cosine/ctor' ); 281 282 var cosine = new Cosine( 2.0, 4.0 ); 283 284 var mean = cosine.mean; 285 // returns 2.0 286 287 var median = cosine.median; 288 // returns 2.0 289 290 var s2 = cosine.variance; 291 // returns ~2.091 292 293 var y = cosine.cdf( 0.8 ); 294 // returns ~0.221 295 ``` 296 297 </section> 298 299 <!-- /.examples --> 300 301 <!-- 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. --> 302 303 <section class="references"> 304 305 </section> 306 307 <!-- /.references --> 308 309 <!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> 310 311 <section class="links"> 312 313 [cosine-distribution]: https://en.wikipedia.org/wiki/Raised_cosine_distribution 314 315 [cdf]: https://en.wikipedia.org/wiki/Cumulative_distribution_function 316 317 [mgf]: https://en.wikipedia.org/wiki/Moment-generating_function 318 319 [pdf]: https://en.wikipedia.org/wiki/Probability_density_function 320 321 [quantile-function]: https://en.wikipedia.org/wiki/Quantile_function 322 323 [expected-value]: https://en.wikipedia.org/wiki/Expected_value 324 325 [kurtosis]: https://en.wikipedia.org/wiki/Kurtosis 326 327 [median]: https://en.wikipedia.org/wiki/Median 328 329 [mode]: https://en.wikipedia.org/wiki/Mode_%28statistics%29 330 331 [skewness]: https://en.wikipedia.org/wiki/Skewness 332 333 [standard-deviation]: https://en.wikipedia.org/wiki/Standard_deviation 334 335 [variance]: https://en.wikipedia.org/wiki/Variance 336 337 </section> 338 339 <!-- /.links -->