当前位置: 首页 > news >正文

生成瑞利信道(Python and Matlab)

channel h k h_k hk is modeled as independent Rayleigh fading with average power loss set as 10^−3

Python

import numpy as np# Set the parameters
average_power_loss = 1e-3  # Average power loss (10^(-3))
num_samples = 1000  # Number of fading samples to generate# Calculate the Rayleigh scale parameter (sigma)
# The scale parameter is related to the average power loss as follows:
# average_power_loss = 2 * sigma^2
sigma = np.sqrt(average_power_loss / 2)# Generate independent Rayleigh fading samples
rayleigh_samples = sigma * np.random.randn(num_samples) + 1j * sigma * np.random.randn(num_samples)# The above code generates complex samples, where the real and imaginary parts
# are both independently Rayleigh distributed.# Optionally, you can plot a histogram of the fading samples to visualize
# the Rayleigh distribution.
import matplotlib.pyplot as pltplt.hist(np.abs(rayleigh_samples), bins=50, density=True)
plt.title("Rayleigh Fading Samples")
plt.xlabel("Amplitude")
plt.ylabel("Probability Density")
plt.show()

对比一下:

H = np.random.rayleigh(scale=1, size= N)*1e-3

如果设定的hk是实数,直接取模就行了。

# Take the absolute value to get real Rayleigh fading samples
rayleigh_samples_real = np.abs(rayleigh_samples_complex)

在这里插入图片描述

Matlab:

% Set the average power loss
average_power_loss = 10^(-3);% Calculate the scale parameter (σ)
sigma = sqrt(average_power_loss / 2);% Number of samples to generate
num_samples = 1000;% Generate random samples from the Rayleigh distribution
rayleigh_samples = raylrnd(sigma, 1, num_samples);% Plot the histogram of the generated samples
histogram(rayleigh_samples, 50); % Adjust the number of bins as needed% Label the axes
xlabel('Rayleigh Fading');
ylabel('Frequency');% Title for the plot
title(['Rayleigh Fading with Average Power Loss of 10^(-3), \sigma = ', num2str(sigma)]);

在这里插入图片描述

http://www.lryc.cn/news/214432.html

相关文章:

  • 数据结构Demo——简单计算器
  • java实现多文件打包压缩,导出zip文件
  • java-枚举类的使用
  • Vue插槽
  • 学习c++的第二天
  • Android NDK开发详解之调试和性能分析的系统跟踪概览
  • AD9371 官方例程HDL JESD204B相关IP端口信号
  • 蓝牙服务:优化体验,提高连接效率
  • SSM校园设备管信息管理系统开发mysql数据库web结构java编程计算机网页源码eclipse项目
  • iOS的应用生命周期以及应用界面
  • Macos下安装使用Redis
  • Redis的四种部署方案
  • Microsoft Edge不能工作了,可能原因不少,那么如何修复呢
  • 算法---缺失的第一个正数
  • 【算法与数据结构】--算法应用--算法和数据结构的案例研究
  • java如何获取调用接口的ip?
  • ubuntu 18 更新git版本到 2.80.1
  • 测试C#调用Aplayer播放视频(2:VideoPlayer源码学习)
  • YOLOv5 分类模型的预处理
  • 25 行为型模式-备忘录模式
  • 物联网AI MicroPython传感器学习 之 SHT3X温湿度传感器
  • int* p = new int[5]; int *p = new int[5]();delete[] p; delete p;区别是什么?
  • 数据结构|基础知识定义
  • 物联网AI MicroPython传感器学习 之 MFRC522 RFID射频IC卡感应模块
  • 搭建ES集群
  • Tomcat的日志接收文件catalina.out nohup.out说明
  • 手机ip地址切换后有什么影响
  • C++ 赋值运算重载,const成员,取地址及const取地址操作符重载
  • 嵌入式Linux系统的闪存设备和文件系统学习纪要
  • android 8.1 disable unsupported sensor