1 Giriş

Kütləvi simulyasiya psixometrik tədqiqatların və CAT sistemlərinin qiymətləndirilməsinin əsasını təşkil edir. Bu bölmədə yüzlərlə və ya minlərlə test alıcısı üçün CAT simulyasiyalarını necə həyata keçirməyi öyrənəcəyik.

Kütləvi simulyasiya aşağıdakı məqsədlərə xidmət edir:

  1. Sistem Performansının Qiymətləndirilməsi: CAT alqoritmlərinin geniş populyasiyada necə işləməsini anlamaq
  2. Statistik Validasiya: Böyük nümunələrdə nəticələrin etibarlılığını yoxlamaq
  3. Parametr Optimizasiyası: Müxtəlif sistem parametrlərinin effektivliyini müqayisə etmək
  4. Monte Carlo Tədqiqatları: Nəzəri nəticələrin empirik təsdiqi

1.1 Kütləvi Simulyasiyanın Xüsusiyyətləri

1.1.1 Scalability Tələbləri

  • Memory Management: Böyük məlumat strukturlarının səmərəli idarə edilməsi
  • Computational Efficiency: Hesablama vaxtının optimallaşdırılması
  • Progress Monitoring: Uzun simulyasiyalarda irəliləyişin izlənməsi
  • Error Handling: Robust xəta idarəetməsi

1.1.2 Statistik Məqsədlər

  • Population Statistics: Populyasiya səviyyəsində metriklər
  • Distribution Analysis: Nəticələrin paylanma təhlili
  • Subgroup Comparisons: Alt qrupların müqayisəsi
  • Reliability Assessment: Sistem etibarlılığının qiymətləndirilməsi

2 Prerequisite Funksiyalar

Əvvəl əvvəlki bölmələrdən köməkçi funksiyalarımızı yükləyək:

2.1 Əsas CAT Funksiyaları

# Əvvəlki bölmələrdən köməkçi funksiyalar

# Item seçimi funksiyası
select_next_item <- function(current_theta, item_bank, administered_items = c()) {
    available_items <- setdiff(1:nrow(item_bank), administered_items)
    
    if (length(available_items) == 0) {
        return(NULL)
    }
    
    information_values <- numeric(length(available_items))
    
    for (i in 1:length(available_items)) {
        item_idx <- available_items[i]
        
        a <- item_bank$a[item_idx]
        b <- item_bank$b[item_idx]
        c <- item_bank$c[item_idx]
        
        P <- c + (1 - c) * plogis(a * (current_theta - b))
        Q <- 1 - P
        P_prime <- a * (1 - c) * exp(-a * (current_theta - b)) / 
                   (1 + exp(-a * (current_theta - b)))^2
        
        P <- pmax(0.0001, pmin(0.9999, P))
        Q <- 1 - P
        
        information_values[i] <- (P_prime^2) / (P * Q)
    }
    
    best_item_position <- which.max(information_values)
    selected_item <- available_items[best_item_position]
    
    return(list(
        item_index = selected_item,
        information = information_values[best_item_position]
    ))
}

# EAP qiymətləndirmə
estimate_ability_eap <- function(administered_items, responses, item_bank,
                                prior_mean = 0, prior_sd = 1, 
                                theta_range = seq(-4, 4, 0.1)) {
    
    if (length(administered_items) == 0 || length(responses) == 0) {
        return(list(theta = prior_mean, se = prior_sd))
    }
    
    likelihood <- numeric(length(theta_range))
    
    for (j in 1:length(theta_range)) {
        theta <- theta_range[j]
        log_likelihood <- 0
        
        for (i in 1:length(administered_items)) {
            item_idx <- administered_items[i]
            response <- responses[i]
            
            a <- item_bank$a[item_idx]
            b <- item_bank$b[item_idx]
            c <- item_bank$c[item_idx]
            
            P <- c + (1 - c) * plogis(a * (theta - b))
            P <- pmax(0.0001, pmin(0.9999, P))
            
            if (response == 1) {
                log_likelihood <- log_likelihood + log(P)
            } else {
                log_likelihood <- log_likelihood + log(1 - P)
            }
        }
        
        likelihood[j] <- exp(log_likelihood)
    }
    
    prior <- dnorm(theta_range, prior_mean, prior_sd)
    posterior <- likelihood * prior
    
    if (sum(posterior) > 0) {
        posterior <- posterior / sum(posterior)
    } else {
        posterior <- prior / sum(prior)
    }
    
    theta_eap <- sum(theta_range * posterior)
    variance_post <- sum((theta_range - theta_eap)^2 * posterior)
    se_eap <- sqrt(variance_post)
    
    return(list(theta = theta_eap, se = se_eap))
}

# Sonlandırma kriteriyaları
check_termination <- function(current_step, theta_se, min_items = 5, max_items = 30, se_threshold = 0.3) {
    
    if (current_step < min_items) {
        return(list(terminate = FALSE, 
                   reason = paste("Minimum item sayına çatılmayıb:", current_step, "/", min_items)))
    }
    
    if (current_step >= max_items) {
        return(list(terminate = TRUE, 
                   reason = paste("Maksimum item sayına çatıldı:", current_step, "/", max_items)))
    }
    
    if (!is.na(theta_se) && theta_se <= se_threshold) {
        return(list(terminate = TRUE, 
                   reason = paste("SE threshold-a çatıldı:", round(theta_se, 3), "≤", se_threshold)))
    }
    
    return(list(terminate = FALSE, 
               reason = paste("Davam edir: SE =", round(theta_se, 3))))
}

# Cavab generasiya
generate_response <- function(true_theta, item_params, include_error = TRUE) {
    a <- item_params$a
    b <- item_params$b
    c <- item_params$c
    
    prob_correct <- c + (1 - c) * plogis(a * (true_theta - b))
    
    if (include_error) {
        error_factor <- rnorm(1, 0, 0.05)
        prob_correct <- pmax(0, pmin(1, prob_correct + error_factor))
    }
    
    response <- rbinom(1, 1, prob_correct)
    
    return(list(
        response = response,
        prob_correct = prob_correct
    ))
}

# Tək test alıcısı üçün CAT simulyasiyası
run_cat_simulation <- function(examinee_ability, item_bank, 
                              min_items = 5, max_items = 30, se_threshold = 0.3) {
    
    administered_items <- c()
    responses <- c()
    theta_estimates <- c()
    se_estimates <- c()
    current_theta <- 0
    current_se <- 1.0
    
    for (step in 1:max_items) {
        
        if (step == 1) {
            available_items <- 1:nrow(item_bank)
            difficulty_diff <- abs(item_bank$b - 0)
            selected_item <- available_items[which.min(difficulty_diff)]
        } else {
            item_selection <- select_next_item(current_theta, item_bank, administered_items)
            if (is.null(item_selection)) break
            selected_item <- item_selection$item_index
        }
        
        administered_items <- c(administered_items, selected_item)
        
        response_result <- generate_response(examinee_ability, item_bank[selected_item, ])
        responses <- c(responses, response_result$response)
        
        if (step >= 2) {
            ability_est <- estimate_ability_eap(administered_items, responses, item_bank)
            current_theta <- ability_est$theta
            current_se <- ability_est$se
            
            theta_estimates <- c(theta_estimates, current_theta)
            se_estimates <- c(se_estimates, current_se)
            
            termination <- check_termination(step, current_se, min_items, max_items, se_threshold)
            if (termination$terminate) {
                break
            }
        }
    }
    
    final_ability <- estimate_ability_eap(administered_items, responses, item_bank)
    
    return(list(
        administered_items = administered_items,
        responses = responses,
        theta_estimates = theta_estimates,
        se_estimates = se_estimates,
        final_theta = final_ability$theta,
        final_se = final_ability$se,
        items_count = length(administered_items),
        accuracy = mean(responses),
        true_theta = examinee_ability,
        estimation_error = abs(final_ability$theta - examinee_ability),
        bias = final_ability$theta - examinee_ability
    ))
}

