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) ...
随机推荐
- 什么是MIME类型-基础知识补全
MIME类型(Multipurpose Internet Mail Extensions,多用途互联网邮件扩展)是一种标准,用于标识互联网上传输的文件类型.它最初是为电子邮件设计的,后来被广泛应用于W ...
- Ubuntu24使用Wine运行Windows程序安装微信
Ubuntu24使用Wine运行Windows程序安装微信 2024.11.8:好消息!微信发布Linux版本了,微信主站Linux版本客户端下载页面:https://linux.weixin.qq. ...
- word突然无法转换latex公式的解决尝试
正常情况下我在word插入复制的latex公式步骤如下(以\(\mu\neq 10\)为例): 把\(\mu\neq 10\)粘贴到word文档中,选中\(\mu\neq 10\)并同时按下alt和等 ...
- STM32串口缓冲区
在嵌入式开发中,外设通信(如UART.SPI.I2C)的数据接收常面临两大挑战:不定时.不定量数据的实时处理和高频率数据流下的稳定性保障.传统的轮询方式效率低下,而中断驱动的接收逻辑又容易因处理延迟导 ...
- FastAPI依赖覆盖与测试环境模拟
title: FastAPI依赖覆盖与测试环境模拟 date: 2025/04/10 00:58:09 updated: 2025/04/10 00:58:09 author: cmdragon ex ...
- QT C++ 实现数据类与 json 的转换
QT 提供了 QJsonDocument.QJsonObject.QJsonArray.QJsonValue 等类用于 JSON 的解析和转换.QJsonValue 支持的数据类型包括:bool.do ...
- Map之“获取map中的key流转为List”
一.获取map中的key转为List 注意 这里可以获取map中所有的key来转换为List, 这样后很多方案就不需要另外查询出来处理了 代码 @Test public void test() { M ...
- 告别 .NET 7,支持将于 5 月结束——我们几乎不认识你
微软 .NET 7 软件框架的支持将于 5 月结束,这距离其 2022 年发布仅过去 18 个月--这提醒我们,长期更新时代正在成为过去. .NET 7 于 2022 年 11 月 8 日首次亮相,与 ...
- 第六章: SEO与交互指标 二
上一篇文章地址 5. 提升用户参与度 提高用户参与度不仅有利于SEO,还能增加转化率和用户留存. 5.1 内容结构优化 使用吸引人的标题和小标题: 使用数字列表.问题形式或"如何" ...
- Django踩坑之django.core.exceptions.ImproperlyConfigured mysqlclient 1.3.13 or newer is required; you have 0.9.3.
安装Django3后不想折腾mysqlclient那堆库文件,直接装了pymysql替代mysqlclient,报错:django.core.exceptions.ImproperlyConfigur ...