From c797ad2fdafb54eeb2ea7135886f4414a155353e Mon Sep 17 00:00:00 2001 From: Ahmet Inan Date: Fri, 13 Feb 2026 15:40:56 +0100 Subject: [PATCH] compute erasure probability from code rate --- tests/pac_list_regression_test.cc | 10 +++++----- tests/polar_list_regression_test.cc | 10 +++++----- tests/polar_parity_regression_test.cc | 11 ++++++----- tests/polar_regression_test.cc | 10 +++++----- 4 files changed, 21 insertions(+), 20 deletions(-) diff --git a/tests/pac_list_regression_test.cc b/tests/pac_list_regression_test.cc index da3128f..c92eeca 100644 --- a/tests/pac_list_regression_test.cc +++ b/tests/pac_list_regression_test.cc @@ -20,6 +20,7 @@ Copyright 2025 Ahmet Inan int main() { + double R = 0.5; const int MAX_M = 8; const int MAX_N = 1 << MAX_M; const int M = 7; @@ -27,6 +28,7 @@ int main() const bool crc_aided = true; CODE::CRC crc(0xD9); const int C = 8; + int K = R * N + crc_aided * C; #if 1 const int L = 64; typedef int8_t code_type; @@ -43,8 +45,7 @@ int main() auto data = std::bind(distribution(0, 1), generator(rd())); auto codeword = new code_type[N]; - double erasure_probability = 0.5; - int K = (1 - erasure_probability) * N + crc_aided * C; + double erasure_probability = 1 - R; double design_SNR = 10 * std::log10(-std::log(erasure_probability)); std::cerr << "design SNR: " << design_SNR << std::endl; auto construct = new CODE::ReedMullerSequence; @@ -177,13 +178,12 @@ int main() count = 0; int MOD_BITS = 1; // BPSK - double code_rate = (double)(K - crc_aided * C) / (double)N; - double spectral_efficiency = code_rate * MOD_BITS; + double spectral_efficiency = R * MOD_BITS; double EbN0 = 10 * std::log10(sigma_signal * sigma_signal / (spectral_efficiency * 2 * sigma_noise * sigma_noise)); if (0) { 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 << quantization_erasures << " erasures caused by quantization." << std::endl; std::cerr << uncorrected_errors << " errors uncorrected." << std::endl; diff --git a/tests/polar_list_regression_test.cc b/tests/polar_list_regression_test.cc index 0f53de3..e1fd820 100644 --- a/tests/polar_list_regression_test.cc +++ b/tests/polar_list_regression_test.cc @@ -26,12 +26,14 @@ bool get_bit(const uint32_t *bits, int idx) int main() { + double R = 0.7; const int M = 10; const int N = 1 << M; const bool systematic = false; const bool crc_aided = true; CODE::CRC crc(0xD419CC15); const int C = 32; + int K = R * N + crc_aided * C; #if 1 const int L = 32; typedef int8_t code_type; @@ -50,8 +52,7 @@ int main() auto codeword = new code_type[N]; auto temp = new simd_type[N]; - double erasure_probability = 0.3; - int K = (1 - erasure_probability) * N + crc_aided * C; + double erasure_probability = 1 - R; double design_SNR = 10 * std::log10(-std::log(erasure_probability)); std::cerr << "design SNR: " << design_SNR << std::endl; for (int i = 0; i < N / 32; ++i) @@ -213,13 +214,12 @@ int main() count = 0; int MOD_BITS = 1; // BPSK - double code_rate = (double)(K - crc_aided * C) / (double)N; - double spectral_efficiency = code_rate * MOD_BITS; + double spectral_efficiency = R * MOD_BITS; double EbN0 = 10 * std::log10(sigma_signal * sigma_signal / (spectral_efficiency * 2 * sigma_noise * sigma_noise)); if (0) { 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 << quantization_erasures << " erasures caused by quantization." << std::endl; std::cerr << uncorrected_errors << " errors uncorrected." << std::endl; diff --git a/tests/polar_parity_regression_test.cc b/tests/polar_parity_regression_test.cc index 26b5f0f..2a519f9 100644 --- a/tests/polar_parity_regression_test.cc +++ b/tests/polar_parity_regression_test.cc @@ -25,12 +25,14 @@ bool get_bit(const uint32_t *bits, int idx) int main() { + double R = 0.7; const int M = 10; const int N = 1 << M; const bool crc_aided = true; CODE::CRC crc(0xD419CC15); const int C = 32; const int S = 32; + int K = R * N + crc_aided * C; #if 1 const int L = 32; typedef int8_t code_type; @@ -48,8 +50,7 @@ int main() auto frozen = new uint32_t[N/32]; auto codeword = new code_type[N]; - double erasure_probability = 0.3; - int K = (1 - erasure_probability) * N + crc_aided * C; + double erasure_probability = 1 - R; double design_SNR = 10 * std::log10(-std::log(erasure_probability)); std::cerr << "design SNR: " << design_SNR << std::endl; for (int i = 0; i < N / 32; ++i) @@ -81,6 +82,7 @@ int main() if (!crc_aided) F += S; K -= P; + R = (double)(K - crc_aided * C) / (double)N; std::cerr << "Polar(" << N << ", " << K << ")" << std::endl; auto message = new code_type[K]; auto decoded = new simd_type[K]; @@ -200,13 +202,12 @@ int main() count = 0; int MOD_BITS = 1; // BPSK - double code_rate = (double)(K - crc_aided * C) / (double)N; - double spectral_efficiency = code_rate * MOD_BITS; + double spectral_efficiency = R * MOD_BITS; double EbN0 = 10 * std::log10(sigma_signal * sigma_signal / (spectral_efficiency * 2 * sigma_noise * sigma_noise)); if (0) { 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 << quantization_erasures << " erasures caused by quantization." << std::endl; std::cerr << uncorrected_errors << " errors uncorrected." << std::endl; diff --git a/tests/polar_regression_test.cc b/tests/polar_regression_test.cc index faf4e8f..776386c 100644 --- a/tests/polar_regression_test.cc +++ b/tests/polar_regression_test.cc @@ -25,9 +25,11 @@ bool get_bit(const uint32_t *bits, int idx) int main() { + double R = 2. / 3.; const int M = 20; const int N = 1 << M; const bool systematic = true; + int K = R * N; #if 1 typedef int8_t code_type; #else @@ -42,8 +44,7 @@ int main() auto codeword = new code_type[N]; auto temp = new code_type[N]; - double erasure_probability = 1. / 3.; - int K = (1 - erasure_probability) * N; + double erasure_probability = 1 - R; double design_SNR = 10 * std::log10(-std::log(erasure_probability)); std::cerr << "design SNR: " << design_SNR << std::endl; double better_SNR = design_SNR + 0.5;//1.59175; @@ -164,13 +165,12 @@ int main() count = 0; int MOD_BITS = 1; // BPSK - double code_rate = (double)K / (double)N; - double spectral_efficiency = code_rate * MOD_BITS; + double spectral_efficiency = R * MOD_BITS; double EbN0 = 10 * std::log10(sigma_signal * sigma_signal / (spectral_efficiency * 2 * sigma_noise * sigma_noise)); if (0) { 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 << quantization_erasures << " erasures caused by quantization." << std::endl; std::cerr << uncorrected_errors << " errors uncorrected." << std::endl;