| Title: | Quantum Computing for Analyzing CD4 Lymphocytes and Antiretroviral Therapy |
|---|---|
| Description: | Resources, tutorials, and code snippets dedicated to exploring the intersection of quantum computing and artificial intelligence (AI) in the context of analyzing Cluster of Differentiation 4 (CD4) lymphocytes and optimizing antiretroviral therapy (ART) for human immunodeficiency virus (HIV). With the emergence of quantum artificial intelligence and the development of small-scale quantum computers, there's an unprecedented opportunity to revolutionize the understanding of HIV dynamics and treatment strategies. This project leverages a quantum computer simulator, to explore these applications in quantum computing techniques, addressing the challenges in studying CD4 lymphocytes and enhancing ART efficacy. |
| Authors: | Juan Pablo Acuña González [aut, cre, cph] (ORCID: <https://orcid.org/0009-0003-6029-6560>) |
| Maintainer: | Juan Pablo Acuña González <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.0.6 |
| Built: | 2026-06-07 10:38:36 UTC |
| Source: | https://github.com/juan-acu/qvirus |
Contains longitudinal measurements of CD4 lymphocyte counts for 176 patients living with HIV, recorded over the period from 2018 to 2024. CD4 counts are a critical indicator of immune function, used to monitor the progression of HIV and the effectiveness of treatments. Measurements were taken at various points throughout the study, with some missing values due to unavailable data for specific patients at certain times.
cd_3cd_3
A data frame with 176 rows and 18 variables:
Unique identifier for each patient.
CD4 count for the first measurement in 2018.
CD4 count for the second measurement in 2018.
CD4 count for the first measurement in 2019.
CD4 count for the second measurement in 2019.
CD4 count for the first measurement in 2020.
CD4 count for the first measurement in 2021.
CD4 count for the second measurement in 2021.
CD4 count for the third measurement in 2021.
CD4 count for the first measurement in 2022.
CD4 count for the second measurement in 2022.
CD4 count for the third measurement in 2022.
CD4 count for the first measurement in 2023.
CD4 count for the second measurement in 2023.
CD4 count for the third measurement in 2023.
CD4 count for the first measurement in 2024.
CD4 count for the second measurement in 2024.
CD4 count for the third measurement in 2024.
. CD4 counts are used to monitor immune system health in individuals with HIV. A lower CD4 count often indicates a weakened immune system, whereas higher counts suggest a stronger immune response. Some values are missing, indicating no measurement was taken for a particular patient at that time.
Clinical data from Hospital Vicente Guerrero, IMSS, HIV Clinic.
# Load the dataset data(cd_3) # Summarize CD4 counts for the year 2021 summary(cd_3[, c("cd_2021_1", "cd_2021_2", "cd_2021_3")])# Load the dataset data(cd_3) # Summarize CD4 counts for the year 2021 summary(cd_3[, c("cd_2021_1", "cd_2021_2", "cd_2021_3")])
This function calculates the mean differences of CD4 counts across time for each individual in the dataset.
cd_diff(cd_data)cd_diff(cd_data)
cd_data |
A data frame of longitudinal CD4 count values per individual, where rows represent patients and columns represent sequential measurements across time (e.g., years or visits). |
An object of class "Interaction" with the following components:
Mean differences of raw CD4 count values.
data(cd_3) cd_data <- cd_3[,-1] result <- cd_diff(cd_data)data(cd_3) cd_data <- cd_3[,-1] result <- cd_diff(cd_data)
This function calculates the mean standardized differences of CD4 counts across time for each individual in the dataset.
cds_diff(cd_data)cds_diff(cd_data)
cd_data |
A data frame of longitudinal CD4 count values per individual, where rows represent patients and columns represent sequential measurements across time (e.g., years or visits). |
An object of class "Interaction" with the following components:
Mean standardized differences of raw CD4 count values.
data(cd_3) cd_data <- cd_3[,-1] result <- cds_diff(cd_data)data(cd_3) cd_data <- cd_3[,-1] result <- cds_diff(cd_data)
A numeric data frame containing a curated panel of biomarkers used to estimate correlation-driven coefficients for a variational Hamiltonian in a 3-qubit quantum model.
data(data_corr)data(data_corr)
A data frame with 12 rows and 30 variables:
Amino acid metabolism biomarker.
Nucleotide metabolism enzyme.
Adenosine kinase (nucleotide metabolism).
Chemokine involved in immune signaling.
Inflammatory chemokine.
Immune signaling chemokine.
Innate immune receptor.
Macrophage activation marker.
Urea cycle enzyme.
Lysosomal protease.
Cathepsin L (antigen processing).
Fumarylacetoacetate hydrolase.
Fatty acid synthase.
Beta-oxidation enzyme.
Hexokinase 2 (glycolysis).
Tryptophan metabolism enzyme.
Inflammatory cytokine.
Purine biosynthesis enzyme.
T-cell activation linker protein.
Lactate dehydrogenase B.
Leukotriene synthesis enzyme.
Metal regulatory transcription factor.
Ecto-5'-nucleotidase.
Pyruvate kinase (glycolysis).
Prostaglandin synthesis enzyme.
Cyclooxygenase-2 (inflammation).
mTOR pathway regulator.
Tryptophan metabolism enzyme.
Zinc finger transcription factor.
Zinc finger regulatory protein.
The Hamiltonian is defined as:
where:
are Pauli strings from the 3-qubit Pauli group
are coefficients estimated via Pearson correlation
between selected biomarkers
The biomarkers in data_corr are grouped into biological axes:
Amino Acid Metabolism: IDO1, TDO2, ACMSD, CPS1, FAH
Immune Signaling: IL6, CCL4, CCL5, CCL13, NT5E
Antigen Processing: CD14, CD163, LAT, CTSL, CTSD
Fatty Acid / Lipid: HADH, FASN, LTC4S, PTGS2, PTGES
Aerobic / Nucleotide: LDHB, PKM, IMPDH2, ADA, ADK, HK2
Regulatory / Epigenetic: ZNF93, MTF1, RPTOR, ZNF708, CAD
These features define a high-dimensional correlation structure used to construct patient-specific or cohort-level Hamiltonians.
Brown, A. J., et al. (2024). Metabolic reprogramming of human macrophages during Mycobacterium tuberculosis infection under HIV exposure. Gene Expression Omnibus (GEO), accession GSE314344. Baluku, J. B., et al. (2023). DNA methylation profiling of people living with HIV stratified by tuberculosis status. Gene Expression Omnibus (GEO), accession GSE304107.
data(data_corr) dim(data_corr)data(data_corr) dim(data_corr)
A numeric data frame containing patient-level biomarker expression values used for angle encoding into a 3-qubit quantum state. Each row corresponds to a sample (patient), and each column corresponds to a biomarker mapped to a rotation angle in the quantum circuit.
data(data_enc)data(data_enc)
A data frame with 12 rows and 6 variables:
Expression level of CD14 (innate immune receptor; phi2 angle).
Expression level of HADH (beta-oxidation marker; theta3 angle).
Expression level of IDO1 (tryptophan metabolism; phi1 angle).
Expression level of IL6 (inflammatory signaling; theta1 angle).
Expression level of LDHB (glycolytic flux; phi3 angle).
Expression level of TDO2 (systemic metabolic repression; theta2 angle).
The encoding follows a 3-qubit angle encoding scheme:
where each qubit is parameterized by two biomarkers:
Qubit 1: IL6 (), IDO1 ()
Qubit 2: TDO2 (), CD14 ()
Qubit 3: HADH (), LDHB ()
These biomarkers capture key immunometabolic axes, including inflammation, tryptophan metabolism, innate immune sensing, and metabolic reprogramming.
Prior to encoding, values are typically normalized to angular ranges
(e.g., ) using dataset-specific min–max scaling.
Brown, A. J., et al. (2024). Metabolic reprogramming of human macrophages during Mycobacterium tuberculosis infection under HIV exposure. Gene Expression Omnibus (GEO), accession GSE314344. Baluku, J. B., et al. (2023). DNA methylation profiling of people living with HIV stratified by tuberculosis status. Gene Expression Omnibus (GEO), accession GSE304107.
data(data_enc) str(data_enc)data(data_enc) str(data_enc)
This function estimates the payoff parameters for HIV phenotype interactions based on the provided classification object and predictions from a viral load model. It calculates the mean differences in viral loads and CD4 counts, as well as the average payoffs for each classification.
estimate_payoffs(object, predictions)estimate_payoffs(object, predictions)
object |
An object of class |
predictions |
A |
set.seed(42) data(cd_3) cd_data <- cd_3[,-1] cd_result <- cds_diff(cd_data) data(vl_3) vl_data <- vl_3[,-1] vl_result <- vlogs_diff(vl_data) result <- InteractionClassification(cd_result = cd_result, vl_result = vl_result) data(preds) payoffs_results <- estimate_payoffs(result, preds)set.seed(42) data(cd_3) cd_data <- cd_3[,-1] cd_result <- cds_diff(cd_data) data(vl_3) vl_data <- vl_3[,-1] vl_result <- vlogs_diff(vl_data) result <- InteractionClassification(cd_result = cd_result, vl_result = vl_result) data(preds) payoffs_results <- estimate_payoffs(result, preds)
This function performs k-means clustering on the differences in viral load and CD4 counts
to classify interaction types between HIV phenotypes. It returns an object of class
InteractionClassification, a data.frame with classification labels.
InteractionClassification(cd_result, vl_result, k = 4, ns = 100, seed = 123)InteractionClassification(cd_result, vl_result, k = 4, ns = 100, seed = 123)
cd_result |
A numeric vector of differences in CD4 T-cell counts. |
vl_result |
A numeric vector of differences in log viral load. |
k |
Integer. The number of clusters to use in k-means. Default is 4. |
ns |
Integer. Number of random initializations for the k-means algorithm. Default is 100. |
seed |
Integer. Seed for random number generation to ensure reproducibility. Default is 123. |
A data.frame of class InteractionClassification with three columns:
The CD4 count difference for each interaction.
The viral load difference (log scale) for each interaction.
An integer label (1 to k) indicating the interaction cluster.
set.seed(42) data(cd_3) cd_data <- cd_3[,-1] cd_result <- cds_diff(cd_data) data(vl_3) vl_data <- vl_3[,-1] vl_result <- vlogs_diff(vl_data) result <- InteractionClassification(cd_result = cd_result, vl_result = vl_result)set.seed(42) data(cd_3) cd_data <- cd_3[,-1] cd_result <- cds_diff(cd_data) data(vl_3) vl_data <- vl_3[,-1] vl_result <- vlogs_diff(vl_data) result <- InteractionClassification(cd_result = cd_result, vl_result = vl_result)
Mean squared errors (MSE) for viral load differences and CD4 count differences by comparing the actual values with the group means from the classification.
Computes the mean squared error (MSE) between observed CD4 and viral load differences and their corresponding predicted payoff values within each interaction classification.
mse(object, ...) mse(object, ...)mse(object, ...) mse(object, ...)
object |
An object of class |
... |
Additional arguments passed to other methods (currently not used). |
A data.frame containing the MSE for CD4 count differences (mse_cds_diff)
and (mse_vlogs_diff) for viral load differences.
set.seed(42) data(cd_3) cd_data <- cd_3[,-1] cd_result <- cds_diff(cd_data) data(vl_3) vl_data <- vl_3[,-1] vl_result <- vlogs_diff(vl_data) result <- InteractionClassification(cd_result = cd_result, vl_result = vl_result) mse(result) set.seed(42) data(cd_3) cd_data <- cd_3[,-1] cd_result <- cds_diff(cd_data) data(vl_3) vl_data <- vl_3[,-1] vl_result <- vlogs_diff(vl_data) result <- InteractionClassification(cd_result = cd_result, vl_result = vl_result) data(preds) payoffs_results <- estimate_payoffs(result, preds) mse(payoffs_results)set.seed(42) data(cd_3) cd_data <- cd_3[,-1] cd_result <- cds_diff(cd_data) data(vl_3) vl_data <- vl_3[,-1] vl_result <- vlogs_diff(vl_data) result <- InteractionClassification(cd_result = cd_result, vl_result = vl_result) mse(result) set.seed(42) data(cd_3) cd_data <- cd_3[,-1] cd_result <- cds_diff(cd_data) data(vl_3) vl_data <- vl_3[,-1] vl_result <- vlogs_diff(vl_data) result <- InteractionClassification(cd_result = cd_result, vl_result = vl_result) data(preds) payoffs_results <- estimate_payoffs(result, preds) mse(payoffs_results)
Mean squared errors (MSE) for viral load differences and CD4 count differences by comparing the actual values with the group means from the classification.
## S3 method for class 'InteractionClassification' mse(object, ...)## S3 method for class 'InteractionClassification' mse(object, ...)
object |
An object of class |
... |
Additional arguments passed to other methods (currently not used). |
Computes the mean squared error (MSE) between observed CD4 and viral load differences and their corresponding predicted payoff values within each interaction classification.
## S3 method for class 'payoffs' mse(object, ...)## S3 method for class 'payoffs' mse(object, ...)
object |
An object of class |
... |
Additional arguments passed to other methods (currently not used). |
This function computes the nearest simulated payoff from a given list of payoffs based on a viral load difference (vl_diff). It returns both the nearest payoff value and its corresponding payoff name.
nearest_payoff(vl_diff, payoffs_list)nearest_payoff(vl_diff, payoffs_list)
vl_diff |
Numeric value representing the viral load difference for which the nearest payoff will be found. |
payoffs_list |
A named list of payoff values, where the names correspond to specific payoffs and the values are the associated payoff values. |
I <- diag(2) H <- 1 / sqrt(2) * matrix(c(1, 1, 1, -1), 2, 2) Z <- diag(c(1, -1)) gates <- list(I = I, H = H, Z = Z) alpha <- 0.3; beta <- 0.1; gamma <- 0.5; theta <- 0.2 alpha2 <- 0.35; beta2 <- 0.15; gamma2 <- 0.6; theta2 <- 0.25 pays <- payoffs_list(gates, alpha, beta, gamma, theta, alpha2, beta2, gamma2, theta2) nearest_payoff(-0.2, pays)I <- diag(2) H <- 1 / sqrt(2) * matrix(c(1, 1, 1, -1), 2, 2) Z <- diag(c(1, -1)) gates <- list(I = I, H = H, Z = Z) alpha <- 0.3; beta <- 0.1; gamma <- 0.5; theta <- 0.2 alpha2 <- 0.35; beta2 <- 0.15; gamma2 <- 0.6; theta2 <- 0.25 pays <- payoffs_list(gates, alpha, beta, gamma, theta, alpha2, beta2, gamma2, theta2) nearest_payoff(-0.2, pays)
Computes payoff values for all pairwise combinations of quantum gate strategies provided in
a named list. For each pair, the function calculates the payoffs for both phenotypes v and V
using two different sets of payoff parameters.
payoffs_list(gates, alpha, beta, gamma, theta, alpha2, beta2, gamma2, theta2)payoffs_list(gates, alpha, beta, gamma, theta, alpha2, beta2, gamma2, theta2)
gates |
A named list of 2x2 unitary matrices representing quantum strategies (e.g., I, H, Z). |
alpha |
Numeric scalar, payoff coefficient for phenotype |
beta |
Numeric scalar, payoff coefficient for phenotype |
gamma |
Numeric scalar, payoff coefficient for phenotype |
theta |
Numeric scalar, payoff coefficient for phenotype |
alpha2 |
Numeric scalar, alternate value of |
beta2 |
Numeric scalar, alternate value of |
gamma2 |
Numeric scalar, alternate value of |
theta2 |
Numeric scalar, alternate value of |
I <- diag(2) H <- 1 / sqrt(2) * matrix(c(1, 1, 1, -1), 2, 2) Z <- diag(c(1, -1)) gates <- list(I = I, H = H, Z = Z) payoffs <- payoffs_list(gates, 1, 0.5, 0.3,0.2, 1.5, 0.6, 0.7, 0.8)I <- diag(2) H <- 1 / sqrt(2) * matrix(c(1, 1, 1, -1), 2, 2) Z <- diag(c(1, -1)) gates <- list(I = I, H = H, Z = Z) payoffs <- payoffs_list(gates, 1, 0.5, 0.3,0.2, 1.5, 0.6, 0.7, 0.8)
This function calculates the final quantum state and expected payoffs for two players in a quantum game based on their strategies. The function uses quantum gates and unitary transformations to simulate the game dynamics.
phen_hiv(strategy1, strategy2, alpha, beta, gamma, theta)phen_hiv(strategy1, strategy2, alpha, beta, gamma, theta)
strategy1 |
A 2x2 matrix representing the strategy of player 1. |
strategy2 |
A 2x2 matrix representing the strategy of player 2. |
alpha |
A numeric value representing the payoff for outcome |00>. |
beta |
A numeric value representing the payoff for outcome |01>. |
gamma |
A numeric value representing the payoff for outcome |10>. |
theta |
A numeric value representing the payoff for outcome |11>. |
Özlüer Başer, B. (2022). "Analyzing the competition of HIV-1 phenotypes with quantum game theory". Gazi University Journal of Science, 35(3), 1190–1198. doi:10.35378/gujs.772616
strategy1 <- diag(2) # Identity matrix for strategy 1 strategy2 <- diag(2) # Identity matrix for strategy 2 alpha <- 1 beta <- 0.5 gamma <- 2 theta <- 0.1 result <- phen_hiv(strategy1, strategy2, alpha, beta, gamma, theta)strategy1 <- diag(2) # Identity matrix for strategy 1 strategy2 <- diag(2) # Identity matrix for strategy 2 alpha <- 1 beta <- 0.5 gamma <- 2 theta <- 0.1 result <- phen_hiv(strategy1, strategy2, alpha, beta, gamma, theta)
Contains predictions of longitudinal viral load values for 176 patients from 2018 to 2024.
predspreds
An object of class spec_tbl_df (inherits from tbl_df, tbl, data.frame) with 176 rows and 1 columns.
Clinical data from Hospital Vicente Guerrero, IMSS, HIV Clinic.
data(preds) head(preds)data(preds) head(preds)
Contains batched predictions of longitudinal viral load values for 176 patients from 2018 to 2024.
preds2preds2
An object of class spec_tbl_df (inherits from tbl_df, tbl, data.frame) with 176 rows and 1 columns.
Clinical data from Hospital Vicente Guerrero, IMSS, HIV Clinic.
data(preds2) head(preds2)data(preds2) head(preds2)
The qphen dataset contains 176 observations and 24 variables, representing classified phenotype interactions in a quantum game-theoretic model of HIV phenotypes.
The data includes CD4 and viral load differences, quantum game strategies, classification clusters, and tuberculosis/genoresistance indicators.
data(qphen)data(qphen)
A data frame with 176 rows and 24 variables:
(double) Unique identifier for each observation.
(double) Difference in viral load (log scale) between time points.
(double) Difference in CD4 count between time points.
(double) Mean difference of viral loads across the dataset.
(double) Mean difference of CD4 counts across the dataset.
(double) Number of cases in each interaction cluster.
(double) Computed payoff for the phenotype interaction.
#'
(double) Alternative computed payoff.
(double) Closest estimated payoff value.
(double) Cluster assignment for phenotype interactions (second clustering method).
(double) Cluster assignment for phenotype interactions (third clustering method).
(double) Cluster assignment for phenotype interactions (fourth clustering method).
(double) Phenotype type (v or V).
(double) Strategy of the first phenotype using X, T, or H gate (binary encoding).
(double) Alternative strategy of the first phenotype.
(double) Strategy of the second phenotype using H, Id, S, T, X, Y, or Z gate (binary encoding).
(double) Alternative strategy of the second phenotype.
(double) Alternative strategy of the second phenotype.
(double) Alternative strategy of the second phenotype.
(double) Alternative strategy of the second phenotype.
(double) Alternative strategy of the second phenotype.
(double) Indicates whether predictions were made on full data or batch data.
(double) Indicator for tuberculosis presence (1 = TB, 0 = no TB).
(double) Indicator for genoresistance presence (1 = resistant, 0 = non-resistant).
data(qphen) head(qphen)data(qphen) head(qphen)
Simulates the BB84 protocol for quantum key distribution (QKD), illustrating the difference in the Quantum Bit Error Rate (QBER) between an ideal channel (no interference) and a channel under eavesdropping (Eve). The simulation models the encoding, transmission, and measurement of quantum bits (qubits) following the original Bennett–Brassard (1984) protocol.
run_bb84_simulation( eavesdropping_active = FALSE, key_length = 1000, test_ratio = 0.2 )run_bb84_simulation( eavesdropping_active = FALSE, key_length = 1000, test_ratio = 0.2 )
eavesdropping_active |
Logical. If |
key_length |
Integer. Length of the quantum key sequence to be simulated. The default is 1000, which provides good statistical stability. |
test_ratio |
Numeric. Proportion (between 0 and 1) of bits that Alice and Bob compare to detect eavesdropping during the verification phase. Default is 0.2. |
The BB84 protocol proceeds through the following stages:
Preparation: Alice generates random bits and bases and encodes photons accordingly.
Transmission: Photons are sent over a quantum channel.
Eavesdropping (optional): Eve intercepts each photon, measures it using a random basis, and resends a new photon, introducing potential errors.
Measurement: Bob measures the incoming photons using his own random bases.
Sifting: Alice and Bob retain only bits measured with matching bases.
Error estimation: A random subset of the sifted bits is compared to estimate QBER.
If the measured QBER exceeds a security threshold (commonly 15–25%), it indicates that eavesdropping has occurred and the key must be discarded. In the absence of interference, the QBER should be close to zero.
A list of class "BB84Simulation" containing:
QBERThe observed Quantum Bit Error Rate between Alice's and Bob's bits.
Sifted_LengthNumber of bits retained after basis reconciliation.
Final_Key_LengthNumber of bits remaining after error testing.
EavesdroppingLogical flag indicating whether eavesdropping was active.
Bennett, C. H., & Brassard, G. (1984). Quantum cryptography: Public key distribution and coin tossing. Proceedings of IEEE International Conference on Computers, Systems and Signal Processing, 175–179.
Nielsen, M. A., & Chuang, I. L. (2010). Quantum Computation and Quantum Information. Cambridge University Press.
Rieffel, E. G., & Polak, W. H. (2011). Quantum Computing: A Gentle Introduction. MIT Press.
# Scenario 1: Perfect Channel (No Eavesdropping) results_no_eve <- run_bb84_simulation(eavesdropping_active = FALSE) cat("--- Scenario 1: No Eavesdropping ---\n") cat(paste("Sifted Key Length:", results_no_eve$Sifted_Length, "\n")) cat(paste("Final Key Length:", results_no_eve$Final_Key_Length, "\n")) cat(paste("Quantum Bit Error Rate (QBER):", round(results_no_eve$QBER * 100, 2), "%\n")) cat("Result: Secure key established successfully.\n") # Scenario 2: Measure-and-Resend Attack results_with_eve <- run_bb84_simulation(eavesdropping_active = TRUE) cat("\n--- Scenario 2: With Eavesdropping ---\n") cat(paste("Sifted Key Length:", results_with_eve$Sifted_Length, "\n")) cat(paste("Final Key Length:", results_with_eve$Final_Key_Length, "\n")) cat(paste("Quantum Bit Error Rate (QBER):", round(results_with_eve$QBER * 100, 2), "%\n")) if (results_with_eve$QBER > 0.15) { cat("High QBER detected. Eavesdropping likely — key discarded.\n") } else { cat("No eavesdropping detected (unlikely in theory).\n") }# Scenario 1: Perfect Channel (No Eavesdropping) results_no_eve <- run_bb84_simulation(eavesdropping_active = FALSE) cat("--- Scenario 1: No Eavesdropping ---\n") cat(paste("Sifted Key Length:", results_no_eve$Sifted_Length, "\n")) cat(paste("Final Key Length:", results_no_eve$Final_Key_Length, "\n")) cat(paste("Quantum Bit Error Rate (QBER):", round(results_no_eve$QBER * 100, 2), "%\n")) cat("Result: Secure key established successfully.\n") # Scenario 2: Measure-and-Resend Attack results_with_eve <- run_bb84_simulation(eavesdropping_active = TRUE) cat("\n--- Scenario 2: With Eavesdropping ---\n") cat(paste("Sifted Key Length:", results_with_eve$Sifted_Length, "\n")) cat(paste("Final Key Length:", results_with_eve$Final_Key_Length, "\n")) cat(paste("Quantum Bit Error Rate (QBER):", round(results_with_eve$QBER * 100, 2), "%\n")) if (results_with_eve$QBER > 0.15) { cat("High QBER detected. Eavesdropping likely — key discarded.\n") } else { cat("No eavesdropping detected (unlikely in theory).\n") }
Simulates the E91 (Ekert 1991) quantum key distribution protocol using entangled
particle pairs (EPR) and Bell’s theorem (CHSH statistic) to ensure channel security.
Security is established when the Bell Inequality is violated, i.e.
when , indicating quantum behavior.
run_e91_simulation( eavesdropping_active = FALSE, key_length = 1000, noise_level = 0.5 )run_e91_simulation( eavesdropping_active = FALSE, key_length = 1000, noise_level = 0.5 )
eavesdropping_active |
Logical. If |
key_length |
Integer. Number of simulated EPR pairs (default = 1000). |
noise_level |
Numeric. Noise level (0-1) applied when
|
El E91 se diferencia de BB84 en que la detección del espía es simultánea a la generación de la clave. Los pares de bases son separados en dos conjuntos:
Clave Secreta: Pares con perfecta anti-correlación (ej. a2-b1, a3-b2).
Test de Bell: Pares restantes usados para calcular la esperanza $E(a_i, b_j)$ y el valor $S$.
Si $S$ cae por debajo de 2 (límite clásico de Bell), se concluye que el entrelazamiento ha sido roto por Eve, y la clave debe descartarse.
A list of class "E91Simulation" containing:
S_CalculatedObserved Bell CHSH statistic.
S_TheoreticalQuantum theoretical value ( -2.8284).
Bell_ViolationTRUE if (secure),
FALSE if (insecure).
Sifted_Key_LengthNumber of bits retained for key formation.
EavesdroppingIndicates if an attack was simulated.
Ekert, A. K. (1991). Quantum cryptography based on Bell's theorem. Physical Review Letters, 67(6), 661.
# Escenario 1: Canal Cuántico Seguro (No Eavesdropping) results_secure <- run_e91_simulation(eavesdropping_active = FALSE) cat("--- Escenario 1: Sin Eavesdropping ---\n") cat(paste("S Calculado:", round(results_secure$S_Calculated, 4), "\n")) cat(paste("Violación de Bell:", results_secure$Bell_Violation, "\n")) # Escenario 2: Ataque que Rompe el Entrelazamiento results_attack <- run_e91_simulation(eavesdropping_active = TRUE) cat("\n--- Escenario 2: Con Ataque ---\n") cat(paste("S Calculado:", round(results_attack$S_Calculated, 4), "\n")) cat(paste("Violación de Bell:", results_attack$Bell_Violation, "\n"))# Escenario 1: Canal Cuántico Seguro (No Eavesdropping) results_secure <- run_e91_simulation(eavesdropping_active = FALSE) cat("--- Escenario 1: Sin Eavesdropping ---\n") cat(paste("S Calculado:", round(results_secure$S_Calculated, 4), "\n")) cat(paste("Violación de Bell:", results_secure$Bell_Violation, "\n")) # Escenario 2: Ataque que Rompe el Entrelazamiento results_attack <- run_e91_simulation(eavesdropping_active = TRUE) cat("\n--- Escenario 2: Con Ataque ---\n") cat(paste("S Calculado:", round(results_attack$S_Calculated, 4), "\n")) cat(paste("Violación de Bell:", results_attack$Bell_Violation, "\n"))
Computes summary statistics by classification group from an object of class
InteractionClassification, including mean differences in viral load and CD4 counts,
and the number of observations per cluster.
This function summarizes the payoffs object by classification.
summary(object, ...) summary(object, ...)summary(object, ...) summary(object, ...)
object |
A payoffs object. |
... |
Additional arguments (not used). |
A data.frame with one row per interaction cluster and the following columns:
Cluster label (as factor).
Mean of CD4 differences in the group.
Mean of viral load differences in the group.
Number of observations in the group.
set.seed(42) data(cd_3) cd_data <- cd_3[,-1] cd_result <- cds_diff(cd_data) data(vl_3) vl_data <- vl_3[,-1] vl_result <- vlogs_diff(vl_data) result <- InteractionClassification(cd_result = cd_result, vl_result = vl_result) summary(result) set.seed(42) data(cd_3) cd_data <- cd_3[,-1] cd_result <- cds_diff(cd_data) data(vl_3) vl_data <- vl_3[,-1] vl_result <- vlogs_diff(vl_data) result <- InteractionClassification(cd_result = cd_result, vl_result = vl_result) data(preds) payoffs_results <- estimate_payoffs(result, preds) summary(payoffs_results)set.seed(42) data(cd_3) cd_data <- cd_3[,-1] cd_result <- cds_diff(cd_data) data(vl_3) vl_data <- vl_3[,-1] vl_result <- vlogs_diff(vl_data) result <- InteractionClassification(cd_result = cd_result, vl_result = vl_result) summary(result) set.seed(42) data(cd_3) cd_data <- cd_3[,-1] cd_result <- cds_diff(cd_data) data(vl_3) vl_data <- vl_3[,-1] vl_result <- vlogs_diff(vl_data) result <- InteractionClassification(cd_result = cd_result, vl_result = vl_result) data(preds) payoffs_results <- estimate_payoffs(result, preds) summary(payoffs_results)
Computes summary statistics by classification group from an object of class
InteractionClassification, including mean differences in viral load and CD4 counts,
and the number of observations per cluster.
## S3 method for class 'InteractionClassification' summary(object, ...)## S3 method for class 'InteractionClassification' summary(object, ...)
object |
An object of class |
... |
Additional arguments passed to other methods (currently not used). |
This function summarizes the payoffs object by classification.
## S3 method for class 'payoffs' summary(object, ...)## S3 method for class 'payoffs' summary(object, ...)
object |
A payoffs object. |
... |
Additional arguments (not used). |
Contains longitudinal measurements of viral load for 176 patients from 2018 to 2024. Viral load is a critical marker used to monitor the effectiveness of HIV treatment by measuring the amount of HIV RNA in the blood.
vl_3vl_3
A data frame with 176 rows and 18 variables:
Unique identifier for each patient.
Viral load for the first measurement in 2018.
Viral load for the second measurement in 2018.
Viral load for the first measurement in 2019.
Viral load for the second measurement in 2019.
Viral load for the first measurement in 2020.
Viral load for the first measurement in 2021.
Viral load for the second measurement in 2021.
Viral load for the third measurement in 2021.
Viral load for the first measurement in 2022.
Viral load for the second measurement in 2022.
Viral load for the third measurement in 2022.
Viral load for the first measurement in 2023.
Viral load for the second measurement in 2023.
Viral load for the third measurement in 2023.
Viral load for the first measurement in 2024.
Viral load for the second measurement in 2024.
Viral load for the third measurement in 2024.
The viral load measurements provide insight into the patient's response to antiretroviral therapy (ART). Lower viral load values, especially undetectable levels, indicate better control of the infection. Missing values indicate that no viral load measurement was available for that patient at that specific time.
Clinical data from Hospital Vicente Guerrero, IMSS, HIV Clinic.
## Not run: # Load the dataset data(vl_3) # Summarize viral loads for the year 2021 summary(vl_3[, c("cd_2021_1", "cd_2021_2", "cd_2021_3")]) ## End(Not run)## Not run: # Load the dataset data(vl_3) # Summarize viral loads for the year 2021 summary(vl_3[, c("cd_2021_1", "cd_2021_2", "cd_2021_3")]) ## End(Not run)
This function calculates the mean differences of viral loads across time for each individual in the dataset.
vl_diff(vl_data)vl_diff(vl_data)
vl_data |
A data frame of longitudinal viral load values per individual, where rows represent patients and columns represent sequential measurements across time (e.g., years or visits). |
An object of class "Interaction" with the following components:
Mean differences of raw viral load values.
data(vl_3) vl_data <- vl_3[,-1] result <- vl_diff(vl_data)data(vl_3) vl_data <- vl_3[,-1] result <- vl_diff(vl_data)
This function calculates the mean differences of lograithmic viral loads across time for each individual in the dataset.
vlog_diff(vl_data)vlog_diff(vl_data)
vl_data |
A data frame of longitudinal viral load values per individual, where rows represent patients and columns represent sequential measurements across time (e.g., years or visits). |
An object of class "Interaction" with the following components:
Mean differences of logarithmic viral load values.
data(vl_3) vl_data <- vl_3[,-1] result <- vlog_diff(vl_data)data(vl_3) vl_data <- vl_3[,-1] result <- vlog_diff(vl_data)
This function calculates the mean standardized differences of logarithmic viral loads across time for each individual in the dataset.
vlogs_diff(vl_data)vlogs_diff(vl_data)
vl_data |
A data frame of longitudinal viral load values per individual, where rows represent patients and columns represent sequential measurements across time (e.g., years or visits). |
An object of class "Interaction" with the following components:
Mean standardized differences of logarithmic viral load values.
data(vl_3) vl_data <- vl_3[,-1] result <- vlogs_diff(vl_data)data(vl_3) vl_data <- vl_3[,-1] result <- vlogs_diff(vl_data)