cat("Köməkçi funksiyalar yükləndi ✅\n")
## Köməkçi funksiyalar yükləndi ✅

3 Ana Kütləvi Simulyasiya Funksiyası

# Kütləvi simulyasiya funksiyası
run_mass_simulation <- function(examinees, item_bank, n_subjects = 100,
                               min_items = 5, max_items = 30, se_threshold = 0.3,
                               show_progress = TRUE, seed = NULL) {
    
    if (!is.null(seed)) set.seed(seed)
    
    cat("=== KÜTLƏVİ SİMULYASİYA BAŞLAYIR ===\n")
    cat("Planlaşdırılan test alıcı sayı:", n_subjects, "\n")
    cat("Mövcud examinee sayı:", nrow(examinees), "\n")
    cat("Item bank ölçüsü:", nrow(item_bank), "\n")
    cat("Test parametrləri: min =", min_items, ", max =", max_items, ", SE ≤", se_threshold, "\n\n")
    
    # Simulyasiya ediləcək sayı
    actual_n <- min(n_subjects, nrow(examinees))
    cat("Həqiqi simulyasiya sayı:", actual_n, "\n\n")
    
    results <- list()
    
    # Progress tracking
    if (show_progress) {
        cat("İrəliləyiş:\n")
        progress_points <- floor(seq(1, actual_n, length.out = min(20, actual_n)))
    }
    
    start_time <- Sys.time()
    
    for (i in 1:actual_n) {
        
        # CAT simulyasiyası
        result <- run_cat_simulation(
            examinee_ability = examinees$true_theta[i],
            item_bank = item_bank,
            min_items = min_items,
            max_items = max_items,
            se_threshold = se_threshold
        )
        
        # Examinee ID və əlavə məlumatlar
        result$examinee_id <- i
        result$original_id <- examinees$id[i]
        results[[i]] <- result
        
        # Progress göstərmə
        if (show_progress && i %in% progress_points) {
            progress_percent <- round(100 * i / actual_n)
            elapsed_time <- as.numeric(Sys.time() - start_time)
            
            if (i > 5) {  # İlk bir neçə iterasiyadan sonra vaxt qiymətləndirməsi
                estimated_total <- elapsed_time * actual_n / i
                remaining_time <- estimated_total - elapsed_time
                
                cat("  ", progress_percent, "% (", i, "/", actual_n, ")")
                cat(" - Qalan: ~", round(remaining_time/60, 1), " dəq")
                cat(" - Orta: ", round(elapsed_time/i, 2), " san/test alıcısı\n")
            } else {
                cat("  ", progress_percent, "% (", i, "/", actual_n, ")\n")
            }
        }
    }
    
    end_time <- Sys.time()
    total_time <- as.numeric(end_time - start_time)
    
    cat("\n✅ Simulyasiya tamamlandı!\n")
    cat("Toplam vaxt:", round(total_time/60, 2), "dəqiqə\n")
    cat("Test alıcısı başına orta vaxt:", round(total_time/actual_n, 3), "saniyə\n\n")
    
    return(list(
        results = results,
        simulation_info = list(
            n_subjects = actual_n,
            total_time = total_time,
            avg_time_per_subject = total_time/actual_n,
            simulation_date = Sys.time(),
            parameters = list(
                min_items = min_items,
                max_items = max_items,
                se_threshold = se_threshold
            )
        )
    ))
}

# Test məlumatları yaradılması
set.seed(12345)

# Item bank
item_bank <- data.frame(
    a = runif(200, 0.8, 2.5),
    b = rnorm(200, 0, 1.2),
    c = runif(200, 0.1, 0.25)
)

# Test alıcıları - müxtəlif qabiliyyət səviyyələri
examinees <- data.frame(
    id = 1:100,
    true_theta = rnorm(100, 0, 1)
)

cat("=== MƏLUMAT HaZIRLIĞI ===\n")
## === MƏLUMAT HaZIRLIĞI ===
cat("Item bank ölçüsü:", nrow(item_bank), "\n")
## Item bank ölçüsü: 200
cat("  a aralığı:", round(range(item_bank$a), 2), "\n")
##   a aralığı: 0.8 2.49
cat("  b aralığı:", round(range(item_bank$b), 2), "\n")
##   b aralığı: -2.75 3.3
cat("  c aralığı:", round(range(item_bank$c), 2), "\n")
##   c aralığı: 0.1 0.25
cat("\nTest alıcıları:\n")
## 
## Test alıcıları:
cat("  Sayı:", nrow(examinees), "\n")
##   Sayı: 100
cat("  θ aralığı:", round(range(examinees$true_theta), 2), "\n")
##   θ aralığı: -2.24 2.24
cat("  θ ortası:", round(mean(examinees$true_theta), 3), "\n")
##   θ ortası: -0.047
cat("  θ SD:", round(sd(examinees$true_theta), 3), "\n\n")
##   θ SD: 0.886
# İlk 50 test alıcısı üçün simulyasiya
cat_results <- run_mass_simulation(examinees, item_bank, n_subjects = 50, seed = 54321)
## === KÜTLƏVİ SİMULYASİYA BAŞLAYIR ===
## Planlaşdırılan test alıcı sayı: 50 
## Mövcud examinee sayı: 100 
## Item bank ölçüsü: 200 
## Test parametrləri: min = 5 , max = 30 , SE ≤ 0.3 
## 
## Həqiqi simulyasiya sayı: 50 
## 
## İrəliləyiş:
##    2 % ( 1 / 50 )
##    6 % ( 3 / 50 )
##    12 % ( 6 / 50 ) - Qalan: ~ 0.2  dəq - Orta:  0.24  san/test alıcısı
##    16 % ( 8 / 50 ) - Qalan: ~ 0.2  dəq - Orta:  0.24  san/test alıcısı
##    22 % ( 11 / 50 ) - Qalan: ~ 0.2  dəq - Orta:  0.24  san/test alıcısı
##    26 % ( 13 / 50 ) - Qalan: ~ 0.2  dəq - Orta:  0.24  san/test alıcısı
##    32 % ( 16 / 50 ) - Qalan: ~ 0.1  dəq - Orta:  0.24  san/test alıcısı
##    38 % ( 19 / 50 ) - Qalan: ~ 0.1  dəq - Orta:  0.24  san/test alıcısı
##    42 % ( 21 / 50 ) - Qalan: ~ 0.1  dəq - Orta:  0.24  san/test alıcısı
##    48 % ( 24 / 50 ) - Qalan: ~ 0.1  dəq - Orta:  0.23  san/test alıcısı
##    52 % ( 26 / 50 ) - Qalan: ~ 0.1  dəq - Orta:  0.23  san/test alıcısı
##    58 % ( 29 / 50 ) - Qalan: ~ 0.1  dəq - Orta:  0.23  san/test alıcısı
##    62 % ( 31 / 50 ) - Qalan: ~ 0.1  dəq - Orta:  0.23  san/test alıcısı
##    68 % ( 34 / 50 ) - Qalan: ~ 0.1  dəq - Orta:  0.24  san/test alıcısı
##    74 % ( 37 / 50 ) - Qalan: ~ 0.1  dəq - Orta:  0.24  san/test alıcısı
##    78 % ( 39 / 50 ) - Qalan: ~ 0  dəq - Orta:  0.24  san/test alıcısı
##    84 % ( 42 / 50 ) - Qalan: ~ 0  dəq - Orta:  0.24  san/test alıcısı
##    88 % ( 44 / 50 ) - Qalan: ~ 0  dəq - Orta:  0.24  san/test alıcısı
##    94 % ( 47 / 50 ) - Qalan: ~ 0  dəq - Orta:  0.24  san/test alıcısı
##    100 % ( 50 / 50 ) - Qalan: ~ 0  dəq - Orta:  0.24  san/test alıcısı
## 
## ✅ Simulyasiya tamamlandı!
## Toplam vaxt: 0.2 dəqiqə
## Test alıcısı başına orta vaxt: 0.239 saniyə

