-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
pi.frm
1366 lines (1113 loc) · 41.6 KB
/
pi.frm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
VERSION 5.00
Begin VB.Form Form1
AutoRedraw = -1 'True
Caption = "Demo - PI engine, digits to signals"
ClientHeight = 10650
ClientLeft = 120
ClientTop = 450
ClientWidth = 19845
LinkTopic = "Form1"
ScaleHeight = 710
ScaleMode = 3 'Pixel
ScaleWidth = 1323
StartUpPosition = 2 'CenterScreen
Begin VB.TextBox Orig
Height = 1215
Index = 0
Left = 2640
MultiLine = -1 'True
ScrollBars = 2 'Vertical
TabIndex = 35
Text = "pi.frx":0000
Top = 11280
Width = 10335
End
Begin VB.TextBox Orig
Height = 1215
Index = 1
Left = 2640
MultiLine = -1 'True
ScrollBars = 2 'Vertical
TabIndex = 34
Text = "pi.frx":2727
Top = 12720
Width = 10335
End
Begin VB.TextBox Orig
Height = 1215
Index = 2
Left = 2640
MultiLine = -1 'True
ScrollBars = 2 'Vertical
TabIndex = 33
Text = "pi.frx":4E4E
Top = 14160
Width = 10335
End
Begin VB.TextBox Orig
Height = 1215
Index = 3
Left = 2640
MultiLine = -1 'True
ScrollBars = 2 'Vertical
TabIndex = 32
Text = "pi.frx":7575
Top = 15600
Width = 10335
End
Begin VB.Frame Frame3
Caption = "Analyze the digits from:"
Height = 2655
Left = 240
TabIndex = 26
Top = 120
Width = 8775
Begin VB.TextBox Sec1
Height = 2055
Left = 1200
MultiLine = -1 'True
ScrollBars = 2 'Vertical
TabIndex = 40
Top = 360
Width = 7335
End
Begin VB.OptionButton Option2
Caption = "PI"
Height = 195
Index = 0
Left = 240
TabIndex = 30
Top = 480
Value = -1 'True
Width = 615
End
Begin VB.OptionButton Option2
Caption = "e"
Height = 195
Index = 1
Left = 240
TabIndex = 29
Top = 720
Width = 495
End
Begin VB.OptionButton Option2
Caption = "Ratio"
Height = 195
Index = 2
Left = 240
TabIndex = 28
Top = 960
Width = 735
End
Begin VB.OptionButton Option2
Caption = "sqr(2)"
Height = 195
Index = 3
Left = 240
TabIndex = 27
Top = 1200
Width = 735
End
End
Begin VB.Frame Frame2
Caption = "Make signal by rule:"
Height = 1815
Left = 14640
TabIndex = 20
Top = 7920
Width = 5055
Begin VB.CheckBox OSignal
Caption = "Overlapping signals"
Height = 255
Left = 240
TabIndex = 31
Top = 1320
Width = 1935
End
Begin VB.HScrollBar x_tuple
Height = 255
Left = 1800
Max = 20
Min = 1
TabIndex = 24
Top = 600
Value = 1
Width = 3015
End
Begin VB.OptionButton Option1
Caption = "[n-1<n]"
Height = 195
Index = 1
Left = 240
TabIndex = 23
ToolTipText = "If [n-1<n] then add one to the signal else subtract one"
Top = 720
Width = 1335
End
Begin VB.OptionButton Option1
Caption = "[n-1>n]"
Height = 195
Index = 0
Left = 240
TabIndex = 22
ToolTipText = "If [n-1>n] then add one to the signal else subtract one"
Top = 480
Value = -1 'True
Width = 1215
End
Begin VB.CommandButton Command1
Caption = "Compare digits"
Height = 495
Left = 2400
TabIndex = 21
Top = 1080
Width = 2415
End
Begin VB.Label Arata_tuple
BackStyle = 0 'Transparent
Caption = "n-tuple"
Height = 255
Left = 1800
TabIndex = 25
Top = 360
Width = 3015
End
End
Begin VB.PictureBox MaxFWindow
Appearance = 0 'Flat
AutoRedraw = -1 'True
BackColor = &H00FFFFFF&
ForeColor = &H80000008&
Height = 1575
Left = 9360
ScaleHeight = 103
ScaleMode = 3 'Pixel
ScaleWidth = 335
TabIndex = 19
Top = 7920
Width = 5055
End
Begin VB.PictureBox ProbGraph
Appearance = 0 'Flat
AutoRedraw = -1 'True
BackColor = &H00FFFFFF&
ForeColor = &H80000008&
Height = 1575
Left = 14640
ScaleHeight = 103
ScaleMode = 3 'Pixel
ScaleWidth = 335
TabIndex = 18
Top = 360
Width = 5055
End
Begin VB.OptionButton LineSum2
Caption = "Cross Line"
Height = 255
Left = 17040
TabIndex = 17
Top = 4200
Width = 1095
End
Begin VB.OptionButton CubeSum
Caption = "Cube Line"
Height = 255
Left = 15960
TabIndex = 15
Top = 4200
Width = 1575
End
Begin VB.OptionButton BarSum
Caption = "Cross Bar"
Height = 255
Left = 18120
TabIndex = 14
Top = 4200
Value = -1 'True
Width = 1095
End
Begin VB.OptionButton LineSum
Caption = "Line"
Height = 195
Left = 15240
TabIndex = 13
Top = 4200
Width = 975
End
Begin VB.PictureBox SumOfPI
Appearance = 0 'Flat
AutoRedraw = -1 'True
BackColor = &H00FFFFFF&
ForeColor = &H80000008&
Height = 1575
Left = 14640
ScaleHeight = 103
ScaleMode = 3 'Pixel
ScaleWidth = 335
TabIndex = 9
Top = 2280
Width = 5055
End
Begin VB.PictureBox DigitFrec
Appearance = 0 'Flat
AutoRedraw = -1 'True
BackColor = &H00FFFFFF&
ForeColor = &H80000008&
Height = 1695
Left = 9360
ScaleHeight = 111
ScaleMode = 3 'Pixel
ScaleWidth = 335
TabIndex = 8
Top = 5640
Width = 5055
End
Begin VB.Frame Frame1
Caption = "Scan digits:"
Height = 3135
Left = 14640
TabIndex = 3
Top = 4680
Width = 5055
Begin VB.CommandButton Stop_Run
Caption = "Stop"
Height = 495
Left = 2640
TabIndex = 16
Top = 2400
Width = 1935
End
Begin VB.HScrollBar Stepp
Height = 255
Left = 240
Max = 100
Min = 1
TabIndex = 7
Top = 1200
Value = 10
Width = 4695
End
Begin VB.HScrollBar pause
Height = 255
Left = 240
Max = 100
Min = 5
TabIndex = 6
Top = 1920
Value = 10
Width = 4695
End
Begin VB.HScrollBar Window
Height = 255
Left = 240
Max = 5000
Min = 20
TabIndex = 5
Top = 600
Value = 100
Width = 4695
End
Begin VB.CommandButton Anim
Caption = "Run window"
BeginProperty Font
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 480
TabIndex = 4
Top = 2400
Width = 1935
End
Begin VB.Label StepTxT
BackStyle = 0 'Transparent
Caption = "Sliding window step:"
Height = 255
Left = 240
TabIndex = 12
Top = 960
Width = 2055
End
Begin VB.Label Label3
BackStyle = 0 'Transparent
Caption = "Processing speed:"
Height = 255
Left = 240
TabIndex = 11
Top = 1680
Width = 2535
End
Begin VB.Label WindowTXT
BackStyle = 0 'Transparent
Caption = "Sliding window length:"
Height = 255
Left = 240
TabIndex = 10
Top = 360
Width = 2895
End
End
Begin VB.PictureBox Center_patt
Appearance = 0 'Flat
AutoRedraw = -1 'True
BackColor = &H00FFFFFF&
ForeColor = &H80000008&
Height = 4695
Left = 9360
ScaleHeight = 311
ScaleMode = 3 'Pixel
ScaleWidth = 335
TabIndex = 2
Top = 600
Width = 5055
End
Begin VB.CommandButton TR_PI
Caption = "Process all in one"
Height = 615
Left = 1920
TabIndex = 1
Top = 9120
Width = 4935
End
Begin VB.TextBox WMatrix
BeginProperty Font
Name = "Courier New"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 5655
Left = 240
MultiLine = -1 'True
ScrollBars = 2 'Vertical
TabIndex = 0
Top = 3240
Width = 8775
End
Begin VB.Image Image1
Height = 720
Left = -5400
Picture = "pi.frx":9C9C
Top = 9960
Width = 25290
End
Begin VB.Line Line2
X1 = 976
X2 = 976
Y1 = 260
Y2 = 240
End
Begin VB.Line Line1
X1 = 1312
X2 = 1312
Y1 = 245
Y2 = 260
End
Begin VB.Label E_SW
Alignment = 1 'Right Justify
BackStyle = 0 'Transparent
Caption = "100"
Height = 255
Left = 17880
TabIndex = 48
Top = 3960
Width = 1815
End
Begin VB.Label B_SW
BackStyle = 0 'Transparent
Caption = "1"
Height = 255
Left = 14580
TabIndex = 47
Top = 3960
Width = 1815
End
Begin VB.Label Label12
BackStyle = 0 'Transparent
Caption = "Results in text format:"
Height = 255
Left = 240
TabIndex = 46
Top = 3000
Width = 4935
End
Begin VB.Label Label11
BackStyle = 0 'Transparent
Caption = "Balance on sliding windows:"
Height = 255
Left = 14640
TabIndex = 45
Top = 2040
Width = 4935
End
Begin VB.Label Label10
BackStyle = 0 'Transparent
Caption = "Parallel signals for each digit along the sequence"
Height = 255
Left = 14640
TabIndex = 44
Top = 120
Width = 4935
End
Begin VB.Label Label9
BackStyle = 0 'Transparent
Caption = "Max digit frequency on all sliding windows:"
Height = 255
Left = 9360
TabIndex = 43
Top = 7680
Width = 4935
End
Begin VB.Label Label8
BackStyle = 0 'Transparent
Caption = "Digit frequency on sliding window/all digits:"
Height = 255
Left = 9360
TabIndex = 42
Top = 5400
Width = 4935
End
Begin VB.Label Label7
BackStyle = 0 'Transparent
Caption = "Transition matrix between the digits of the sliding window/all digits:"
Height = 255
Left = 9240
TabIndex = 41
Top = 120
Width = 4935
End
Begin VB.Label Label6
Caption = "Pi"
BeginProperty Font
Name = "MS Sans Serif"
Size = 24
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 735
Left = 960
TabIndex = 39
Top = 11640
Width = 1215
End
Begin VB.Label Label5
Caption = "e"
BeginProperty Font
Name = "MS Sans Serif"
Size = 24
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 735
Left = 960
TabIndex = 38
Top = 12960
Width = 1215
End
Begin VB.Label Label4
Caption = "sqr(2)"
BeginProperty Font
Name = "MS Sans Serif"
Size = 24
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 735
Left = 960
TabIndex = 37
Top = 15840
Width = 1455
End
Begin VB.Label Label1
Caption = "Ratio"
BeginProperty Font
Name = "MS Sans Serif"
Size = 24
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 735
Left = 960
TabIndex = 36
Top = 14400
Width = 1215
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
' ________________________________ ____________________
' / PI Engine \________________________/ v1 |
' | |
' | Name: PI Engine |
' | Category: Open source software |
' | Author: Paul A. Gagniuc |
' | Book: Algorithms in Bioinformatics: Theory and Implementation |
' | Email: paul_gagniuc@acad.ro |
' | ____________________________________________________________________________ |
' | |
' | Date Created: May 2014 |
' | Update: August 2021 |
' | Tested On: WinXP, WinVista, Win7, Win8, Win10 |
' | Use: Analysis |
' | |
' | _____________________________ |
' |_________________/ \_______________________________|
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Dim stop_anim As Boolean
'=IF(E2>F2,D8+1,D8-1)
Dim M1(0 To 9, 0 To 9) As String
Dim MatrixMaxVal As Variant 'matrix maximum value
Dim MatrixMinVal As Variant 'matrix minimum value
Dim MAX_DIGIT_WINDOW(0 To 9) As Integer
Private Sub Anim_Click()
stop_anim = False
Sec1.Text = Replace(Sec1.Text, vbCrLf, "")
For i = 0 To 9
MAX_DIGIT_WINDOW(i) = 0
Next i
For s = 1 To Len(Sec1.Text) - Window.Value Step Stepp.Value
Call Fill_Transition_Matrix(M1, 9, 9, Mid(Sec1.Text, s, Window.Value))
Call frec(Mid(Sec1.Text, s, Window.Value))
Call SumPI2(Mid(Sec1.Text, s, Window.Value))
Call Max_frec(Mid(Sec1.Text, s, Window.Value))
Call P(Mid(Sec1.Text, s, Window.Value), s)
Sleep (CLng(pause.Value))
'---------------------------------------
MatrixMaxVal = 0
MatrixMinVal = 0
For i = 0 To 9
For j = 0 To 9
If M1(i, j) > MatrixMaxVal Then MatrixMaxVal = M1(i, j)
If M1(i, j) < MatrixMinVal Then MatrixMinVal = M1(i, j)
Next j
Next i
Call DrowColorMatrix(9, 9, M1, Center_patt)
'---------------------------------------
Frame1.Caption = "Scan digits: " & (s + Window.Value + Stepp.Value - 1)
E_SW.Caption = (s + Window.Value + Stepp.Value - 1)
B_SW.Caption = E_SW.Caption - Window.Value
If stop_anim = True Then GoTo 1
DoEvents
Next s
1:
End Sub
Private Sub Command1_Click()
If Option1(0).Value = True Then a = 0
If Option1(1).Value = True Then a = 1
WMatrix.Text = WMatrix.Text & vbCrLf & RulePI(Sec1.Text, a)
WMatrix.SelStart = Len(WMatrix.Text)
End Sub
Function P(ByVal s As String, ByVal pos As Integer)
'd = cati de x sunt in fereastra
Dim f(0 To 9) As Integer
Dim prob(0 To 9) As Variant
For i = 1 To Len(s)
DI = Mid(s, i, 1)
If DI = "0" Then f(0) = f(0) + 1
If DI = "1" Then f(1) = f(1) + 1
If DI = "2" Then f(2) = f(2) + 1
If DI = "3" Then f(3) = f(3) + 1
If DI = "4" Then f(4) = f(4) + 1
If DI = "5" Then f(5) = f(5) + 1
If DI = "6" Then f(6) = f(6) + 1
If DI = "7" Then f(7) = f(7) + 1
If DI = "8" Then f(8) = f(8) + 1
If DI = "9" Then f(9) = f(9) + 1
Next i
peX = (ProbGraph.ScaleWidth / Len(Sec1.Text))
peY = (ProbGraph.ScaleHeight / 100)
old = 0
For i = 0 To 9
prob(i) = f(i) / Len(s)
nou_p = prob(i) * 100
tmp = old + nou_p
If i = 0 Then colora = RGB(55, 55, 55)
If i = 1 Then colora = RGB(0, 55, 55)
If i = 2 Then colora = RGB(55, 0, 55)
If i = 3 Then colora = RGB(55, 70, 55)
If i = 4 Then colora = RGB(0, 55, 100)
If i = 5 Then colora = RGB(55, 160, 55)
If i = 6 Then colora = RGB(55, 55, 200)
If i = 7 Then colora = RGB(0, 0, 55)
If i = 8 Then colora = RGB(55, 0, 0)
If i = 9 Then colora = RGB(55, 90, 160)
If i = 0 Then colora = RGB(i * 30, 55, 55)
If i = 1 Then colora = RGB(i * 30, 55, 55)
If i = 2 Then colora = RGB(i * 30, 55, 55)
If i = 3 Then colora = RGB(i * 30, 55, 55)
If i = 4 Then colora = RGB(i * 30, 55, 55)
If i = 5 Then colora = RGB(i * 30, 55, 55)
If i = 6 Then colora = RGB(i * 30, 55, 55)
If i = 7 Then colora = RGB(i * 30, 55, 55)
If i = 8 Then colora = RGB(i * 30, 55, 55)
If i = 9 Then colora = RGB(i * 30, 55, 55)
If i = 0 Then colora = RGB(i * 30, i * 20, 55)
If i = 1 Then colora = RGB(i * 30, i * 20, 55)
If i = 2 Then colora = RGB(i * 30, i * 20, 55)
If i = 3 Then colora = RGB(i * 30, i * 20, 55)
If i = 4 Then colora = RGB(i * 30, i * 20, 55)
If i = 5 Then colora = RGB(i * 30, i * 20, 55)
If i = 6 Then colora = RGB(i * 30, i * 20, 55)
If i = 7 Then colora = RGB(i * 30, i * 20, 55)
If i = 8 Then colora = RGB(i * 30, i * 20, 55)
If i = 9 Then colora = RGB(i * 30, i * 20, 55)
ProbGraph.Line (peX * pos, ProbGraph.ScaleHeight - (peY + old))-(peX * (pos + Len(s)), ProbGraph.ScaleHeight - (peY * tmp)), colora, BF
'ProbGraph.Line (peX * pos, ProbGraph.ScaleHeight - (peY + old))-(peX * (pos), ProbGraph.ScaleHeight - (peY * tmp)), colora
old = tmp
Next i
End Function
Function SumPI2(ByVal s As String)
a = 0
For i = 1 To Len(s)
DI = Val(Mid(s, i, 1))
a = a + DI
Next i
peX = (SumOfPI.ScaleWidth / Len(s))
peY = (SumOfPI.ScaleHeight / a)
SumOfPI.Cls
For i = 1 To Len(s)
DI = Val(Mid(s, i, 1))
d = d + DI
If LineSum.Value = True Then SumOfPI.Line (peX * i, SumOfPI.ScaleHeight - (peY * old))-(peX * (i + 1), SumOfPI.ScaleHeight - (peY * d)), RGB(55, 55, 55)
If LineSum2.Value = True Then SumOfPI.Line (peX * i, SumOfPI.ScaleHeight - (peY * old))-(peX * (i + 1), (peY * d)), RGB(55, 55, 55)
If BarSum.Value = True Then SumOfPI.Line (peX * i, peY * old)-(peX * (i + 1), SumOfPI.ScaleHeight - (peY * d)), RGB(55, 55, 55), B
'If CubeSum.Value = True Then SumOfPI.Line (peX * i, peY * old)-(peX * (i + 1), (peY * d)), RGB(55, 55, 55), B
If CubeSum.Value = True Then SumOfPI.Line (peX * i, SumOfPI.ScaleHeight - (peY * old))-(peX * (i + 1), SumOfPI.ScaleHeight - (peY * d)), RGB(55, 55, 55), B
old = d
Next i
End Function
Function Max_frec(ByVal s As String)
'------------------------------------
Dim f(0 To 9) As Integer
For i = 1 To Len(s)
DI = Mid(s, i, 1)
If DI = "0" Then f(0) = f(0) + 1
If DI = "1" Then f(1) = f(1) + 1
If DI = "2" Then f(2) = f(2) + 1
If DI = "3" Then f(3) = f(3) + 1
If DI = "4" Then f(4) = f(4) + 1
If DI = "5" Then f(5) = f(5) + 1
If DI = "6" Then f(6) = f(6) + 1
If DI = "7" Then f(7) = f(7) + 1
If DI = "8" Then f(8) = f(8) + 1
If DI = "9" Then f(9) = f(9) + 1
Next i
For i = 0 To UBound(f)
If f(i) > Maxim Then
Maxim = f(i)
tmp = i
End If
Next i
MAX_DIGIT_WINDOW(tmp) = MAX_DIGIT_WINDOW(tmp) + 1
peX = (MaxFWindow.ScaleWidth / (UBound(f) + 1))
For i = 0 To UBound(MAX_DIGIT_WINDOW)
If MAX_DIGIT_WINDOW(i) > Maxim Then Maxim = MAX_DIGIT_WINDOW(i)
Next i
peY = (MaxFWindow.ScaleHeight / Maxim)
'peY = (MaxFWindow.ScaleHeight / Len(s))
MaxFWindow.Cls
For i = 0 To UBound(f)
MaxFWindow.Line (peX * i, DigitFrec.ScaleHeight)-(peX * (i + 1), DigitFrec.ScaleHeight - (peY * MAX_DIGIT_WINDOW(i))), RGB(55, 20, 20), BF
'MaxFWindow.Line (peX * i, DigitFrec.ScaleHeight)-(peX * (i + 1), DigitFrec.ScaleHeight - (peY * (MAX_DIGIT_WINDOW(i) * f(i)))), RGB(55, 55, 55), BF
Next i
'------------------------------------
End Function
Function frec(ByVal s As String)
'------------------------------------
Dim f(0 To 9) As Integer
For i = 1 To Len(s)
DI = Mid(s, i, 1)
If DI = "0" Then f(0) = f(0) + 1
If DI = "1" Then f(1) = f(1) + 1
If DI = "2" Then f(2) = f(2) + 1
If DI = "3" Then f(3) = f(3) + 1
If DI = "4" Then f(4) = f(4) + 1
If DI = "5" Then f(5) = f(5) + 1
If DI = "6" Then f(6) = f(6) + 1
If DI = "7" Then f(7) = f(7) + 1
If DI = "8" Then f(8) = f(8) + 1
If DI = "9" Then f(9) = f(9) + 1
Next i
For i = 0 To UBound(f)
If f(i) > Maxim Then Maxim = f(i)
Next i
peX = (DigitFrec.ScaleWidth / (UBound(f) + 1))
peY = (DigitFrec.ScaleHeight / Maxim)
DigitFrec.Cls
For i = 0 To UBound(f)
'in functie de f maxima
DigitFrec.Line (peX * i, DigitFrec.ScaleHeight)-(peX * (i + 1), DigitFrec.ScaleHeight - (peY * f(i))), RGB(55, 55, 55), BF
'DigitFrec.Line (peX * i, DigitFrec.ScaleHeight / 2)-(peX * (i + 1), (peY * f(i))), RGB(55, 55, 55), BF
Next i
'------------------------------------
End Function
Private Sub Form_Load()
Sec1.Text = Replace(Orig(0).Text, vbCrLf, "")
Sec1.Text = Replace(Sec1.Text, vbCrLf, "")
Call draw_scale(cicle)
Window_Change
Stepp_Change
TR_PI_Click
End Sub
Private Sub Form_Terminate()
stop_anim = True
End Sub
Private Sub Form_Unload(Cancel As Integer)
stop_anim = True
End Sub
Private Sub Option2_Click(Index As Integer)
If Option2(Index).Value = True Then
a = Index
Sec1.Text = Replace(Orig(a).Text, vbCrLf, "")
End If
End Sub
Private Sub Stepp_Change()
StepTxT.Caption = "Sliding window step: " & Stepp.Value
End Sub
Private Sub Stop_Run_Click()
stop_anim = True
End Sub
Private Sub TR_PI_Click()
Center_patt.Cls
DigitFrec.Cls
SumOfPI.Cls
MatrixMaxVal = 0
MatrixMinVal = 0
Sec1.Text = Replace(Sec1.Text, vbCrLf, "")
Call Fill_Transition_Matrix(M1, 9, 9, Sec1.Text)
Call frec(Sec1.Text)
Call SumPI2(Sec1.Text)
Call P(Sec1.Text, 1)
sTXT = DrowMatrix(9, 9, M1, "(P)", "Transition probabilities M:")
sTXT_EXCEL = DrowMatrixForEXCEL(9, 9, M1, "(P)", "Copy/Paste to EXCEL:")
WMatrix.Text = sTXT & sTXT_EXCEL
For i = 0 To 9 '4
For j = 0 To 9 '4
If M1(i, j) > MatrixMaxVal Then MatrixMaxVal = M1(i, j)
If M1(i, j) < MatrixMinVal Then MatrixMinVal = M1(i, j)
Next j
Next i
Call DrowColorMatrix(9, 9, M1, Center_patt)
End Sub
Function Fill_Transition_Matrix(ByRef M() As String, ByVal cols As Integer, ByVal rows As Integer, ByVal s As String)
For i = 0 To cols '4
For j = 0 To rows '4
M(i, j) = 0
Next j
Next i
For i = 1 To Len(s)
DI = Mid(s, i, 1)
If DI = "0" Then n0 = n0 + 1
If DI = "1" Then n1 = n1 + 1
If DI = "2" Then n2 = n2 + 1
If DI = "3" Then n3 = n3 + 1
If DI = "4" Then n4 = n4 + 1
If DI = "5" Then n5 = n5 + 1
If DI = "6" Then n6 = n6 + 1
If DI = "7" Then n7 = n7 + 1
If DI = "8" Then n8 = n8 + 1
If DI = "9" Then n9 = n9 + 1
Next i
For i = 1 To Len(s) - 1
DI1 = Mid(s, i, 1)
DI2 = Mid(s, i + 1, 1)
If DI1 = "0" Then r = 0
If DI1 = "1" Then r = 1
If DI1 = "2" Then r = 2
If DI1 = "3" Then r = 3
If DI1 = "4" Then r = 4
If DI1 = "5" Then r = 5
If DI1 = "6" Then r = 6
If DI1 = "7" Then r = 7
If DI1 = "8" Then r = 8
If DI1 = "9" Then r = 9
If DI2 = "0" Then c = 0
If DI2 = "1" Then c = 1
If DI2 = "2" Then c = 2
If DI2 = "3" Then c = 3
If DI2 = "4" Then c = 4
If DI2 = "5" Then c = 5
If DI2 = "6" Then c = 6
If DI2 = "7" Then c = 7
If DI2 = "8" Then c = 8
If DI2 = "9" Then c = 9
M(r, c) = Val(M(r, c)) + 1
Next i
For i = 0 To cols
For j = 0 To rows