compute erasure probability from code rate

This commit is contained in:
Ahmet Inan 2026-02-13 15:40:56 +01:00
commit c797ad2fda
4 changed files with 21 additions and 20 deletions

View file

@ -20,6 +20,7 @@ Copyright 2025 Ahmet Inan <inan@aicodix.de>
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<uint8_t> 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<MAX_M>;
@ -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;

View file

@ -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<uint32_t> 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;

View file

@ -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<uint32_t> 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;

View file

@ -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;