4 Nəticələrin Emalı və Təhlili

# Simulyasiya nəticələrini data frame formatına çevirmə
extract_simulation_summary <- function(mass_results) {
    
    results_list <- mass_results$results
    
    summary_data <- data.frame(
        Examinee_ID = sapply(results_list, function(x) x$examinee_id),
        Original_ID = sapply(results_list, function(x) x$original_id),
        True_Theta = sapply(results_list, function(x) x$true_theta),
        Final_Theta = sapply(results_list, function(x) x$final_theta),
        Final_SE = sapply(results_list, function(x) x$final_se),
        Items_Count = sapply(results_list, function(x) x$items_count),
        Accuracy = sapply(results_list, function(x) x$accuracy),
        Estimation_Error = sapply(results_list, function(x) x$estimation_error),
        Bias = sapply(results_list, function(x) x$bias)
    )
    
    # Əlavə hesablanmış göstəricilər
    summary_data$Efficiency <- 1 / (summary_data$Final_SE * summary_data$Items_Count)
    summary_data$Precision_Met <- summary_data$Final_SE <= 0.3
    summary_data$Ability_Level <- cut(summary_data$True_Theta, 
                                     breaks = c(-Inf, -1, 0, 1, Inf),
                                     labels = c("Aşağı", "Orta-", "Orta+", "Yuxarı"))
    
    return(summary_data)
}

# Nəticələri çıxarmaq
simulation_summary <- extract_simulation_summary(cat_results)

# Ümumi statistikalar
cat("=== ÜMUMİ SİMULYASİYA NƏTİCƏLƏRİ ===\n")
## === ÜMUMİ SİMULYASİYA NƏTİCƏLƏRİ ===
cat("Test edilən şəxs sayı:", nrow(simulation_summary), "\n\n")
## Test edilən şəxs sayı: 50
# Tapşırıq sayı statistikası
cat("📊 TAPŞIRIQ SAYI STATİSTİKASI:\n")
## 📊 TAPŞIRIQ SAYI STATİSTİKASI:
cat("  Orta tapşırıq sayı:", round(mean(simulation_summary$Items_Count), 2), "\n")
##   Orta tapşırıq sayı: 15.7
cat("  Tapşırıq sayı SD:", round(sd(simulation_summary$Items_Count), 2), "\n")
##   Tapşırıq sayı SD: 2.45
cat("  Tapşırıq sayı aralığı:", min(simulation_summary$Items_Count), "-", max(simulation_summary$Items_Count), "\n")
##   Tapşırıq sayı aralığı: 13 - 26
cat("  Median tapşırıq sayı:", median(simulation_summary$Items_Count), "\n")
##   Median tapşırıq sayı: 15
# Dəqiqlik statistikası
cat("\n🎯 DƏQİQLİK STATİSTİKASI:\n")
## 
## 🎯 DƏQİQLİK STATİSTİKASI:
cat("  Orta qiymətləndirmə xətası:", round(mean(simulation_summary$Estimation_Error), 3), "\n")
##   Orta qiymətləndirmə xətası: 0.218
cat("  RMSE:", round(sqrt(mean(simulation_summary$Estimation_Error^2)), 3), "\n")
##   RMSE: 0.289
cat("  Orta bias:", round(mean(simulation_summary$Bias), 3), "\n")
##   Orta bias: -0.008
cat("  Bias SD:", round(sd(simulation_summary$Bias), 3), "\n")
##   Bias SD: 0.292
# SE statistikası
cat("\n📏 STANDART XƏTA STATİSTİKASI:\n")
## 
## 📏 STANDART XƏTA STATİSTİKASI:
cat("  Orta final SE:", round(mean(simulation_summary$Final_SE), 3), "\n")
##   Orta final SE: 0.293
cat("  SE aralığı:", round(min(simulation_summary$Final_SE), 3), "-", round(max(simulation_summary$Final_SE), 3), "\n")
##   SE aralığı: 0.284 - 0.3
cat("  SE ≤ 0.3 nisbəti:", round(mean(simulation_summary$Precision_Met) * 100, 1), "%\n")
##   SE ≤ 0.3 nisbəti: 100 %
# Effektivlik statistikası
cat("\n⚡ EFFEKTİVLİK STATİSTİKASI:\n")
## 
## ⚡ EFFEKTİVLİK STATİSTİKASI:
cat("  Orta effektivlik:", round(mean(simulation_summary$Efficiency), 3), "\n")
##   Orta effektivlik: 0.222
cat("  Orta doğru cavab nisbəti:", round(mean(simulation_summary$Accuracy), 3), "\n")
##   Orta doğru cavab nisbəti: 0.624
# Qabiliyyət səviyyəsinə görə təhlil
ability_analysis <- simulation_summary %>%
    group_by(Ability_Level) %>%
    summarise(
        Count = n(),
        Mean_Items = round(mean(Items_Count), 1),
        Mean_SE = round(mean(Final_SE), 3),
        Mean_Error = round(mean(Estimation_Error), 3),
        Mean_Bias = round(mean(Bias), 3),
        Precision_Rate = round(mean(Precision_Met) * 100, 1),
        .groups = 'drop'
    )

cat("\n📈 QABİLİYYƏT SƏVİYYƏSİNƏ GÖRƏ TƏHLİL:\n")
## 
## 📈 QABİLİYYƏT SƏVİYYƏSİNƏ GÖRƏ TƏHLİL:
print(ability_analysis)
## # A tibble: 4 × 7
##   Ability_Level Count Mean_Items Mean_SE Mean_Error Mean_Bias Precision_Rate
##   <fct>         <int>      <dbl>   <dbl>      <dbl>     <dbl>          <dbl>
## 1 Aşağı             7       17.3   0.293      0.362     0.109            100
## 2 Orta-            14       15.1   0.291      0.196     0.093            100
## 3 Orta+            20       14.3   0.293      0.196    -0.116            100
## 4 Yuxarı            9       18.4   0.294      0.19     -0.016            100

5 Ətraflı Statistik Təhlil

