mirror of
https://github.com/aicodix/code.git
synced 2026-04-27 14:30:36 +00:00
compute erasure probability from code rate
This commit is contained in:
parent
72e5b2240a
commit
c797ad2fda
4 changed files with 21 additions and 20 deletions
|
|
@ -20,6 +20,7 @@ Copyright 2025 Ahmet Inan <inan@aicodix.de>
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
|
double R = 0.5;
|
||||||
const int MAX_M = 8;
|
const int MAX_M = 8;
|
||||||
const int MAX_N = 1 << MAX_M;
|
const int MAX_N = 1 << MAX_M;
|
||||||
const int M = 7;
|
const int M = 7;
|
||||||
|
|
@ -27,6 +28,7 @@ int main()
|
||||||
const bool crc_aided = true;
|
const bool crc_aided = true;
|
||||||
CODE::CRC<uint8_t> crc(0xD9);
|
CODE::CRC<uint8_t> crc(0xD9);
|
||||||
const int C = 8;
|
const int C = 8;
|
||||||
|
int K = R * N + crc_aided * C;
|
||||||
#if 1
|
#if 1
|
||||||
const int L = 64;
|
const int L = 64;
|
||||||
typedef int8_t code_type;
|
typedef int8_t code_type;
|
||||||
|
|
@ -43,8 +45,7 @@ int main()
|
||||||
auto data = std::bind(distribution(0, 1), generator(rd()));
|
auto data = std::bind(distribution(0, 1), generator(rd()));
|
||||||
auto codeword = new code_type[N];
|
auto codeword = new code_type[N];
|
||||||
|
|
||||||
double erasure_probability = 0.5;
|
double erasure_probability = 1 - R;
|
||||||
int K = (1 - erasure_probability) * N + crc_aided * C;
|
|
||||||
double design_SNR = 10 * std::log10(-std::log(erasure_probability));
|
double design_SNR = 10 * std::log10(-std::log(erasure_probability));
|
||||||
std::cerr << "design SNR: " << design_SNR << std::endl;
|
std::cerr << "design SNR: " << design_SNR << std::endl;
|
||||||
auto construct = new CODE::ReedMullerSequence<MAX_M>;
|
auto construct = new CODE::ReedMullerSequence<MAX_M>;
|
||||||
|
|
@ -177,13 +178,12 @@ int main()
|
||||||
count = 0;
|
count = 0;
|
||||||
|
|
||||||
int MOD_BITS = 1; // BPSK
|
int MOD_BITS = 1; // BPSK
|
||||||
double code_rate = (double)(K - crc_aided * C) / (double)N;
|
double spectral_efficiency = R * MOD_BITS;
|
||||||
double spectral_efficiency = code_rate * MOD_BITS;
|
|
||||||
double EbN0 = 10 * std::log10(sigma_signal * sigma_signal / (spectral_efficiency * 2 * sigma_noise * sigma_noise));
|
double EbN0 = 10 * std::log10(sigma_signal * sigma_signal / (spectral_efficiency * 2 * sigma_noise * sigma_noise));
|
||||||
|
|
||||||
if (0) {
|
if (0) {
|
||||||
std::cerr << SNR << " Es/N0 => AWGN with standard deviation of " << sigma_noise << " and mean " << mean_noise << std::endl;
|
std::cerr << SNR << " Es/N0 => AWGN with standard deviation of " << sigma_noise << " and mean " << mean_noise << std::endl;
|
||||||
std::cerr << EbN0 << " Eb/N0, using spectral efficiency of " << spectral_efficiency << " from " << code_rate << " code rate and " << MOD_BITS << " bits per symbol." << std::endl;
|
std::cerr << EbN0 << " Eb/N0, using spectral efficiency of " << spectral_efficiency << " from " << R << " code rate and " << MOD_BITS << " bits per symbol." << std::endl;
|
||||||
std::cerr << awgn_errors << " errors caused by AWGN." << std::endl;
|
std::cerr << awgn_errors << " errors caused by AWGN." << std::endl;
|
||||||
std::cerr << quantization_erasures << " erasures caused by quantization." << std::endl;
|
std::cerr << quantization_erasures << " erasures caused by quantization." << std::endl;
|
||||||
std::cerr << uncorrected_errors << " errors uncorrected." << std::endl;
|
std::cerr << uncorrected_errors << " errors uncorrected." << std::endl;
|
||||||
|
|
|
||||||
|
|
@ -26,12 +26,14 @@ bool get_bit(const uint32_t *bits, int idx)
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
|
double R = 0.7;
|
||||||
const int M = 10;
|
const int M = 10;
|
||||||
const int N = 1 << M;
|
const int N = 1 << M;
|
||||||
const bool systematic = false;
|
const bool systematic = false;
|
||||||
const bool crc_aided = true;
|
const bool crc_aided = true;
|
||||||
CODE::CRC<uint32_t> crc(0xD419CC15);
|
CODE::CRC<uint32_t> crc(0xD419CC15);
|
||||||
const int C = 32;
|
const int C = 32;
|
||||||
|
int K = R * N + crc_aided * C;
|
||||||
#if 1
|
#if 1
|
||||||
const int L = 32;
|
const int L = 32;
|
||||||
typedef int8_t code_type;
|
typedef int8_t code_type;
|
||||||
|
|
@ -50,8 +52,7 @@ int main()
|
||||||
auto codeword = new code_type[N];
|
auto codeword = new code_type[N];
|
||||||
auto temp = new simd_type[N];
|
auto temp = new simd_type[N];
|
||||||
|
|
||||||
double erasure_probability = 0.3;
|
double erasure_probability = 1 - R;
|
||||||
int K = (1 - erasure_probability) * N + crc_aided * C;
|
|
||||||
double design_SNR = 10 * std::log10(-std::log(erasure_probability));
|
double design_SNR = 10 * std::log10(-std::log(erasure_probability));
|
||||||
std::cerr << "design SNR: " << design_SNR << std::endl;
|
std::cerr << "design SNR: " << design_SNR << std::endl;
|
||||||
for (int i = 0; i < N / 32; ++i)
|
for (int i = 0; i < N / 32; ++i)
|
||||||
|
|
@ -213,13 +214,12 @@ int main()
|
||||||
count = 0;
|
count = 0;
|
||||||
|
|
||||||
int MOD_BITS = 1; // BPSK
|
int MOD_BITS = 1; // BPSK
|
||||||
double code_rate = (double)(K - crc_aided * C) / (double)N;
|
double spectral_efficiency = R * MOD_BITS;
|
||||||
double spectral_efficiency = code_rate * MOD_BITS;
|
|
||||||
double EbN0 = 10 * std::log10(sigma_signal * sigma_signal / (spectral_efficiency * 2 * sigma_noise * sigma_noise));
|
double EbN0 = 10 * std::log10(sigma_signal * sigma_signal / (spectral_efficiency * 2 * sigma_noise * sigma_noise));
|
||||||
|
|
||||||
if (0) {
|
if (0) {
|
||||||
std::cerr << SNR << " Es/N0 => AWGN with standard deviation of " << sigma_noise << " and mean " << mean_noise << std::endl;
|
std::cerr << SNR << " Es/N0 => AWGN with standard deviation of " << sigma_noise << " and mean " << mean_noise << std::endl;
|
||||||
std::cerr << EbN0 << " Eb/N0, using spectral efficiency of " << spectral_efficiency << " from " << code_rate << " code rate and " << MOD_BITS << " bits per symbol." << std::endl;
|
std::cerr << EbN0 << " Eb/N0, using spectral efficiency of " << spectral_efficiency << " from " << R << " code rate and " << MOD_BITS << " bits per symbol." << std::endl;
|
||||||
std::cerr << awgn_errors << " errors caused by AWGN." << std::endl;
|
std::cerr << awgn_errors << " errors caused by AWGN." << std::endl;
|
||||||
std::cerr << quantization_erasures << " erasures caused by quantization." << std::endl;
|
std::cerr << quantization_erasures << " erasures caused by quantization." << std::endl;
|
||||||
std::cerr << uncorrected_errors << " errors uncorrected." << std::endl;
|
std::cerr << uncorrected_errors << " errors uncorrected." << std::endl;
|
||||||
|
|
|
||||||
|
|
@ -25,12 +25,14 @@ bool get_bit(const uint32_t *bits, int idx)
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
|
double R = 0.7;
|
||||||
const int M = 10;
|
const int M = 10;
|
||||||
const int N = 1 << M;
|
const int N = 1 << M;
|
||||||
const bool crc_aided = true;
|
const bool crc_aided = true;
|
||||||
CODE::CRC<uint32_t> crc(0xD419CC15);
|
CODE::CRC<uint32_t> crc(0xD419CC15);
|
||||||
const int C = 32;
|
const int C = 32;
|
||||||
const int S = 32;
|
const int S = 32;
|
||||||
|
int K = R * N + crc_aided * C;
|
||||||
#if 1
|
#if 1
|
||||||
const int L = 32;
|
const int L = 32;
|
||||||
typedef int8_t code_type;
|
typedef int8_t code_type;
|
||||||
|
|
@ -48,8 +50,7 @@ int main()
|
||||||
auto frozen = new uint32_t[N/32];
|
auto frozen = new uint32_t[N/32];
|
||||||
auto codeword = new code_type[N];
|
auto codeword = new code_type[N];
|
||||||
|
|
||||||
double erasure_probability = 0.3;
|
double erasure_probability = 1 - R;
|
||||||
int K = (1 - erasure_probability) * N + crc_aided * C;
|
|
||||||
double design_SNR = 10 * std::log10(-std::log(erasure_probability));
|
double design_SNR = 10 * std::log10(-std::log(erasure_probability));
|
||||||
std::cerr << "design SNR: " << design_SNR << std::endl;
|
std::cerr << "design SNR: " << design_SNR << std::endl;
|
||||||
for (int i = 0; i < N / 32; ++i)
|
for (int i = 0; i < N / 32; ++i)
|
||||||
|
|
@ -81,6 +82,7 @@ int main()
|
||||||
if (!crc_aided)
|
if (!crc_aided)
|
||||||
F += S;
|
F += S;
|
||||||
K -= P;
|
K -= P;
|
||||||
|
R = (double)(K - crc_aided * C) / (double)N;
|
||||||
std::cerr << "Polar(" << N << ", " << K << ")" << std::endl;
|
std::cerr << "Polar(" << N << ", " << K << ")" << std::endl;
|
||||||
auto message = new code_type[K];
|
auto message = new code_type[K];
|
||||||
auto decoded = new simd_type[K];
|
auto decoded = new simd_type[K];
|
||||||
|
|
@ -200,13 +202,12 @@ int main()
|
||||||
count = 0;
|
count = 0;
|
||||||
|
|
||||||
int MOD_BITS = 1; // BPSK
|
int MOD_BITS = 1; // BPSK
|
||||||
double code_rate = (double)(K - crc_aided * C) / (double)N;
|
double spectral_efficiency = R * MOD_BITS;
|
||||||
double spectral_efficiency = code_rate * MOD_BITS;
|
|
||||||
double EbN0 = 10 * std::log10(sigma_signal * sigma_signal / (spectral_efficiency * 2 * sigma_noise * sigma_noise));
|
double EbN0 = 10 * std::log10(sigma_signal * sigma_signal / (spectral_efficiency * 2 * sigma_noise * sigma_noise));
|
||||||
|
|
||||||
if (0) {
|
if (0) {
|
||||||
std::cerr << SNR << " Es/N0 => AWGN with standard deviation of " << sigma_noise << " and mean " << mean_noise << std::endl;
|
std::cerr << SNR << " Es/N0 => AWGN with standard deviation of " << sigma_noise << " and mean " << mean_noise << std::endl;
|
||||||
std::cerr << EbN0 << " Eb/N0, using spectral efficiency of " << spectral_efficiency << " from " << code_rate << " code rate and " << MOD_BITS << " bits per symbol." << std::endl;
|
std::cerr << EbN0 << " Eb/N0, using spectral efficiency of " << spectral_efficiency << " from " << R << " code rate and " << MOD_BITS << " bits per symbol." << std::endl;
|
||||||
std::cerr << awgn_errors << " errors caused by AWGN." << std::endl;
|
std::cerr << awgn_errors << " errors caused by AWGN." << std::endl;
|
||||||
std::cerr << quantization_erasures << " erasures caused by quantization." << std::endl;
|
std::cerr << quantization_erasures << " erasures caused by quantization." << std::endl;
|
||||||
std::cerr << uncorrected_errors << " errors uncorrected." << std::endl;
|
std::cerr << uncorrected_errors << " errors uncorrected." << std::endl;
|
||||||
|
|
|
||||||
|
|
@ -25,9 +25,11 @@ bool get_bit(const uint32_t *bits, int idx)
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
|
double R = 2. / 3.;
|
||||||
const int M = 20;
|
const int M = 20;
|
||||||
const int N = 1 << M;
|
const int N = 1 << M;
|
||||||
const bool systematic = true;
|
const bool systematic = true;
|
||||||
|
int K = R * N;
|
||||||
#if 1
|
#if 1
|
||||||
typedef int8_t code_type;
|
typedef int8_t code_type;
|
||||||
#else
|
#else
|
||||||
|
|
@ -42,8 +44,7 @@ int main()
|
||||||
auto codeword = new code_type[N];
|
auto codeword = new code_type[N];
|
||||||
auto temp = new code_type[N];
|
auto temp = new code_type[N];
|
||||||
|
|
||||||
double erasure_probability = 1. / 3.;
|
double erasure_probability = 1 - R;
|
||||||
int K = (1 - erasure_probability) * N;
|
|
||||||
double design_SNR = 10 * std::log10(-std::log(erasure_probability));
|
double design_SNR = 10 * std::log10(-std::log(erasure_probability));
|
||||||
std::cerr << "design SNR: " << design_SNR << std::endl;
|
std::cerr << "design SNR: " << design_SNR << std::endl;
|
||||||
double better_SNR = design_SNR + 0.5;//1.59175;
|
double better_SNR = design_SNR + 0.5;//1.59175;
|
||||||
|
|
@ -164,13 +165,12 @@ int main()
|
||||||
count = 0;
|
count = 0;
|
||||||
|
|
||||||
int MOD_BITS = 1; // BPSK
|
int MOD_BITS = 1; // BPSK
|
||||||
double code_rate = (double)K / (double)N;
|
double spectral_efficiency = R * MOD_BITS;
|
||||||
double spectral_efficiency = code_rate * MOD_BITS;
|
|
||||||
double EbN0 = 10 * std::log10(sigma_signal * sigma_signal / (spectral_efficiency * 2 * sigma_noise * sigma_noise));
|
double EbN0 = 10 * std::log10(sigma_signal * sigma_signal / (spectral_efficiency * 2 * sigma_noise * sigma_noise));
|
||||||
|
|
||||||
if (0) {
|
if (0) {
|
||||||
std::cerr << SNR << " Es/N0 => AWGN with standard deviation of " << sigma_noise << " and mean " << mean_noise << std::endl;
|
std::cerr << SNR << " Es/N0 => AWGN with standard deviation of " << sigma_noise << " and mean " << mean_noise << std::endl;
|
||||||
std::cerr << EbN0 << " Eb/N0, using spectral efficiency of " << spectral_efficiency << " from " << code_rate << " code rate and " << MOD_BITS << " bits per symbol." << std::endl;
|
std::cerr << EbN0 << " Eb/N0, using spectral efficiency of " << spectral_efficiency << " from " << R << " code rate and " << MOD_BITS << " bits per symbol." << std::endl;
|
||||||
std::cerr << awgn_errors << " errors caused by AWGN." << std::endl;
|
std::cerr << awgn_errors << " errors caused by AWGN." << std::endl;
|
||||||
std::cerr << quantization_erasures << " erasures caused by quantization." << std::endl;
|
std::cerr << quantization_erasures << " erasures caused by quantization." << std::endl;
|
||||||
std::cerr << uncorrected_errors << " errors uncorrected." << std::endl;
|
std::cerr << uncorrected_errors << " errors uncorrected." << std::endl;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue