Continuous uniform probability density function
collapse all in page
Syntax
y = unifpdf(x)
y = unifpdf(x,a,b)
Description
example
y = unifpdf(x)
returns the probability density function (pdf) of the standard uniform distribution, evaluated at the values in x
.
example
y = unifpdf(x,a,b)
returns the pdf of the continuous uniform distribution on the interval [a
, b
], evaluated at the values in x
.
Examples
collapse all
Compute Standard and Continuous Uniform pdf
Open Live Script
The pdf of the standard uniform distribution is constant on the interval [0,1]
.
Compute the pdf of 0.2, 0.4,...,1 in the standard uniform distribution.
x = 0.2:0.2:1;y = unifpdf(x)
y = 1×5 1 1 1 1 1
If x
is not between a
and b
, unifpdf
returns 0
.
Compute the pdf of 1
through 5
in the continuous uniform distribution on the interval [2,4]
.
x2 = 1:5;unifpdf(x2,2,4)
ans = 1×5 0 0.5000 0.5000 0.5000 0
If the parameter a
is larger than b
, unifpdf
returns NaN
regardless of the x
input.
unifpdf(5,10,1)
ans = NaN
Input Arguments
collapse all
x
— Values at which to evaluate pdf
nonnegative scalar value | array of nonnegative scalar values
Values at which to evaluate the pdf, specified as a nonnegative scalar value or an array of nonnegative scalar values.
To evaluate the pdf at multiple values, specify
x
using an array.To evaluate the pdfs of multiple distributions, specify a and b using arrays.
If one or more of the input arguments x
, a
, and b
are arrays, then the array sizes must be the same. In this case, unifpdf
expands each scalar input into a constant array of the same size as the array inputs. Each element in y is the pdf value of the distribution specified by the corresponding elements in a
and b
, evaluated at the corresponding element in x
.
Example: [3 4 7 9]
Data Types: single
| double
a
— Lower endpoint
scalar value | array of scalar values
Lower endpoint of the uniform distribution, specified as a scalar value or an array of scalar values.
To evaluate the pdf at multiple values, specify x using an array.
To evaluate the pdfs of multiple distributions, specify
a
and b using arrays.
If one or more of the input arguments x
, a
, and b
are arrays, then the array sizes must be the same. In this case, unifpdf
expands each scalar input into a constant array of the same size as the array inputs. Each element in y is the pdf value of the distribution specified by the corresponding elements in a
and b
, evaluated at the corresponding element in x
.
Example: [0 -1 7 9]
Data Types: single
| double
b
— Upper endpoint
scalar value | array of scalar values
Upper endpoint of the uniform distribution, specified as a scalar value or an array of scalar values.
To evaluate the pdf at multiple values, specify x using an array.
To evaluate the pdfs of multiple distributions, specify a and
b
using arrays.
If one or more of the input arguments x
, a
, and b
are arrays, then the array sizes must be the same. In this case, unifpdf
expands each scalar input into a constant array of the same size as the array inputs. Each element in y is the pdf value of the distribution specified by the corresponding elements in a
and b
, evaluated at the corresponding element in x
.
Example: [1 1 10 10]
Data Types: single
| double
Output Arguments
collapse all
y
— pdf values
scalar value | array of scalar values
pdf values evaluated at the values in x, returned as a scalar value or an array of scalar values. y
is the same size as x
, a, and b after any necessary scalar expansion. Each element in y
is the pdf value of the distribution specified by the corresponding elements in a
and b
, evaluated at the corresponding element in x
.
More About
collapse all
Continuous Uniform pdf
The continuous uniform distribution is a two-parameter family of curves with a constant pdf on its interval of support, [a, b]. The parameters a and b are the endpoints of the interval.
The continuous uniform pdf is
The standard uniform distribution occurs when a = 0 and b = 1.
For more information, see Uniform Distribution (Continuous).
Alternative Functionality
unifpdf
is a function specific to the continuous uniform distribution. Statistics and Machine Learning Toolbox™ also offers the generic function pdf, which supports various probability distributions. To usepdf
, create a UniformDistribution probability distribution object and pass the object as an input argument or specify the probability distribution name and its parameters. Note that the distribution-specific functionunifpdf
is faster than the generic functionpdf
.Use the Probability Distribution Function app to create an interactive plot of the cumulative distribution function (cdf) or probability density function (pdf) for a probability distribution.
Extended Capabilities
C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.
GPU Arrays
Accelerate code by running on a graphics processing unit (GPU) using Parallel Computing Toolbox™.
This function fully supports GPU arrays. For more information, see Run MATLAB Functions on a GPU (Parallel Computing Toolbox).
Version History
Introduced before R2006a
See Also
UniformDistribution | pdf | unifcdf | unifinv | unifstat | unifit | unifrnd
Topics
- Uniform Distribution (Continuous)
MATLAB 命令
您点击的链接对应于以下 MATLAB 命令:
请在 MATLAB 命令行窗口中直接输入以执行命令。Web 浏览器不支持 MATLAB 命令。
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 简体中文
- English
- 日本 (日本語)
- 한국 (한국어)
Contact your local office