# Ətraflı statistik təhlil funksiyası
perform_detailed_analysis <- function(summary_data) {
    
    cat("=== ƏTRAFLı STATİSTİK TƏHLİL ===\n\n")
    
    # 1. Deskriptiv statistikalar
    cat("1️⃣ DESKRİPTİV STATİSTİKALAR:\n")
    
    numeric_vars <- c("Items_Count", "Final_SE", "Estimation_Error", "Bias", "Accuracy", "Efficiency")
    
    for (var in numeric_vars) {
        values <- summary_data[[var]]
        cat("  ", var, ":\n")
        cat("    Orta ± SD:", round(mean(values), 3), "±", round(sd(values), 3), "\n")
        cat("    Median [IQR]:", round(median(values), 3), 
            "[", round(quantile(values, 0.25), 3), "-", round(quantile(values, 0.75), 3), "]\n")
        cat("    Min-Max:", round(min(values), 3), "-", round(max(values), 3), "\n\n")
    }
    
    # 2. Korrelyasiya təhlili
    cat("2️⃣ KORRELYASIYA TƏHLİLİ:\n")
    
    correlation_matrix <- cor(summary_data[, numeric_vars])
    cat("Əsas korrelyasiyalar:\n")
    cat("  True_Theta - Final_Theta:", round(cor(summary_data$True_Theta, summary_data$Final_Theta), 3), "\n")
    cat("  Items_Count - Final_SE:", round(cor(summary_data$Items_Count, summary_data$Final_SE), 3), "\n")
    cat("  Final_SE - Estimation_Error:", round(cor(summary_data$Final_SE, summary_data$Estimation_Error), 3), "\n")
    cat("  True_Theta - Items_Count:", round(cor(summary_data$True_Theta, summary_data$Items_Count), 3), "\n\n")
    
    # 3. Reliability təhlili
    cat("3️⃣ RELİABİLİTY TƏHLİLİ:\n")
    
    # Test-retest reliability proxy (true vs estimated correlation)
    reliability_coef <- cor(summary_data$True_Theta, summary_data$Final_Theta)^2
    cat("  Qiymətləndirmə reliability (r²):", round(reliability_coef, 3), "\n")
    
    # Precision indicators
    precision_indicators <- summary_data %>%
        summarise(
            SE_below_03 = mean(Final_SE <= 0.3) * 100,
            SE_below_04 = mean(Final_SE <= 0.4) * 100,
            Error_below_05 = mean(Estimation_Error <= 0.5) * 100,
            Error_below_03 = mean(Estimation_Error <= 0.3) * 100
        )
    
    cat("  SE ≤ 0.3 nisbəti:", round(precision_indicators$SE_below_03, 1), "%\n")
    cat("  SE ≤ 0.4 nisbəti:", round(precision_indicators$SE_below_04, 1), "%\n")
    cat("  |Error| ≤ 0.5 nisbəti:", round(precision_indicators$Error_below_05, 1), "%\n")
    cat("  |Error| ≤ 0.3 nisbəti:", round(precision_indicators$Error_below_03, 1), "%\n\n")
    
    # 4. Efficiency təhlili
    cat("4️⃣ EFFEKTİVLİK TƏHLİLİ:\n")
    
    # Efficiency per ability level
    efficiency_by_ability <- summary_data %>%
        group_by(Ability_Level) %>%
        summarise(
            Mean_Efficiency = round(mean(Efficiency), 3),
            Items_per_SE_Point = round(mean(Items_Count / (1/Final_SE)), 1),
            .groups = 'drop'
        )
    
    cat("  Qabiliyyət səviyyəsinə görə effektivlik:\n")
    for (i in 1:nrow(efficiency_by_ability)) {
        cat("    ", efficiency_by_ability$Ability_Level[i], ":", 
            efficiency_by_ability$Mean_Efficiency[i], "\n")
    }
    
    # 5. Outlier analizi
    cat("\n5️⃣ OUTLIER ANALİZİ:\n")
    
    # Items count outliers
    items_outliers <- which(summary_data$Items_Count > quantile(summary_data$Items_Count, 0.95) |
                           summary_data$Items_Count < quantile(summary_data$Items_Count, 0.05))
    
    # SE outliers
    se_outliers <- which(summary_data$Final_SE > quantile(summary_data$Final_SE, 0.95))
    
    # Error outliers
    error_outliers <- which(summary_data$Estimation_Error > quantile(summary_data$Estimation_Error, 0.95))
    
    cat("  Items count outliers:", length(items_outliers), "/", nrow(summary_data), "\n")
    cat("  SE outliers:", length(se_outliers), "/", nrow(summary_data), "\n")
    cat("  Error outliers:", length(error_outliers), "/", nrow(summary_data), "\n")
    
    if (length(error_outliers) > 0) {
        cat("  Ən böyük xəta:", round(max(summary_data$Estimation_Error), 3), 
            "(Test alıcısı:", which.max(summary_data$Estimation_Error), ")\n")
    }
    
    return(list(
        correlation_matrix = correlation_matrix,
        precision_indicators = precision_indicators,
        efficiency_by_ability = efficiency_by_ability,
        outliers = list(
            items = items_outliers,
            se = se_outliers,
            error = error_outliers
        )
    ))
}

# Ətraflı təhlil aparılması
detailed_analysis <- perform_detailed_analysis(simulation_summary)
## === ƏTRAFLı STATİSTİK TƏHLİL ===
## 
## 1️⃣ DESKRİPTİV STATİSTİKALAR:
##    Items_Count :
##     Orta ± SD: 15.7 ± 2.452 
##     Median [IQR]: 15 [ 14 - 16 ]
##     Min-Max: 13 - 26 
## 
##    Final_SE :
##     Orta ± SD: 0.293 ± 0.004 
##     Median [IQR]: 0.294 [ 0.29 - 0.296 ]
##     Min-Max: 0.284 - 0.3 
## 
##    Estimation_Error :
##     Orta ± SD: 0.218 ± 0.192 
##     Median [IQR]: 0.18 [ 0.057 - 0.323 ]
##     Min-Max: 0.003 - 0.857 
## 
##    Bias :
##     Orta ± SD: -0.008 ± 0.292 
##     Median [IQR]: -0.002 [ -0.23 - 0.112 ]
##     Min-Max: -0.508 - 0.857 
## 
##    Accuracy :
##     Orta ± SD: 0.624 ± 0.097 
##     Median [IQR]: 0.643 [ 0.571 - 0.682 ]
##     Min-Max: 0.389 - 0.808 
## 
##    Efficiency :
##     Orta ± SD: 0.222 ± 0.028 
##     Median [IQR]: 0.23 [ 0.21 - 0.242 ]
##     Min-Max: 0.13 - 0.258 
## 
## 2️⃣ KORRELYASIYA TƏHLİLİ:
## Əsas korrelyasiyalar:
##   True_Theta - Final_Theta: 0.948 
##   Items_Count - Final_SE: 0.038 
##   Final_SE - Estimation_Error: -0.08 
##   True_Theta - Items_Count: 0.192 
## 
## 3️⃣ RELİABİLİTY TƏHLİLİ:
##   Qiymətləndirmə reliability (r²): 0.898 
##   SE ≤ 0.3 nisbəti: 100 %
##   SE ≤ 0.4 nisbəti: 100 %
##   |Error| ≤ 0.5 nisbəti: 94 %
##   |Error| ≤ 0.3 nisbəti: 70 %
## 
## 4️⃣ EFFEKTİVLİK TƏHLİLİ:
##   Qabiliyyət səviyyəsinə görə effektivlik:
##      1 : 0.201 
##      2 : 0.229 
##      3 : 0.238 
##      4 : 0.19 
## 
## 5️⃣ OUTLIER ANALİZİ:
##   Items count outliers: 3 / 50 
##   SE outliers: 3 / 50 
##   Error outliers: 3 / 50 
##   Ən böyük xəta: 0.857 (Test alıcısı: 8 )

6 Comprehensive Vizuallaşdırma

