auto-account-machine/browser-automation-ts/analyze-markov.js
2025-11-27 10:34:59 +08:00

94 lines
3.5 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
* 马尔可夫链分析 - 分析位置之间的转移概率
*/
// 70张成功卡号
const fullCards = [
// 原始16张
'6228367545055812', '6228367548774419', '6228367546781457', '6228367542738949',
'6228367542602400', '6228367548575105', '6228367546496080', '6228367540057649',
'6228367549574719', '6228367548435128', '6228367542797374', '6228367545956423',
'6228367547237848', '6228367540385107', '6228367544252006', '6228367547562054',
// 今天54张
'6228367541130577', '6228367540744030', '6228367549888788', '6228367549131205',
'6228367541450744', '6228367547238010', '6228367547300364', '6228367540814288',
'6228367546042579', '6228367546361755', '6228367542443235', '6228367543564435',
'6228367548400627', '6228367544445204', '6228367542653734', '6228367549976732',
'6228367540810302', '6228367540707201', '6228367545237808', '6228367544322734',
'6228367541880148', '6228367549130520', '6228367547863197', '6228367541210049',
'6228367549031561', '6228367542464926', '6228367542487000', '6228367545452860',
'6228367548491592', '6228367545022853', '6228367545864858', '6228367544742832',
'6228367540023658', '6228367547416988', '6228367547093159', '6228367549198576',
'6228367548160064', '6228367546223252', '6228367544873785', '6228367541299976',
'6228367542940032', '6228367546998937', '6228367545800241', '6228367543770784',
'6228367545976843', '6228367547542551', '6228367543917914', '6228367545657930',
'6228367586381796', '6228367544322809', '6228367549131254', '6228367543917146',
'6228367546998903', '6228367545864460'
];
// 提取后3位不含校验位
const patterns = fullCards.map(card => card.slice(-4, -1));
console.log('=== 马尔可夫链分析:位置转移概率 ===\n');
// 统计转移概率:百位 -> 十位
const transitions = {};
patterns.forEach(p => {
const d1 = p[0]; // 百位
const d2 = p[1]; // 十位
if (!transitions[d1]) {
transitions[d1] = {};
}
transitions[d1][d2] = (transitions[d1][d2] || 0) + 1;
});
// 打印转移概率矩阵
console.log('百位 -> 十位 转移概率:\n');
for (let i = 0; i <= 9; i++) {
if (!transitions[i]) continue;
const total = Object.values(transitions[i]).reduce((sum, count) => sum + count, 0);
console.log(`百位=${i} (${total}次):`);
const sorted = Object.entries(transitions[i])
.sort((a, b) => b[1] - a[1])
.slice(0, 5); // 只显示前5个最高概率
sorted.forEach(([digit, count]) => {
const prob = (count / total * 100).toFixed(1);
console.log(` -> ${digit}: ${count}次 (${prob}%)`);
});
console.log();
}
// 生成转移概率配置
console.log('\n=== 生成马尔可夫转移配置 ===\n');
console.log('const markovTransitions = {');
for (let i = 0; i <= 9; i++) {
if (!transitions[i]) {
console.log(` '${i}': [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], // 无数据,均匀分布`);
continue;
}
const weights = Array.from({length: 10}, (_, j) => transitions[i][j] || 0);
console.log(` '${i}': [${weights.join(', ')}],`);
}
console.log('};');
// 分析是否有明显的模式
console.log('\n=== 关键发现 ===\n');
for (let i = 0; i <= 9; i++) {
if (!transitions[i]) continue;
const total = Object.values(transitions[i]).reduce((sum, count) => sum + count, 0);
const max = Math.max(...Object.values(transitions[i]));
const maxDigit = Object.entries(transitions[i]).find(([_, count]) => count === max)[0];
const maxProb = (max / total * 100).toFixed(1);
if (maxProb > 25) {
console.log(`⚠️ 百位=${i} 时,十位=${maxDigit} 的概率高达 ${maxProb}%`);
}
}