|
| 1 | +<!-- |
| 2 | +
|
| 3 | +@license Apache-2.0 |
| 4 | +
|
| 5 | +Copyright (c) 2025 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 | +# Probability Density Function |
| 22 | + |
| 23 | +> [Bradford][bradford-distribution] distribution [probability density function][pdf] (PDF). |
| 24 | +
|
| 25 | +<section class="intro"> |
| 26 | + |
| 27 | +The [probability density function][pdf] (PDF) for a [Bradford][bradford-distribution] random variable is |
| 28 | + |
| 29 | +<!-- <equation class="equation" label="eq:bradford_pdf" align="center" raw="f(x;c)=\frac{c}{(\ln(1+c)) (1 + cx)}" alt="Probability density function (PDF) for a Bradford distribution."> --> |
| 30 | + |
| 31 | +```math |
| 32 | +f(x;c)=\frac{c}{(\ln(1+c)) (1 + cx)} |
| 33 | +``` |
| 34 | + |
| 35 | +<!-- <div class="equation" align="center" data-raw-text="f(x;c)=\frac{c}{(\ln(1+c)) (1 + cx)}" data-equation="eq:bradford_pdf"> |
| 36 | + <img src="https://cdn.jsdelivr.net/gh/stdlib-js/stdlib@51534079fef45e990850102147e8945fb023d1d0/lib/node_modules/@stdlib/stats/base/dists/bradford/pdf/docs/img/equation_bradford_pdf.svg" alt="Probability density function (PDF) for a Bradford distribution."> |
| 37 | + <br> |
| 38 | +</div> --> |
| 39 | + |
| 40 | +<!-- </equation> --> |
| 41 | + |
| 42 | +where `c > 0` is the shape parameter of the distribution. |
| 43 | + |
| 44 | +</section> |
| 45 | + |
| 46 | +<!-- /.intro --> |
| 47 | + |
| 48 | +<section class="usage"> |
| 49 | + |
| 50 | +## Usage |
| 51 | + |
| 52 | +```javascript |
| 53 | +var pdf = require( '@stdlib/stats/base/dists/bradford/pdf' ); |
| 54 | +``` |
| 55 | + |
| 56 | +#### pdf( x, c ) |
| 57 | + |
| 58 | +Evaluates the [probability density function][pdf] (PDF) for a [Bradford][bradford-distribution] distribution with shape parameter `c` at a value `x`. |
| 59 | + |
| 60 | +```javascript |
| 61 | +var y = pdf( 0.1, 0.1 ); |
| 62 | +// returns ~1.039 |
| 63 | + |
| 64 | +y = pdf( 0.5, 5.0 ); |
| 65 | +// returns ~0.797 |
| 66 | + |
| 67 | +y = pdf( 1.0, 10.0 ); |
| 68 | +// returns ~0.379 |
| 69 | +``` |
| 70 | + |
| 71 | +If provided `NaN` as any argument, the function returns `NaN`. |
| 72 | + |
| 73 | +```javascript |
| 74 | +var y = pdf( NaN, 1.0 ); |
| 75 | +// returns NaN |
| 76 | + |
| 77 | +y = pdf( 0.0, NaN ); |
| 78 | +// returns NaN |
| 79 | +``` |
| 80 | + |
| 81 | +If provided a `x` outside the support `[0,1]`, the function returns `0`. |
| 82 | + |
| 83 | +```javascript |
| 84 | +var y = pdf( 2.0, 1.0 ); |
| 85 | +// returns 0.0 |
| 86 | + |
| 87 | +y = pdf( -0.5, 1.0 ); |
| 88 | +// returns 0.0 |
| 89 | +``` |
| 90 | + |
| 91 | +If provided a shape parameter `c <= 0`, the function returns `NaN`. |
| 92 | + |
| 93 | +```javascript |
| 94 | +var y = pdf( 0.5, 0.0 ); |
| 95 | +// returns NaN |
| 96 | + |
| 97 | +y = pdf( 0.5, -5.0 ); |
| 98 | +// returns NaN |
| 99 | +``` |
| 100 | + |
| 101 | +#### pdf.factory( c ) |
| 102 | + |
| 103 | +Returns a function for evaluating the [PDF][pdf] of a [Bradford][bradford-distribution] distribution with shape parameter `c`. |
| 104 | + |
| 105 | +```javascript |
| 106 | +var myPDF = pdf.factory( 5.0 ); |
| 107 | +var y = myPDF( 0.5 ); |
| 108 | +// returns ~0.797 |
| 109 | + |
| 110 | +y = myPDF( 1.0 ); |
| 111 | +// returns ~0.465 |
| 112 | +``` |
| 113 | + |
| 114 | +</section> |
| 115 | + |
| 116 | +<!-- /.usage --> |
| 117 | + |
| 118 | +<section class="examples"> |
| 119 | + |
| 120 | +## Examples |
| 121 | + |
| 122 | +<!-- eslint no-undef: "error" --> |
| 123 | + |
| 124 | +```javascript |
| 125 | +var uniform = require( '@stdlib/random/array/uniform' ); |
| 126 | +var pdf = require( '@stdlib/stats/base/dists/bradford/pdf' ); |
| 127 | + |
| 128 | +var x = uniform( 10, 0.0, 1.0 ); |
| 129 | +var c = uniform( 10, 0.1, 10.0 ); |
| 130 | + |
| 131 | +var y; |
| 132 | +var i; |
| 133 | +for ( i = 0; i < x.length; i++ ) { |
| 134 | + y = pdf( x[ i ], c[ i ] ); |
| 135 | + console.log( 'x: %d, c: %d, f(x;c): %d', x[ i ].toFixed( 4 ), c[ i ].toFixed( 4 ), y.toFixed( 4 ) ); |
| 136 | +} |
| 137 | +``` |
| 138 | + |
| 139 | +</section> |
| 140 | + |
| 141 | +<!-- /.examples --> |
| 142 | + |
| 143 | +<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. --> |
| 144 | + |
| 145 | +<section class="related"> |
| 146 | + |
| 147 | +</section> |
| 148 | + |
| 149 | +<!-- /.related --> |
| 150 | + |
| 151 | +<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> |
| 152 | + |
| 153 | +<section class="links"> |
| 154 | + |
| 155 | +[pdf]: https://en.wikipedia.org/wiki/Probability_density_function |
| 156 | + |
| 157 | +[bradford-distribution]: https://en.wikipedia.org/wiki/Bradford%27s_law |
| 158 | + |
| 159 | +</section> |
| 160 | + |
| 161 | +<!-- /.links --> |
0 commit comments