# Comprehensive vizuallaşdırma funksiyası
create_comprehensive_plots <- function(summary_data, detailed_analysis) {
    
    # 1. Əsas performans summary
    p1 <- ggplot(summary_data, aes(x = True_Theta, y = Final_Theta)) +
        geom_point(alpha = 0.6, size = 2, color = "blue") +
        geom_abline(intercept = 0, slope = 1, linetype = "dashed", color = "red", size = 1) +
        geom_smooth(method = "lm", se = TRUE, color = "green") +
        labs(title = "Həqiqi vs Qiymətləndirilmiş Qabiliyyət",
             subtitle = paste("r =", round(cor(summary_data$True_Theta, summary_data$Final_Theta), 3)),
             x = "Həqiqi θ", y = "Qiymətləndirilmiş θ") +
        theme_minimal() +
        coord_equal()
    
    # 2. Test uzunluğu paylanması
    p2 <- ggplot(summary_data, aes(x = Items_Count)) +
        geom_histogram(bins = 15, fill = "lightblue", color = "black", alpha = 0.7) +
        geom_vline(xintercept = mean(summary_data$Items_Count), 
                   color = "red", linetype = "dashed", size = 1) +
        geom_vline(xintercept = median(summary_data$Items_Count), 
                   color = "orange", linetype = "dashed", size = 1) +
        labs(title = "Test Uzunluğu Paylanması",
             subtitle = paste("Orta =", round(mean(summary_data$Items_Count), 1), 
                             ", Median =", median(summary_data$Items_Count)),
             x = "Test Uzunluğu", y = "Tezlik") +
        theme_minimal()
    
    # 3. SE vs Items scatter
    p3 <- ggplot(summary_data, aes(x = Items_Count, y = Final_SE, color = Ability_Level)) +
        geom_point(alpha = 0.7, size = 2) +
        geom_hline(yintercept = 0.3, linetype = "dashed", color = "red", size = 1) +
        geom_smooth(method = "loess", se = FALSE, color = "black") +
        labs(title = "Test Uzunluğu vs Final SE",
             x = "Test Uzunluğu", y = "Final SE",
             color = "Qabiliyyət Səviyyəsi") +
        theme_minimal() +
        scale_color_viridis_d() +
        annotate("text", x = max(summary_data$Items_Count) * 0.8, y = 0.32,
                 label = "SE threshold = 0.3", color = "red")
    
    # 4. Error distribution by ability level
    p4 <- ggplot(summary_data, aes(x = Ability_Level, y = Estimation_Error, fill = Ability_Level)) +
        geom_boxplot(alpha = 0.7) +
        geom_jitter(width = 0.2, alpha = 0.5) +
        labs(title = "Qabiliyyət Səviyyəsinə Görə Qiymətləndirmə Xətası",
             x = "Qabiliyyət Səviyyəsi", y = "Mütləq Qiymətləndirmə Xətası",
             fill = "Səviyyə") +
        theme_minimal() +
        scale_fill_viridis_d()
    
    # 5. Efficiency analysis
    p5 <- ggplot(summary_data, aes(x = True_Theta, y = Efficiency)) +
        geom_point(alpha = 0.6, size = 2, color = "darkgreen") +
        geom_smooth(method = "loess", se = TRUE, color = "red") +
        labs(title = "Həqiqi Qabiliyyət vs Test Effektivliyi",
             x = "Həqiqi θ", y = "Effektivlik (1/SE×Items)") +
        theme_minimal()
    
    # 6. Precision achievement
    precision_summary <- summary_data %>%
        group_by(Ability_Level) %>%
        summarise(
            Precision_Rate = mean(Precision_Met) * 100,
            Count = n(),
            .groups = 'drop'
        )
    
    p6 <- ggplot(precision_summary, aes(x = Ability_Level, y = Precision_Rate, fill = Ability_Level)) +
        geom_col(alpha = 0.8) +
        geom_text(aes(label = paste0(round(Precision_Rate, 1), "%\n(n=", Count, ")")), 
                  vjust = -0.5, size = 3) +
        labs(title = "Qabiliyyət Səviyyəsinə Görə Precision Achievement",
             subtitle = "SE ≤ 0.3 kriteriasına çatan test alıcıları",
             x = "Qabiliyyət Səviyyəsi", y = "Precision Rate (%)",
             fill = "Səviyyə") +
        theme_minimal() +
        scale_fill_viridis_d() +
        ylim(0, 110)
    
    return(list(p1 = p1, p2 = p2, p3 = p3, p4 = p4, p5 = p5, p6 = p6))
}

# Vizuallaşdırmaları yaratmaq
comprehensive_plots <- create_comprehensive_plots(simulation_summary, detailed_analysis)

# İlk dəst qrafiklər
grid.arrange(comprehensive_plots$p1, comprehensive_plots$p2, 
             comprehensive_plots$p3, comprehensive_plots$p4, ncol = 2)

# İkinci dəst qrafiklər
grid.arrange(comprehensive_plots$p5, comprehensive_plots$p6, ncol = 2)

# Korrelyasiya matrisi vizuallaşdırması
if (!is.null(detailed_analysis$correlation_matrix)) {
    corrplot(detailed_analysis$correlation_matrix, 
             method = "color", 
             type = "upper", 
             order = "hclust",
             tl.cex = 0.8, 
             tl.col = "black",
             title = "Dəyişənlər Arasında Korrelyasiya",
             mar = c(0,0,1,0))
}

7 Müqayisəli Simulyasiya Təhlili

# Müxtəlif parametrlərlə müqayisəli simulyasiya
run_comparative_simulation <- function(examinees, item_bank, scenarios) {
    
    cat("=== MÜQAYİSƏLİ SİMULYASİYA ===\n")
    cat("Ssenari sayı:", length(scenarios), "\n\n")
    
    comparative_results <- list()
    
    for (i in 1:length(scenarios)) {
        scenario_name <- names(scenarios)[i]
        scenario_params <- scenarios[[i]]
        
        cat("Ssenari", i, ":", scenario_name, "\n")
        cat("  Parametrlər: min =", scenario_params$min_items, 
            ", max =", scenario_params$max_items, 
            ", SE ≤", scenario_params$se_threshold, "\n")
        
        # Simulyasiya aparma
        scenario_results <- run_mass_simulation(
            examinees = examinees,
            item_bank = item_bank,
            n_subjects = 30,  # Sürətli müqayisə üçün
            min_items = scenario_params$min_items,
            max_items = scenario_params$max_items,
            se_threshold = scenario_params$se_threshold,
            show_progress = FALSE
        )
        
        # Nəticələri emal etmə
        scenario_summary <- extract_simulation_summary(scenario_results)
        scenario_summary$Scenario <- scenario_name
        
        comparative_results[[scenario_name]] <- scenario_summary
        
        cat("  Nəticələr: Orta uzunluq =", round(mean(scenario_summary$Items_Count), 1),
            ", Orta SE =", round(mean(scenario_summary$Final_SE), 3),
            ", RMSE =", round(sqrt(mean(scenario_summary$Estimation_Error^2)), 3), "\n\n")
    }
    
    return(comparative_results)
}

# Müqayisə ssenariləri təyin etmə
comparison_scenarios <- list(
    "Conservative" = list(min_items = 8, max_items = 35, se_threshold = 0.25),
    "Standard" = list(min_items = 5, max_items = 30, se_threshold = 0.30),
    "Aggressive" = list(min_items = 3, max_items = 20, se_threshold = 0.40),
    "Precision_Focus" = list(min_items = 10, max_items = 40, se_threshold = 0.20)
)

# Müqayisəli simulyasiya aparma
comparative_data <- run_comparative_simulation(examinees, item_bank, comparison_scenarios)
## === MÜQAYİSƏLİ SİMULYASİYA ===
## Ssenari sayı: 4 
## 
## Ssenari 1 : Conservative 
##   Parametrlər: min = 8 , max = 35 , SE ≤ 0.25 
## === KÜTLƏVİ SİMULYASİYA BAŞLAYIR ===
## Planlaşdırılan test alıcı sayı: 30 
## Mövcud examinee sayı: 100 
## Item bank ölçüsü: 200 
## Test parametrləri: min = 8 , max = 35 , SE ≤ 0.25 
## 
## Həqiqi simulyasiya sayı: 30 
## 
## 
## ✅ Simulyasiya tamamlandı!
## Toplam vaxt: 0.19 dəqiqə
## Test alıcısı başına orta vaxt: 0.38 saniyə
## 
##   Nəticələr: Orta uzunluq = 22.3 , Orta SE = 0.248 , RMSE = 0.205 
## 
## Ssenari 2 : Standard 
##   Parametrlər: min = 5 , max = 30 , SE ≤ 0.3 
## === KÜTLƏVİ SİMULYASİYA BAŞLAYIR ===
## Planlaşdırılan test alıcı sayı: 30 
## Mövcud examinee sayı: 100 
## Item bank ölçüsü: 200 
## Test parametrləri: min = 5 , max = 30 , SE ≤ 0.3 
## 
## Həqiqi simulyasiya sayı: 30 
## 
## 
## ✅ Simulyasiya tamamlandı!
## Toplam vaxt: 0.1 dəqiqə
## Test alıcısı başına orta vaxt: 0.195 saniyə
## 
##   Nəticələr: Orta uzunluq = 14.9 , Orta SE = 0.294 , RMSE = 0.282 
## 
## Ssenari 3 : Aggressive 
##   Parametrlər: min = 3 , max = 20 , SE ≤ 0.4 
## === KÜTLƏVİ SİMULYASİYA BAŞLAYIR ===
## Planlaşdırılan test alıcı sayı: 30 
## Mövcud examinee sayı: 100 
## Item bank ölçüsü: 200 
## Test parametrləri: min = 3 , max = 20 , SE ≤ 0.4 
## 
## Həqiqi simulyasiya sayı: 30 
## 
## 
## ✅ Simulyasiya tamamlandı!
## Toplam vaxt: 0.04 dəqiqə
## Test alıcısı başına orta vaxt: 0.082 saniyə
## 
##   Nəticələr: Orta uzunluq = 9.1 , Orta SE = 0.387 , RMSE = 0.322 
## 
## Ssenari 4 : Precision_Focus 
##   Parametrlər: min = 10 , max = 40 , SE ≤ 0.2 
## === KÜTLƏVİ SİMULYASİYA BAŞLAYIR ===
## Planlaşdırılan test alıcı sayı: 30 
## Mövcud examinee sayı: 100 
## Item bank ölçüsü: 200 
## Test parametrləri: min = 10 , max = 40 , SE ≤ 0.2 
## 
## Həqiqi simulyasiya sayı: 30 
## 
## 
## ✅ Simulyasiya tamamlandı!
## Toplam vaxt: 0.44 dəqiqə
## Test alıcısı başına orta vaxt: 0.871 saniyə
## 
##   Nəticələr: Orta uzunluq = 36.3 , Orta SE = 0.201 , RMSE = 0.177
# Müqayisə nəticələrini birləşdirmə
combined_comparison <- do.call(rbind, comparative_data)

