Continuous uniform probability density function (2024)

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)

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

xValues 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

aLower 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

bUpper 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

y=f(x|a,b)=1baI[a,b](x).

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 use pdf, 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 function unifpdf is faster than the generic function pdf.

  • 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™.

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 命令。

Continuous uniform probability density function (1)

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

Europe

Asia Pacific

Contact your local office

Continuous uniform probability density function (2024)
Top Articles
Latest Posts
Article information

Author: Tyson Zemlak

Last Updated:

Views: 5675

Rating: 4.2 / 5 (63 voted)

Reviews: 94% of readers found this page helpful

Author information

Name: Tyson Zemlak

Birthday: 1992-03-17

Address: Apt. 662 96191 Quigley Dam, Kubview, MA 42013

Phone: +441678032891

Job: Community-Services Orchestrator

Hobby: Coffee roasting, Calligraphy, Metalworking, Fashion, Vehicle restoration, Shopping, Photography

Introduction: My name is Tyson Zemlak, I am a excited, light, sparkling, super, open, fair, magnificent person who loves writing and wants to share my knowledge and understanding with you.