请问怎么用matlab求出一幅图像的概率密度分布阿?

请问怎么用matlab求出一幅图像的概率密度分布阿?,第1张

我觉得楼主的问题中“概率密度分布”是指图像的灰度值得分布,所以应该用直方图统计函数 hist。

增加的回答:稀疏我觉得取决于图像的内容,另外可以调整imhist的统计频率的间隔。至于包络,直接用imhist无法画出,可以用imhist的取样间隔与频率,用plot画出来,即可得到pdf图像了。另外你可以参考一下这个画包络的,也许有帮助。

http://wwwscieicom/blog/user1/604/archives/2006/200632319557html

m=ksdensity(data,x,'function','cdf')

data就是有自己定义的密度函数生成数据(n行1列)

x就是输入的点,第三四个参数就写'function','cdf不变

m就是所求的分位数值。'

MATLAB自带的两个方法rand和randn可实现,验证的话其实就是从概率密度函数和累积分布函数来验证,MATLAB自带函数ksdensity可实现。

以下是help文档

产生0-1均匀分布rand

Uniformly distributed pseudorandom numbers

Syntax

r = rand(n)

rand(m,n)

rand([m,n])

rand(m,n,p,)

rand([m,n,p,])

rand

rand(size(A))

r = rand(, 'double')

r

= rand(, 'single')

Description

r = rand(n) returns an n-by-n matrix

containing pseudorandom values drawn from the standard uniform distribution

on the open interval (0,1) rand(m,n) or rand([m,n]) returns

an m-by-n matrix rand(m,n,p,) or rand([m,n,p,]) returns

an m-by-n-by-p-by-

array rand returns a scalar rand(size(A)) returns

an array the same size as A

r = rand(, 'double') or r

= rand(, 'single') returns an array of uniform values

of the specified class

Note

Note: The size inputs m, n, p,

should be nonnegative integers Negative integers are treated

as 0

The sequence of numbers produced by rand is determined by the

internal state of the uniform pseudorandom number generator that underlies rand, randi,

and randn The default random

number stream properties can be set using @RandStream methods See @RandStream for details

about controlling the default stream

Resetting the default stream to the same fixed state allows

computations to be repeated Setting the stream to different states

leads to unique computations, however, it does not improve any statistical

properties Since the random number generator is initialized to the

same state every time MATLAB software starts up, rand, randn,

and randi will generate the

same sequence of numbers in each session until the state is changed

Note

In versions of MATLAB prior to 77, you controlled the

internal state of the random number stream used by rand by calling rand directly

with the 'seed', 'state', or 'twister' keywords

That syntax is still supported for backwards compatibility, but is

deprecated For version 77, use the default stream as described

in the @RandStream reference

documentation

Examples

Generate values from the uniform distribution on the interval [a,

b]

r = a + (b-a)rand(100,1);

Replace the default stream at MATLAB startup, using a stream

whose seed is based on clock,

so that rand will return different

values in different MATLAB sessions It is usually not desirable

to do this more than once per MATLAB session

RandStreamsetDefaultStream

(RandStream('mt19937ar','seed',sum(100clock)));

rand(1,5)

Save the current state of the default stream, generate 5 values,

restore the state, and repeat the sequence

defaultStream = RandStreamgetDefaultStream;

savedState = defaultStreamState;

u1 = rand(1,5)

defaultStreamState = savedState;

u2 = rand(1,5) % contains exactly the same values as u1

产生高斯分布随机变量randn

Normally distributed pseudorandom numbers

Syntax

r = randn(n)

randn(m,n)

randn([m,n])

randn(m,n,p,)

randn([m,n,p,])

randn(size(A))

r = randn(, 'double')

r

= randn(, 'single')

Description

r = randn(n) returns an n-by-n matrix

containing pseudorandom values drawn from the standard normal distribution randn(m,n) or randn([m,n]) returns

an m-by-n matrix randn(m,n,p,) or randn([m,n,p,]) returns

an m-by-n-by-p-by-

array randn returns a scalar randn(size(A)) returns

an array the same size as A

r = randn(, 'double') or r

= randn(, 'single') returns an array of normal values

of the specified class

Note

The size inputs m, n, p,

should be nonnegative integers Negative integers are treated

as 0

The sequence of numbers produced by randn is

determined by the internal state of the uniform pseudorandom number

generator that underlies rand, randi, and randn randn uses

one or more uniform values from that default stream to generate each

normal value Control the default stream using its properties and

methods See @RandStream for

details about the default stream

Resetting the default stream to the same fixed state allows

computations to be repeated Setting the stream to different states

leads to unique computations, however, it does not improve any statistical

properties Since the random number generator is initialized to the

same state every time MATLAB software starts up, rand, randn,

and randi will generate the

same sequence of numbers in each session until the state is changed

Note

In versions of MATLAB prior to 77, you controlled the

internal state of the random number stream used by randn by calling randn directly

with the 'seed' or 'state' keywords

That syntax is still supported for backwards compatibility, but is

deprecated For version 77, use the default stream as described

in the @RandStream reference

documentation

Examples

Generate values from a normal distribution with mean 1 and standard

deviation 2

r = 1 + 2randn(100,1);

Generate values from a bivariate normal distribution with specified

mean vector and covariance matrix

mu = [1 2];

Sigma = [1 5; 5 2]; R = chol(Sigma);

z = repmat(mu,100,1) + randn(100,2)R;

Replace the default stream at MATLAB startup, using a stream

whose seed is based on clock,

so that randn will return different

values in different MATLAB sessions It is usually not desirable

to do this more than once per MATLAB session

RandStreamsetDefaultStream

(RandStream('mt19937ar','seed',sum(100clock)));

randn(1,5)

Save the current state of the default stream, generate 5 values,

restore the state, and repeat the sequence

defaultStream = RandStreamgetDefaultStream;

savedState = defaultStreamState;

z1 = randn(1,5)

defaultStreamState = savedState;

z2 = randn(1,5) % contains exactly the same values as z1

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/12178144.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-21
下一篇 2023-05-21

发表评论

登录后才能评论

评论列表(0条)

保存