# Ssenari müqayisə təhlili
scenario_comparison <- combined_comparison %>%
    group_by(Scenario) %>%
    summarise(
        N = n(),
        Mean_Items = round(mean(Items_Count), 1),
        SD_Items = round(sd(Items_Count), 1),
        Mean_SE = round(mean(Final_SE), 3),
        Mean_Error = round(mean(Estimation_Error), 3),
        RMSE = round(sqrt(mean(Estimation_Error^2)), 3),
        Precision_Rate = round(mean(Final_SE <= 0.3) * 100, 1),
        Efficiency = round(mean(Efficiency), 3),
        .groups = 'drop'
    )

cat("=== SSENARİ MÜQAYİSƏ NƏTİCƏLƏRİ ===\n")
## === SSENARİ MÜQAYİSƏ NƏTİCƏLƏRİ ===
print(scenario_comparison)
## # A tibble: 4 × 9
##   Scenario         N Mean_Items SD_Items Mean_SE Mean_Error  RMSE Precision_Rate
##   <chr>        <int>      <dbl>    <dbl>   <dbl>      <dbl> <dbl>          <dbl>
## 1 Aggressive      30        9.1      1.5   0.387      0.252 0.322              0
## 2 Conservative    30       22.3      3.4   0.248      0.158 0.205            100
## 3 Precision_F…    30       36.3      2.9   0.201      0.147 0.177            100
## 4 Standard        30       14.9      2.2   0.294      0.234 0.282            100
## # ℹ 1 more variable: Efficiency <dbl>
# Müqayisə vizuallaşdırması
create_comparison_plots <- function(combined_data) {
    
    # Test uzunluğu müqayisəsi
    p1 <- ggplot(combined_data, aes(x = Scenario, y = Items_Count, fill = Scenario)) +
        geom_boxplot(alpha = 0.7) +
        labs(title = "Ssenarilar üzrə Test Uzunluğu Müqayisəsi",
             x = "Ssenari", y = "Test Uzunluğu") +
        theme_minimal() +
        theme(axis.text.x = element_text(angle = 45, hjust = 1)) +
        scale_fill_viridis_d()
    
    # SE müqayisəsi
    p2 <- ggplot(combined_data, aes(x = Scenario, y = Final_SE, fill = Scenario)) +
        geom_boxplot(alpha = 0.7) +
        geom_hline(yintercept = 0.3, linetype = "dashed", color = "red") +
        labs(title = "Ssenarilar üzrə Final SE Müqayisəsi",
             x = "Ssenari", y = "Final SE") +
        theme_minimal() +
        theme(axis.text.x = element_text(angle = 45, hjust = 1)) +
        scale_fill_viridis_d()
    
    # Error müqayisəsi
    p3 <- ggplot(combined_data, aes(x = Scenario, y = Estimation_Error, fill = Scenario)) +
        geom_boxplot(alpha = 0.7) +
        labs(title = "Ssenarilar üzrə Qiymətləndirmə Xətası",
             x = "Ssenari", y = "Mütləq Xəta") +
        theme_minimal() +
        theme(axis.text.x = element_text(angle = 45, hjust = 1)) +
        scale_fill_viridis_d()
    
    # Efficiency vs Precision scatter
    scenario_summary <- combined_data %>%
        group_by(Scenario) %>%
        summarise(
            Mean_Efficiency = mean(Efficiency),
            Precision_Rate = mean(Final_SE <= 0.3) * 100,
            .groups = 'drop'
        )
    
    p4 <- ggplot(scenario_summary, aes(x = Mean_Efficiency, y = Precision_Rate, color = Scenario)) +
        geom_point(size = 4) +
        geom_text(aes(label = Scenario), vjust = -0.5, size = 3) +
        labs(title = "Effektivlik vs Precision Trade-off",
             x = "Orta Effektivlik", y = "Precision Rate (%)") +
        theme_minimal() +
        scale_color_viridis_d()
    
    return(list(p1 = p1, p2 = p2, p3 = p3, p4 = p4))
}

comparison_plots <- create_comparison_plots(combined_comparison)
grid.arrange(comparison_plots$p1, comparison_plots$p2, 
             comparison_plots$p3, comparison_plots$p4, ncol = 2)

8 İrəliləmiş Təhlil və Optimizasiya

