von Mises Distribution (冯·米赛斯分布)的随机模拟与参数估计的笔记(二)
von Mises Distribution (冯·米赛斯分布)的随机模拟与参数估计的笔记(二)
1.参数估计算子分析
在上一节中,我们讨论了von Mises Distribution的概率分布函数PDF和累计分布函数CDF,并给出了von Mises Distribution的随机模拟和参数估计matlab程序,其中在此我们就参数估计的细节进行补充。其基于最大似然参数估计算子,如下表:
来源于《Statistical Distributions》
利用如下改进贝塞尔函数的关系求解参数\(\kappa\),如下表达:
\]
\]
1.1 \(\mu\)参数估计分析matlab代码
function mu=circ_mean(alpha, w, dim)
%
% mu = circ_mean(alpha, w)
% Computes the mean direction for circular data.
%
% Input:
% alpha sample of angles in radians
% [w weightings in case of binned angle data]
% [dim compute along this dimension, default is 1]
%
% If dim argument is specified, all other optional arguments can be
% left empty: circ_mean(alpha, [], dim)
%
% Output:
% mu mean direction
%
% PHB 7/6/2008
%
% References:
% Statistical analysis of circular data, N. I. Fisher
% Topics in circular statistics, S. R. Jammalamadaka et al.
% Biostatistical Analysis, J. H. Zar
%
% Circular Statistics Toolbox for Matlab
% By Philipp Berens, 2009
% berens@tuebingen.mpg.de - www.kyb.mpg.de/~berens/circStat.html
if nargin < 3
dim = 1;
end
if nargin < 2 || isempty(w)
% if no specific weighting has been specified
% assume no binning has taken place
w = ones(size(alpha));
else
if size(w,2) ~= size(alpha,2) || size(w,1) ~= size(alpha,1)
error('Input dimensions do not match');
end
end
% compute weighted sum of cos and sin of angles
r = sum(w.*exp(1i*alpha),dim);
% obtain mean by
mu = angle(r);
1.2 \(\kappa\)参数估计的matlab代码
function kappa = circ_kappa(alpha,w)
%
% kappa = circ_kappa(alpha,[w])
% Computes an approximation to the ML estimate of the concentration
% parameter kappa of the von Mises distribution.
%
% Input:
% alpha angles in radians OR alpha is length resultant
% [w number of incidences in case of binned angle data]
%
% Output:
% kappa estimated value of kappa
%
% References:
% Statistical analysis of circular data, Fisher, equation p. 88
%
% Circular Statistics Toolbox for Matlab
% By Philipp Berens, 2009
% berens@tuebingen.mpg.de - www.kyb.mpg.de/~berens/circStat.html
alpha = alpha(:);
if nargin<2
% if no specific weighting has been specified
% assume no binning has taken place
w = ones(size(alpha));
else
if size(w,2) > size(w,1)
w = w';
end
end
N = length(alpha);
if N>1
R = circ_r(alpha,w);
else
R = alpha;
end
if R < 0.53
kappa = 2*R + R^3 + 5*R^5/6;
elseif R>=0.53 && R<0.85
kappa = -.4 + 1.39*R + 0.43/(1-R);
else
kappa = 1/(R^3 - 4*R^2 + 3*R);
end
if N<15 && N>1
if kappa < 2
kappa = max(kappa-2*(N*kappa)^-1,0);
else
kappa = (N-1)^3*kappa/(N^3+N);
end
end
function r = circ_r(alpha, w, d, dim)
% r = circ_r(alpha, w, d)
% Computes mean resultant vector length for circular data.
%
% Input:
% alpha sample of angles in radians
% [w number of incidences in case of binned angle data]
% [d spacing of bin centers for binned data, if supplied
% correction factor is used to correct for bias in
% estimation of r, in radians (!)]
% [dim compute along this dimension, default is 1]
%
% If dim argument is specified, all other optional arguments can be
% left empty: circ_r(alpha, [], [], dim)
%
% Output:
% r mean resultant length
%
% PHB 7/6/2008
%
% References:
% Statistical analysis of circular data, N.I. Fisher
% Topics in circular statistics, S.R. Jammalamadaka et al.
% Biostatistical Analysis, J. H. Zar
%
% Circular Statistics Toolbox for Matlab
% By Philipp Berens, 2009
% berens@tuebingen.mpg.de - www.kyb.mpg.de/~berens/circStat.html
if nargin < 4
dim = 1;
end
if nargin < 2 || isempty(w)
% if no specific weighting has been specified
% assume no binning has taken place
w = ones(size(alpha));
else
if size(w,2) ~= size(alpha,2) || size(w,1) ~= size(alpha,1)
error('Input dimensions do not match');
end
end
if nargin < 3 || isempty(d)
% per default do not apply correct for binned data
d = 0;
end
% compute weighted sum of cos and sin of angles
r = sum(w.*exp(1i*alpha),dim);
% obtain length
r = abs(r)./sum(w,dim);
% for data with known spacing, apply correction factor to correct for bias
% in the estimation of r (see Zar, p. 601, equ. 26.16)
if d ~= 0
c = d/2/sin(d/2);
r = c*r;
end
2 代码效果分析
clc
clear all
close all
theta=pi/2; %设置模拟参数
kappa=50;
n=3000;
alpha=circ_vmrnd(theta,kappa,n); %生成制定参数的von-Mises分布的随机数
[thetahat1 kappa1]=circ_vmpar(alpha); %对其进行分布参数进行估计分析
%绘制模拟数据直方图
figure(1)
hist(alpha,100);
xlabel('Angle(弧度)');
ylabel('Frequency');
X = categorical({'Really value','Estimate value'});
%估计参数与模型参数对比
figure(2)
subplot(1,2,1)
bar(X,[theta,thetahat1]);
ylabel('theta');
subplot(1,2,2)
bar(X,[kappa,kappa1]);
ylabel('kappa');
von Mises Distribution (冯·米赛斯分布)的随机模拟与参数估计的笔记(二)的更多相关文章
- Gamma 函数与exponential power distribution (指数幂分布)
1. Γ(⋅) 函数 Γ(α)=∫∞0tα−1e−tdt 可知以下基本性质: Γ(α+1)=αΓ(α) Γ(1)=1 ⇒ Γ(n+1)=n! Γ(12)=π√ 2. 指数幂分布(exponential ...
- Python模块:Random(未完待续)
本文基于Python 3.6.5的官文random编写. random模块简介 random为各种数学分布算法(distributions)实现了伪随机数生成器. 对于整数,是从一个范围中均匀选择(u ...
- Python标准库3.4.3-random
9.6. random — Generate pseudo-random numbers Source code: Lib/random.py 翻译:Z.F. This module impleme ...
- 【论文阅读】CVPR2021: MP3: A Unified Model to Map, Perceive, Predict and Plan
Sensor/组织: Uber Status: Reading Summary: 非常棒!端到端输出map中间态 一种建图 感知 预测 规划的通用框架 Type: CVPR Year: 2021 引用 ...
- 【python】函数之内置函数
Python基础 内置函数 今天来介绍一下Python解释器包含的一系列的内置函数,下面表格按字母顺序列出了内置函数: 下面就一一介绍一下内置函数的用法: 1.abs() 返回一个数值的绝对值,可以是 ...
- PRML读书笔记——2 Probability Distributions
2.1. Binary Variables 1. Bernoulli distribution, p(x = 1|µ) = µ 2.Binomial distribution + 3.beta dis ...
- 转:Python获取随机数(英文)
Random - Generate pseudo-random numbers Source code: Lib/random.py This module implements pseudo-ran ...
- python模块:random
"""Random variable generators. integers -------- uniform within range sequences ----- ...
- python3之模块random随机数
1.random.random() 随机生成一个大于0小于1的随机数. print(random.random()) 0.03064765450719098 2.random.uniform(a,b) ...
- 6.6 random--伪随机数的生成
本模块提供了生成要求安全度不高的随机数.假设须要更高安全的随机数产生.须要使用os.urandom()或者SystmeRandom模块. random.seed(a=None, version=2) ...
随机推荐
- npm publish
# 登录到 npm > npm login Username:[your username] Password:[******] Email:(this IS public):[youre em ...
- FireDAC 下的批量 SQL 命令执行
一.{逐条插入} procedure TForm1.Button1Click(Sender: TObject); const strInsert = 'INSERT INTO MyTable(Name ...
- jmeter使用时报错问题
一.打开时命令行提示按任意键继续图形界面无法打开 如图,打开时jmeter命令行报错 根据报错内容,是Java没有安装好. jdk安装好后,需要在环境变量中配置. 但是jdk安装配置好后打开还是报错, ...
- 从零开始:基于CUDA 12.6的YOLOv5模型训练实战(RTX 2050显卡全流程)
基于cuda12.6训练yolov5模型 前面完成了使用CPU调用yolov5s模型进行识别车辆,现在想训练自己的模型进行目标识别,使用CPU效率太低,尝试使用GPU加速的Pytorch,再重新整理了 ...
- MySQL开启general_log
General_log 详解 1.介绍 开启 general log 将所有到达MySQL Server的SQL语句记录下来. 一般不会开启开功能,因为log的量会非常庞大.但个别情况下可能会临时的开 ...
- Java序列化:为何必须实现Serializable并显式指定serialVersionUID?
结论先行 实现Serializable接口是Java对象序列化的基本前提,没有它JVM会直接拒绝序列化操作. 显式声明serialVersionUID能彻底掌控序列化版本兼容性,避免因类结构微小改动或 ...
- 【BUG】Linux目录下明明有可执行文件却提示找不到,“No such file or directory”,解决:为64位Ubuntu安装32位程序的运行架构
问题 我做了如下努力: ls显示:(能够成功显示) 修改文件名:(能够正常复制.修改.移动,并且被复制的仍然不能运行) 调整文件属性,弄成777: cat显示文件.(能够成功显示) root执行文件: ...
- MySQL高可用之ProxySQL + MGR 实现读写分离实战
部署MGR 1.MGR 前置介绍 阿里云RDS集群方案用的就是MGR模式! 1.1.什么是 MGR MGR(MySQL Group Replication)是MySQL 5.7.17版本诞生的,是My ...
- CAP 关键细节点与ACID、BASE的比较
极客时间:<从 0 开始学架构>:想成为架构师,你必须掌握的CAP细节 1.CAP 关键细节点 埃里克·布鲁尔(Eric Brewer)在<CAP 理论十二年回顾:"规则& ...
- 【语义分割专栏】:FCN原理篇
目录 前言 语义分割 背景介绍 FCN核心剖析 全卷积(Fully Convolution) 反卷积(deconvolution) 最近邻插值法 双线性插值 反卷积 跳跃连接(Skip Connect ...