kececinumbers 0.6.3__py3-none-any.whl → 0.6.4__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
kececinumbers/__init__.py CHANGED
@@ -22,7 +22,7 @@ import warnings
22
22
  # importlib.reload(kececinumbers) # F821 undefined name 'kececinumbers'
23
23
 
24
24
  # Paket sürüm numarası
25
- __version__ = "0.6.3"
25
+ __version__ = "0.6.4"
26
26
  __author__ = "Mehmet Keçeci"
27
27
  __email__ = "mkececi@yaani.com"
28
28
 
@@ -42,6 +42,11 @@ __all__ = [
42
42
  '_get_integer_representation',
43
43
  '_parse_quaternion_from_csv',
44
44
  'generate_kececi_vectorial',
45
+ '_plot_comparison',
46
+ '_find_kececi_zeta_zeros',
47
+ '_compute_gue_similarity',
48
+ '_load_zeta_zeros',
49
+ 'analyze_all_types',
45
50
 
46
51
  # --- Core Generation and Analysis ---
47
52
  'unified_generator',
@@ -95,6 +100,12 @@ try:
95
100
  find_kececi_prime_number,
96
101
  plot_numbers,
97
102
  print_detailed_report,
103
+ _plot_comparison,
104
+ _find_kececi_zeta_zeros,
105
+ _compute_gue_similarity,
106
+ _load_zeta_zeros,
107
+ analyze_all_types,
108
+
98
109
 
99
110
  # Constants
100
111
  TYPE_POSITIVE_REAL,
kececinumbers/_version.py CHANGED
@@ -1,7 +1,7 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  # _version.py
3
3
 
4
- __version__ = "0.6.3"
4
+ __version__ = "0.6.4"
5
5
  __license__ = "MIT"
6
6
  __description__ = "Keçeci Numbers: An Exploration of a Dynamic Sequence Across Diverse Number Sets."
7
7
  __author__ = "Mehmet Keçeci"
@@ -39,6 +39,9 @@ import numpy as np
39
39
  import quaternion
40
40
  import random
41
41
  import re
42
+ from scipy.fft import fft, fftfreq
43
+ from scipy.signal import find_peaks
44
+ from scipy.stats import ks_2samp
42
45
  import sympy
43
46
  from typing import Any, Dict, List, Optional, Tuple
44
47
 
@@ -544,6 +547,299 @@ def _parse_quaternion_from_csv(s: str) -> np.quaternion:
544
547
  except (ValueError, IndexError) as e:
545
548
  raise ValueError(f"Geçersiz virgülle ayrılmış kuaterniyon formatı: '{s}'.") from e
546
549
 
550
+ def _load_zeta_zeros(filename="zeta.txt"):
551
+ """
552
+ zeta.txt dosyasından Riemann zeta sıfırlarını yükle.
553
+ Her satırda bir tane sanal kısım (t_n) olmalı.
554
+ """
555
+ try:
556
+ with open(filename, 'r', encoding='utf-8') as file:
557
+ lines = file.readlines()
558
+ zeta_zeros = []
559
+ for line in lines:
560
+ line = line.strip()
561
+ if not line or line.startswith("#"):
562
+ continue
563
+ try:
564
+ zeta_zeros.append(float(line))
565
+ except ValueError:
566
+ print(f"Geçersiz satır atlandı: {line}")
567
+ print(f"{len(zeta_zeros)} adet zeta sıfırı yüklendi.")
568
+ return np.array(zeta_zeros)
569
+ except FileNotFoundError:
570
+ print(f"'{filename}' dosyası bulunamadı.")
571
+ return np.array([])
572
+
573
+ def _compute_gue_similarity(sequence, tolerance=0.5):
574
+ """
575
+ Keçeci dizisinin GUE (Gaussian Unitary Ensemble) istatistiğine ne kadar benzediğini ölçer.
576
+ """
577
+ from . import _get_integer_representation # Döngüsel import için gecikmeli import
578
+
579
+ values = [val for z in sequence if (val := _get_integer_representation(z)) is not None]
580
+ if len(values) < 10:
581
+ return 0.0, 0.0
582
+
583
+ values = np.array(values) - np.mean(values)
584
+ N = len(values)
585
+ powers = np.abs(fft(values))**2
586
+ freqs = fftfreq(N)
587
+
588
+ mask = (freqs > 0)
589
+ freqs_pos = freqs[mask]
590
+ powers_pos = powers[mask]
591
+
592
+ if len(powers_pos) == 0:
593
+ return 0.0, 0.0
594
+
595
+ peaks, _ = find_peaks(powers_pos, height=np.max(powers_pos)*1e-7)
596
+ strong_freqs = freqs_pos[peaks]
597
+
598
+ if len(strong_freqs) < 2:
599
+ return 0.0, 0.0
600
+
601
+ # Ölçekleme: en güçlü pik → 14.134725
602
+ peak_freq = strong_freqs[np.argmax(powers_pos[peaks])]
603
+ scale_factor = 14.134725 / peak_freq
604
+ scaled_freqs = np.sort(strong_freqs * scale_factor)
605
+
606
+ # Level spacings (frekans farkları)
607
+ if len(scaled_freqs) < 2:
608
+ return 0.0, 0.0
609
+ diffs = np.diff(scaled_freqs)
610
+ if np.mean(diffs) == 0:
611
+ return 0.0, 0.0
612
+ diffs_norm = diffs / np.mean(diffs)
613
+
614
+ # GUE örnek üret (Wigner-Dyson)
615
+ def wigner_dyson(s):
616
+ return (32 / np.pi) * s**2 * np.exp(-4 * s**2 / np.pi)
617
+
618
+ s_gue = np.linspace(0.01, 3.0, 1000)
619
+ p_gue = wigner_dyson(s_gue)
620
+ p_gue = p_gue / np.sum(p_gue)
621
+ sample_gue = np.random.choice(s_gue, size=1000, p=p_gue)
622
+
623
+ # KS test: Keçeci vs GUE
624
+ ks_stat, ks_p = ks_2samp(diffs_norm, sample_gue)
625
+ similarity_score = 1.0 - ks_stat # Ne kadar küçükse, o kadar benzer
626
+
627
+ return similarity_score, ks_p
628
+
629
+ def _find_kececi_zeta_zeros(sequence, tolerance=0.5):
630
+ """
631
+ Keçeci dizisinin spektrumundan zeta sıfırlarını tahmin et.
632
+ """
633
+ from . import _get_integer_representation
634
+
635
+ values = [val for z in sequence if (val := _get_integer_representation(z)) is not None]
636
+ if len(values) < 10:
637
+ return [], 0.0
638
+
639
+ values = np.array(values) - np.mean(values)
640
+ N = len(values)
641
+ powers = np.abs(fft(values))**2
642
+ freqs = fftfreq(N)
643
+
644
+ mask = (freqs > 0)
645
+ freqs_pos = freqs[mask]
646
+ powers_pos = powers[mask]
647
+
648
+ if len(powers_pos) == 0:
649
+ return [], 0.0
650
+
651
+ peaks, _ = find_peaks(powers_pos, height=np.max(powers_pos)*1e-7)
652
+ strong_freqs = freqs_pos[peaks]
653
+
654
+ if len(strong_freqs) < 2:
655
+ return [], 0.0
656
+
657
+ # Ölçekleme: en güçlü pik → 14.134725
658
+ peak_freq = strong_freqs[np.argmax(powers_pos[peaks])]
659
+ scale_factor = 14.134725 / peak_freq
660
+ scaled_freqs = np.sort(strong_freqs * scale_factor)
661
+
662
+ # Sıfır adayları (minimumlar)
663
+ t_vals = np.linspace(0, 650, 10000)
664
+ zeta_vals = np.array([sum((scaled_freqs + 1e-10)**(- (0.5 + 1j * t))) for t in t_vals])
665
+ minima, _ = find_peaks(-np.abs(zeta_vals), height=-0.5*np.max(np.abs(zeta_vals)), distance=5)
666
+ kececi_zeta_zeros = t_vals[minima]
667
+
668
+ # Eşleşme kontrolü
669
+ zeta_zeros_imag = _load_zeta_zeros("zeta.txt")
670
+ if len(zeta_zeros_imag) == 0:
671
+ return kececi_zeta_zeros, 0.0
672
+
673
+ close_matches = [kz for kz in kececi_zeta_zeros if min(abs(kz - zeta_zeros_imag)) < tolerance]
674
+ score = len(close_matches) / len(kececi_zeta_zeros) if kececi_zeta_zeros.size > 0 else 0.0
675
+
676
+ return kececi_zeta_zeros, score
677
+
678
+ def analyze_all_types(iterations=120):
679
+ """
680
+ 11 Keçeci sayı türü için otomatik GUE ve Riemann Zeta karşılaştırması yap.
681
+ Sonuçları sıralar ve grafiklerle gösterir.
682
+ """
683
+
684
+ from . import (
685
+ get_with_params,
686
+ TYPE_POSITIVE_REAL,
687
+ TYPE_NEGATIVE_REAL,
688
+ TYPE_COMPLEX,
689
+ TYPE_FLOAT,
690
+ TYPE_RATIONAL,
691
+ TYPE_QUATERNION,
692
+ TYPE_NEUTROSOPHIC,
693
+ TYPE_NEUTROSOPHIC_COMPLEX,
694
+ TYPE_HYPERREAL,
695
+ TYPE_BICOMPLEX,
696
+ TYPE_NEUTROSOPHIC_BICOMPLEX
697
+ )
698
+
699
+
700
+ print("🔍 11 Keçeci Türü için Otomatik Analiz")
701
+ print("="*80)
702
+
703
+ include_intermediate = True
704
+ results = []
705
+
706
+ # Parametre setleri
707
+ param_sets = [
708
+ ('0.0', '9.0'),
709
+ ('1.0', '7.0'),
710
+ ('2.0', '5.0'),
711
+ ('3.0', '11.0'),
712
+ ('1+1j', '9.0'),
713
+ ('0.0001412', '0.037')
714
+ ]
715
+
716
+ type_names = {
717
+ 1: "Positive Real",
718
+ 2: "Negative Real",
719
+ 3: "Complex",
720
+ 4: "Float",
721
+ 5: "Rational",
722
+ 6: "Quaternion",
723
+ 7: "Neutrosophic",
724
+ 8: "Neutro-Complex",
725
+ 9: "Hyperreal",
726
+ 10: "Bicomplex",
727
+ 11: "Neutro-Bicomplex"
728
+ }
729
+
730
+ for kececi_type in range(1, 12):
731
+ name = type_names[kececi_type]
732
+ best_zeta_score = 0.0
733
+ best_gue_score = 0.0
734
+ best_params = None
735
+
736
+ print(f"🔄 Tür {kececi_type} ({name}) taranıyor...")
737
+
738
+ for start, add in param_sets:
739
+ try:
740
+ # Özel formatlar
741
+ if kececi_type == 3 and '+' not in start:
742
+ start = f"{start}+{start}j"
743
+ if kececi_type == 10 and '+' not in start:
744
+ start = f"{start}+{start}j"
745
+
746
+ sequence = get_with_params(
747
+ kececi_type_choice=kececi_type,
748
+ iterations=iterations,
749
+ start_value_raw=start,
750
+ add_value_raw=add,
751
+ include_intermediate_steps=include_intermediate
752
+ )
753
+
754
+ if not sequence or len(sequence) < 50:
755
+ continue
756
+
757
+ _, zeta_score = _find_kececi_zeta_zeros(sequence, tolerance=0.5)
758
+ _, gue_score = _compute_gue_similarity(sequence)
759
+
760
+ if zeta_score > best_zeta_score:
761
+ best_zeta_score = zeta_score
762
+ best_gue_score = gue_score
763
+ best_params = (start, add)
764
+
765
+ except Exception as e:
766
+ continue
767
+
768
+ if best_params:
769
+ results.append({
770
+ 'type': kececi_type,
771
+ 'name': name,
772
+ 'start': best_params[0],
773
+ 'add': best_params[1],
774
+ 'zeta_score': best_zeta_score,
775
+ 'gue_score': best_gue_score
776
+ })
777
+
778
+ # Sonuçları sırala
779
+ sorted_by_zeta = sorted(results, key=lambda x: x['zeta_score'], reverse=True)
780
+ sorted_by_gue = sorted(results, key=lambda x: x['gue_score'], reverse=True)
781
+
782
+ print("\n" + "="*100)
783
+ print(" EN YÜKSEK RİEMANN ZETA EŞLEŞME SKORLARI (TOP 11)")
784
+ print("="*100)
785
+ print(f"{'Tür':<20} {'Skor':<8} {'Başlangıç':<12} {'Artım':<12}")
786
+ print("-" * 100)
787
+ for r in sorted_by_zeta:
788
+ print(f"{r['name']:<20} {r['zeta_score']:<8.3f} {r['start']:<12} {r['add']:<12}")
789
+
790
+ print("\n" + "="*100)
791
+ print(" EN YÜKSEK GUE BENZERLİK SKORLARI (TOP 11)")
792
+ print("="*100)
793
+ print(f"{'Tür':<20} {'Skor':<8} {'Başlangıç':<12} {'Artım':<12}")
794
+ print("-" * 100)
795
+ for r in sorted_by_gue:
796
+ print(f"{r['name']:<20} {r['gue_score']:<8.3f} {r['start']:<12} {r['add']:<12}")
797
+
798
+ # Grafikler
799
+ _plot_comparison(sorted_by_zeta, sorted_by_gue)
800
+
801
+ return sorted_by_zeta, sorted_by_gue
802
+
803
+ def _plot_comparison(zeta_results, gue_results):
804
+ """İki sonuç setini karşılaştırmak için grafikler çizer."""
805
+ # --- Riemann Zeta Eşleşme Grafiği ---
806
+ plt.figure(figsize=(14, 7))
807
+ types = [r['name'] for r in zeta_results]
808
+ scores = [r['zeta_score'] for r in zeta_results]
809
+ colors = ['skyblue'] * len(scores)
810
+ if scores:
811
+ colors[0] = 'red' # En iyi olanı kırmızı yap
812
+ bars = plt.bar(types, scores, color=colors, edgecolor='black', alpha=0.8)
813
+ plt.xticks(rotation=45, ha='right')
814
+ plt.ylabel("Riemann Zeta Eşleşme Oranı")
815
+ plt.title("Keçeci Türlerinin Riemann Zeta Sıfırlarıyla Eşleşmesi")
816
+ plt.grid(True, alpha=0.3)
817
+ # En iyi barı kalın yap (eğer varsa)
818
+ if bars:
819
+ bars[0].set_edgecolor('darkred')
820
+ bars[0].set_linewidth(1.5)
821
+ plt.tight_layout()
822
+ plt.show()
823
+
824
+ # --- GUE Benzerlik Grafiği ---
825
+ plt.figure(figsize=(14, 7))
826
+ types = [r['name'] for r in gue_results]
827
+ scores = [r['gue_score'] for r in gue_results]
828
+ colors = ['skyblue'] * len(scores)
829
+ if scores:
830
+ colors[0] = 'red' # En iyi olanı kırmızı yap
831
+ bars = plt.bar(types, scores, color=colors, edgecolor='black', alpha=0.8)
832
+ plt.xticks(rotation=45, ha='right')
833
+ plt.ylabel("GUE Benzerlik Skoru")
834
+ plt.title("Keçeci Türlerinin GUE İstatistiğine Benzerliği")
835
+ plt.grid(True, alpha=0.3)
836
+ # En iyi barı kalın yap (eğer varsa)
837
+ if bars:
838
+ bars[0].set_edgecolor('darkred')
839
+ bars[0].set_linewidth(1.5)
840
+ plt.tight_layout()
841
+ plt.show()
842
+
547
843
  # ==============================================================================
548
844
  # --- CORE GENERATOR ---
549
845
  # ==============================================================================
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: kececinumbers
3
- Version: 0.6.3
3
+ Version: 0.6.4
4
4
  Summary: Keçeci Numbers: An Exploration of a Dynamic Sequence Across Diverse Number Sets
5
5
  Home-page: https://github.com/WhiteSymmetry/kececinumbers
6
6
  Author: Mehmet Keçeci
@@ -42,6 +42,7 @@ License-File: LICENSE
42
42
  Requires-Dist: numpy
43
43
  Requires-Dist: matplotlib
44
44
  Requires-Dist: numpy-quaternion
45
+ Requires-Dist: scipy
45
46
  Requires-Dist: sympy
46
47
  Provides-Extra: test
47
48
  Requires-Dist: pytest; extra == "test"
@@ -51,6 +52,7 @@ Requires-Dist: ruff; extra == "test"
51
52
  Requires-Dist: numpy; extra == "test"
52
53
  Requires-Dist: matplotlib; extra == "test"
53
54
  Requires-Dist: numpy-quaternion; extra == "test"
55
+ Requires-Dist: scipy; extra == "test"
54
56
  Requires-Dist: sympy; extra == "test"
55
57
  Dynamic: author
56
58
  Dynamic: home-page
@@ -209,7 +211,7 @@ import kececinumbers as kn
209
211
  sequence = kn.get_with_params(
210
212
  kececi_type_choice=kn.TYPE_POSITIVE_REAL,
211
213
  iterations=30,
212
- start_value_raw="0",
214
+ start_value_raw="0.0",
213
215
  add_value_raw="9.0",
214
216
  include_intermediate_steps=True
215
217
  )
@@ -0,0 +1,10 @@
1
+ docs/conf.py,sha256=jkpH_TchRJcC_EspKeY1E_rml2ODmIWhWoqvyCPu_ok,1116
2
+ kececinumbers/__init__.py,sha256=LqtV7Eze7tGCv013yXBNESqzUFrMfDcSIQMRPUb4r9w,4047
3
+ kececinumbers/_version.py,sha256=1gv6JSaINA1MaeLbvKeiRFNEQTQC72ZM54asm03jS8Y,453
4
+ kececinumbers/kececinumbers.py,sha256=oDhmGqgQ9sHKmTbuDHkE4F-oFgFKUtW190Pu5dM9y0Q,54197
5
+ kececinumbers-0.6.4.dist-info/licenses/LICENSE,sha256=NJZsJEbQuKzxn1mWPWCbRx8jRUqGS22thl8wwuRQJ9c,1071
6
+ tests/test_sample.py,sha256=qMWUBGQtlF1gZHZ_e6Gye1vHtyNnUWH7iXK72a1y6VQ,9728
7
+ kececinumbers-0.6.4.dist-info/METADATA,sha256=rIOUYoF-gZjcdd9QOdc05aTw2X_BLvo5MfCJ8jqC3Fw,33720
8
+ kececinumbers-0.6.4.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
9
+ kececinumbers-0.6.4.dist-info/top_level.txt,sha256=ABQEKRH9iYb4sWnFdx7gIx7Hg899YktRkQpbRlSSqwU,25
10
+ kececinumbers-0.6.4.dist-info/RECORD,,
@@ -1,10 +0,0 @@
1
- docs/conf.py,sha256=jkpH_TchRJcC_EspKeY1E_rml2ODmIWhWoqvyCPu_ok,1116
2
- kececinumbers/__init__.py,sha256=BppueKxmKzWlPR0VUdq-0RiJyJOvEH3mbGqClov0mjw,3758
3
- kececinumbers/_version.py,sha256=mXoGDVZCtP2YgLFmkRSkSIWnem5vexg9IHGcMAOgmDM,453
4
- kececinumbers/kececinumbers.py,sha256=jf0z5I-mJ2speU6Dyqd9GTIS9Phk5GVItjY2Eaaphis,44569
5
- kececinumbers-0.6.3.dist-info/licenses/LICENSE,sha256=NJZsJEbQuKzxn1mWPWCbRx8jRUqGS22thl8wwuRQJ9c,1071
6
- tests/test_sample.py,sha256=qMWUBGQtlF1gZHZ_e6Gye1vHtyNnUWH7iXK72a1y6VQ,9728
7
- kececinumbers-0.6.3.dist-info/METADATA,sha256=CUsBABtdWjq40sYHfJSdbVZbzwQUvL-7Tx9SyzPFFJI,33659
8
- kececinumbers-0.6.3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
9
- kececinumbers-0.6.3.dist-info/top_level.txt,sha256=ABQEKRH9iYb4sWnFdx7gIx7Hg899YktRkQpbRlSSqwU,25
10
- kececinumbers-0.6.3.dist-info/RECORD,,