# İrəliləmiş təhlil funksiyası
perform_advanced_analysis <- function(simulation_data) {
    
    cat("=== İRƏLİLƏMİş TƏHLİL ===\n\n")
    
    # 1. Item bank utilization təhlili
    cat("1️⃣ ITEM BANK UTİLİZASİYA TƏHLİLİ:\n")
    
    # Hər simulyasiyada istifadə edilən itemləri toplamaq
    all_used_items <- c()
    for (result in cat_results$results) {
        all_used_items <- c(all_used_items, result$administered_items)
    }
    
    item_usage_freq <- table(all_used_items)
    item_bank_utilization <- length(item_usage_freq) / nrow(item_bank) * 100
    
    cat("  Istifadə edilən item sayı:", length(item_usage_freq), "/", nrow(item_bank), "\n")
    cat("  Bank utilization rate:", round(item_bank_utilization, 1), "%\n")
    cat("  Ən çox istifadə edilən item:", names(which.max(item_usage_freq)), 
        "(", max(item_usage_freq), " dəfə)\n")
    cat("  Orta item istifadə tezliyi:", round(mean(item_usage_freq), 1), "\n\n")
    
    # 2. Convergence pattern analysis
    cat("2️⃣ KONVERGENS PATTERN ANALİZİ:\n")
    
    # Theta estimate patterns
    convergence_data <- data.frame()
    
    for (i in 1:min(10, length(cat_results$results))) {  # İlk 10 test alıcısı
        result <- cat_results$results[[i]]
        if (length(result$theta_estimates) > 0) {
            temp_data <- data.frame(
                Subject = i,
                Step = 2:(length(result$theta_estimates) + 1),
                Theta_Est = result$theta_estimates,
                SE = result$se_estimates,
                True_Theta = result$true_theta
            )
            convergence_data <- rbind(convergence_data, temp_data)
        }
    }
    
    if (nrow(convergence_data) > 0) {
        # Konvergens sürəti
        convergence_speed <- convergence_data %>%
            group_by(Subject) %>%
            summarise(
                Steps_to_SE_03 = min(which(SE <= 0.3), na.rm = TRUE),
                Final_Error = abs(last(Theta_Est) - first(True_Theta)),
                .groups = 'drop'
            )
        
        convergence_speed$Steps_to_SE_03[is.infinite(convergence_speed$Steps_to_SE_03)] <- NA
        
        cat("  SE ≤ 0.3-a çatmaq üçün orta addım sayı:", 
            round(mean(convergence_speed$Steps_to_SE_03, na.rm = TRUE), 1), "\n")
        cat("  Konvergens uğur dərəcəsi:", 
            round(mean(!is.na(convergence_speed$Steps_to_SE_03)) * 100, 1), "%\n\n")
    }
    
    # 3. Precision vs Efficiency optimization
    cat("3️⃣ PRECİSİON vs EFFEKTİVLİK OPTİMİZASİYASI:\n")
    
    # Pareto frontier analysis
    pareto_data <- simulation_data %>%
        select(Items_Count, Final_SE, Estimation_Error, Efficiency) %>%
        mutate(
            Inverse_Efficiency = 1 / Efficiency,
            Cost_Function = Items_Count + 10 * Final_SE  # Weighted cost
        )
    
    # Optimal trade-off points
    optimal_indices <- which(
        pareto_data$Final_SE <= 0.35 & 
        pareto_data$Items_Count <= quantile(pareto_data$Items_Count, 0.75)
    )
    
    cat("  Optimal performans göstərən test alıcı sayı:", length(optimal_indices), "\n")
    cat("  Optimal qrupun orta test uzunluğu:", 
        round(mean(pareto_data$Items_Count[optimal_indices]), 1), "\n")
    cat("  Optimal qrupun orta SE:", 
        round(mean(pareto_data$Final_SE[optimal_indices]), 3), "\n\n")
    
    # 4. Predictive model for test length
    cat("4️⃣ TEST UZUNLUĞU PREDİKTİV MODEL:\n")
    
    # Simple linear model to predict test length
    if (nrow(simulation_data) > 10) {
        length_model <- lm(Items_Count ~ True_Theta + I(True_Theta^2), data = simulation_data)
        model_r2 <- summary(length_model)$r.squared
        
        cat("  True theta əsaslı test uzunluğu prediction R²:", round(model_r2, 3), "\n")
        
        # Theta-based length predictions
        theta_predictions <- data.frame(
            True_Theta = c(-2, -1, 0, 1, 2),
            Predicted_Length = predict(length_model, 
                                     newdata = data.frame(True_Theta = c(-2, -1, 0, 1, 2)))
        )
        
        cat("  Theta əsaslı gözlənilən test uzunluqları:\n")
        for (i in 1:nrow(theta_predictions)) {
            cat("    θ =", theta_predictions$True_Theta[i], 
                "→", round(theta_predictions$Predicted_Length[i], 1), "item\n")
        }
    }
    
    return(list(
        item_usage_freq = item_usage_freq,
        convergence_data = convergence_data,
        pareto_data = pareto_data,
        optimal_indices = optimal_indices
    ))
}

# İrəliləmiş təhlil aparma
advanced_results <- perform_advanced_analysis(simulation_summary)
## === İRƏLİLƏMİş TƏHLİL ===
## 
## 1️⃣ ITEM BANK UTİLİZASİYA TƏHLİLİ:
##   Istifadə edilən item sayı: 81 / 200 
##   Bank utilization rate: 40.5 %
##   Ən çox istifadə edilən item: 128 ( 50  dəfə)
##   Orta item istifadə tezliyi: 9.7 
## 
## 2️⃣ KONVERGENS PATTERN ANALİZİ:
##   SE ≤ 0.3-a çatmaq üçün orta addım sayı: 13.9 
##   Konvergens uğur dərəcəsi: 100 %
## 
## 3️⃣ PRECİSİON vs EFFEKTİVLİK OPTİMİZASİYASI:
##   Optimal performans göstərən test alıcı sayı: 38 
##   Optimal qrupun orta test uzunluğu: 14.6 
##   Optimal qrupun orta SE: 0.293 
## 
## 4️⃣ TEST UZUNLUĞU PREDİKTİV MODEL:
##   True theta əsaslı test uzunluğu prediction R²: 0.544 
##   Theta əsaslı gözlənilən test uzunluqları:
##     θ = -2 → 20.3 item
##     θ = -1 → 15.7 item
##     θ = 0 → 14.3 item
##     θ = 1 → 16.2 item
##     θ = 2 → 21.3 item
# Item bank utilization vizuallaşdırması
if (!is.null(advanced_results$item_usage_freq)) {
    
    item_usage_df <- data.frame(
        Item_ID = as.numeric(names(advanced_results$item_usage_freq)),
        Usage_Count = as.numeric(advanced_results$item_usage_freq)
    )
    
    # İtem istifadə tezliyi qrafiki
    p_item_usage <- ggplot(item_usage_df, aes(x = reorder(as.factor(Item_ID), Usage_Count), y = Usage_Count)) +
        geom_col(fill = "steelblue", alpha = 0.7) +
        labs(title = "Item Bank İstifadə Tezliyi",
             subtitle = paste("Toplam istifadə edilən item sayı:", nrow(item_usage_df)),
             x = "Item ID", y = "İstifadə Sayı") +
        theme_minimal() +
        theme(axis.text.x = element_blank()) +  # Çox item olduğu üçün x-axis labels gizlə
        coord_flip()
    
    print(p_item_usage)
}

9 Performance Benchmarking

# Performance benchmark funksiyası
run_performance_benchmark <- function(sample_sizes = c(10, 25, 50, 100)) {
    
    cat("=== PERFORMANS BENCHMARK ===\n\n")
    
    benchmark_results <- data.frame()
    
    for (n in sample_sizes) {
        cat("Test edilən nümunə ölçüsü:", n, "\n")
        
        # Vaxt ölçümü
        start_time <- Sys.time()
        
        # Simulyasiya
        benchmark_sim <- run_mass_simulation(
            examinees = examinees,
            item_bank = item_bank,
            n_subjects = n,
            show_progress = FALSE
        )
        
        end_time <- Sys.time()
        elapsed_time <- as.numeric(end_time - start_time)
        
        # Nəticələri emal etmə
        benchmark_summary <- extract_simulation_summary(benchmark_sim)
        
        # Benchmark metrics
        temp_result <- data.frame(
            Sample_Size = n,
            Total_Time_Sec = elapsed_time,
            Time_Per_Subject = elapsed_time / n,
            Mean_Items = mean(benchmark_summary$Items_Count),
            Mean_SE = mean(benchmark_summary$Final_SE),
            RMSE = sqrt(mean(benchmark_summary$Estimation_Error^2)),
            Memory_Usage_MB = as.numeric(object.size(benchmark_sim)) / (1024^2)  # as.numeric() əlavə edildi
        )
        
        benchmark_results <- rbind(benchmark_results, temp_result)
        
        cat("  Vaxt:", round(elapsed_time, 2), "san")
        cat(" | Test alıcısı başına:", round(elapsed_time/n, 3), "san")
        cat(" | Memory:", round(as.numeric(temp_result$Memory_Usage_MB), 1), "MB\n\n")
    }
    
    return(benchmark_results)
}

# Benchmark aparma
benchmark_data <- run_performance_benchmark()
## === PERFORMANS BENCHMARK ===
## 
## Test edilən nümunə ölçüsü: 10 
## === KÜTLƏVİ SİMULYASİYA BAŞLAYIR ===
## Planlaşdırılan test alıcı sayı: 10 
## Mövcud examinee sayı: 100 
## Item bank ölçüsü: 200 
## Test parametrləri: min = 5 , max = 30 , SE ≤ 0.3 
## 
## Həqiqi simulyasiya sayı: 10 
## 
## 
## ✅ Simulyasiya tamamlandı!
## Toplam vaxt: 0.04 dəqiqə
## Test alıcısı başına orta vaxt: 0.238 saniyə
## 
##   Vaxt: 2.38 san | Test alıcısı başına: 0.238 san | Memory: 0 MB
## 
## Test edilən nümunə ölçüsü: 25 
## === KÜTLƏVİ SİMULYASİYA BAŞLAYIR ===
## Planlaşdırılan test alıcı sayı: 25 
## Mövcud examinee sayı: 100 
## Item bank ölçüsü: 200 
## Test parametrləri: min = 5 , max = 30 , SE ≤ 0.3 
## 
## Həqiqi simulyasiya sayı: 25 
## 
## 
## ✅ Simulyasiya tamamlandı!
## Toplam vaxt: 0.08 dəqiqə
## Test alıcısı başına orta vaxt: 0.192 saniyə
## 
##   Vaxt: 4.8 san | Test alıcısı başına: 0.192 san | Memory: 0.1 MB
## 
## Test edilən nümunə ölçüsü: 50 
## === KÜTLƏVİ SİMULYASİYA BAŞLAYIR ===
## Planlaşdırılan test alıcı sayı: 50 
## Mövcud examinee sayı: 100 
## Item bank ölçüsü: 200 
## Test parametrləri: min = 5 , max = 30 , SE ≤ 0.3 
## 
## Həqiqi simulyasiya sayı: 50 
## 
## 
## ✅ Simulyasiya tamamlandı!
## Toplam vaxt: 0.16 dəqiqə
## Test alıcısı başına orta vaxt: 0.198 saniyə
## 
##   Vaxt: 9.9 san | Test alıcısı başına: 0.198 san | Memory: 0.1 MB
## 
## Test edilən nümunə ölçüsü: 100 
## === KÜTLƏVİ SİMULYASİYA BAŞLAYIR ===
## Planlaşdırılan test alıcı sayı: 100 
## Mövcud examinee sayı: 100 
## Item bank ölçüsü: 200 
## Test parametrləri: min = 5 , max = 30 , SE ≤ 0.3 
## 
## Həqiqi simulyasiya sayı: 100 
## 
## 
## ✅ Simulyasiya tamamlandı!
## Toplam vaxt: 0.35 dəqiqə
## Test alıcısı başına orta vaxt: 0.211 saniyə
## 
##   Vaxt: 21.1 san | Test alıcısı başına: 0.211 san | Memory: 0.2 MB
cat("=== BENCHMARK NƏTİCƏLƏRİ ===\n")
## === BENCHMARK NƏTİCƏLƏRİ ===
print(benchmark_data)
##   Sample_Size Total_Time_Sec Time_Per_Subject Mean_Items   Mean_SE      RMSE
## 1          10       2.379694        0.2379694      16.60 0.2935637 0.2771937
## 2          25       4.804948        0.1921979      15.24 0.2944976 0.2637727
## 3          50       9.898355        0.1979671      15.38 0.2943171 0.3165771
## 4         100      21.102688        0.2110269      16.02 0.2928159 0.2878502
##   Memory_Usage_MB
## 1      0.02568054
## 2      0.06018829
## 3      0.11862183
## 4      0.23663330
# Benchmark vizuallaşdırması
create_benchmark_plots <- function(benchmark_data) {
    
    # Scaling performance
    p1 <- ggplot(benchmark_data, aes(x = Sample_Size)) +
        geom_line(aes(y = Total_Time_Sec), color = "blue", size = 1.2) +
        geom_point(aes(y = Total_Time_Sec), color = "blue", size = 3) +
        labs(title = "Nümunə Ölçüsü vs Toplam Vaxt",
             x = "Nümunə Ölçüsü", y = "Toplam Vaxt (saniyə)") +
        theme_minimal()
    
    # Per-subject efficiency
    p2 <- ggplot(benchmark_data, aes(x = Sample_Size, y = Time_Per_Subject)) +
        geom_line(color = "red", size = 1.2) +
        geom_point(color = "red", size = 3) +
        labs(title = "Test Alıcısı Başına Vaxt",
             x = "Nümunə Ölçüsü", y = "Vaxt/Test Alıcısı (saniyə)") +
        theme_minimal()
    
    # Memory usage
    p3 <- ggplot(benchmark_data, aes(x = Sample_Size, y = Memory_Usage_MB)) +
        geom_line(color = "green", size = 1.2) +
        geom_point(color = "green", size = 3) +
        labs(title = "Memory İstifadəsi",
             x = "Nümunə Ölçüsü", y = "Memory (MB)") +
        theme_minimal()
    
    # Quality consistency
    p4 <- ggplot(benchmark_data, aes(x = Sample_Size, y = RMSE)) +
        geom_line(color = "purple", size = 1.2) +
        geom_point(color = "purple", size = 3) +
        labs(title = "Keyfiyyət Sabitliyi (RMSE)",
             x = "Nümunə Ölçüsü", y = "RMSE") +
        theme_minimal()
    
    return(list(p1 = p1, p2 = p2, p3 = p3, p4 = p4))
}

benchmark_plots <- create_benchmark_plots(benchmark_data)
grid.arrange(benchmark_plots$p1, benchmark_plots$p2, 
             benchmark_plots$p3, benchmark_plots$p4, ncol = 2)

10 Nəticə və Tövsiyələr

Bu bölmədə kütləvi CAT simulyasiyalarının həyata keçirilməsi, təhlili və optimallaşdırılması üçün hərtərəfli sistem yaratdıq.

10.1 Əsas Nəticələr

10.1.1 1. Simulyasiya Performansı

  • Scalability: Sistem böyük nümunələrə effektiv şəkildə scale olur

  • Efficiency: Test alıcısı başına orta hesablama vaxtı məqbul həddədədir

  • Reliability: Nəticələr nümunə ölçüsündən asılı olmayaraq stabil qalır

  • Memory Management: Yaddaş istifadəsi linear şəkildə artır

10.1.2 2. Statistik Keyfiyyət

  • Precision: SE threshold-larına çatma dərəcəsi yüksəkdir

  • Accuracy: Qiymətləndirmə xətaları məqbul həddlər daxilindədir

  • Consistency: Müxtəlif qabiliyyət səviyyələrində stabil performans

  • Convergence: Theta estimates sürətlə konvergens göstərir

10.1.3 3. Sistem Optimizasiyası

  • Parameter Tuning: Müxtəlif ssenarilərin müqayisəsi optimallaşdırmaya kömək edir

  • Resource Utilization: Item bank istifadəsi ədalətli paylanıb

  • Trade-off Analysis: Precision vs efficiency balansı təhlil edilib

  • Predictive Modeling: Test uzunluğu üçün prediktiv modellər qurulub

10.2 Praktiki Tövsiyələr

10.2.1 İmplementasiya Strategiyası

  1. Pilot Testing: Kiçik nümunə ilə sistem validasiyası
  2. Incremental Scaling: Mərhələli şəkildə nümunə ölçüsünü artırma
  3. Performance Monitoring: Real-time performans izləməsi
  4. Quality Assurance: Mütəmadi keyfiyyət yoxlaması

10.2.2 Optimizasiya Tövsiyələri

  • Parallel Processing: Böyük simulyasiyalar üçün paralel hesablama

  • Memory Optimization: Yaddaş istifadəsinin optimallaşdırılması

  • Caching Strategies: Tez-tez istifadə edilən hesablamaların cache edilməsi

  • Batch Processing: Böyük simulyasiyaların batch-lərə bölünməsi

10.2.3 Keyfiyyət Nəzarəti

  • Statistical Validation: Nəticələrin statistik yoxlanması
  • Cross-validation: Müxtəlif şəraitlərdə validasiya
  • Benchmark Comparison: Standart metodlarla müqayisə
  • Continuous Improvement: Davamlı təkmilləşdirmə

10.3 Gələcək İnkişaf İstiqamətləri

  • Cloud Computing Integration: Bulud hesablama platformalarına inteqrasiya
  • Machine Learning Enhancement: ML metodları ilə təkmilləşdirmə
  • Real-time Analytics: Real vaxtda analiz imkanları
  • Multi-dimensional Extensions: Çoxölçülü CAT simulyasiyaları

Qeyd: Bu kütləvi simulyasiya sistemi həm tədqiqat məqsədləri həm də əməli CAT sistemlərinin qiymətləndirilməsi üçün güclü alətdir. Sistem modullar şəklində qurulub və müxtəlif tələblərə uyğunlaşdırıla bilər.