analysis_functions
phyllotaxis_analysis.analysis_functions Link
This module contains the functions used to detect permutations in sequences of divergence angles.
EqualTheorAngles Link
Bases: Exception
Raised when different multiples of canonical angles modulo 360 leads to the same value
candidate_angles Link
candidate_angles(angle, bordersDict)
find the theoretical angles that may correspond to a measured angle
:Parameters:
- angle
- measured angle
- bordersDict
- dictionary of theoretical angles and corresponding intervals
:Returns:
- possible theoretical angles for angle
Source code in src/phyllotaxis_analysis/analysis_functions.py
216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 |
|
candidate_angles_list Link
candidate_angles_list(angles, bordersDict)
calculate list of possible theoretical angles for a list of measured angle
Returns list of possible theoretical angles for a list of measured angle
:Parameters:
- angles
- measured angle
- bordersDict
- dictionary of theoretical angles and corresponding intervals
:Returns:
- list of possible theoretical angles for itemList
Source code in src/phyllotaxis_analysis/analysis_functions.py
242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 |
|
circular_std_dev Link
circular_std_dev(kappa)
Calculates the circular standard deviation of a von Mises distribution.
The von Mises distribution is a continuous probability distribution on the circle. It is also known as the circular normal distribution or Tikhonov distribution.
This function calculates the circular standard deviation (circularsigma) of a von Mises distribution, given its concentration parameter kappa (> 0).
Refer to scipy.stats.vonmises
for more information on the von Mises distribution.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
kappa
|
float
|
The concentration parameter of the von Mises distribution (> 0) |
required |
Returns:
Type | Description |
---|---|
float
|
The circular standard deviation of the distribution |
See Also
scipy.stats.vonmises : Probability density function, cumulative distribution function, etc. of the von Mises distribution.
References
.. [1] Gatto, A., & Jammalamadaka, S. R. (2007). Circular statistics. Handbook of statistics, 26, 1-45.
Source code in src/phyllotaxis_analysis/analysis_functions.py
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 |
|
code_sequence Link
code_sequence(seq, permutationBlockMaxSize, canonicalAngle, bordersDict, kappa, threshold)
make list of n
-admissible trees coding sequence of measured angles
:Parameters:
- seq
- sequence of measured angles
- permutationBlockMaxSize
- maximum number of organs involved in permutations
- canonicalAngle
- canonical divergence angle
- bordersDict
- dictionary of theoretical angles and the corresponding intervals
- kappa
- concentration parameter
- threshold
- a statistical threshold to prune the n
-admissible trees
:Returns:
- treesIndexes
- a list of [n-admissible tree, index]
such that each tree in the list is an n-admissible tree coding to seq[(index - 1): index]
Source code in src/phyllotaxis_analysis/analysis_functions.py
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 |
|
counter_clock_wise Link
counter_clock_wise(angles)
Change the orientation of a divergence angles sequence to counterclockwise.
This function takes a list of divergence angles and returns the same list with all the angles rotated by 360 degrees, effectively changing their orientation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
angles
|
list
|
List of divergence angles in degrees. |
required |
Returns:
Type | Description |
---|---|
list
|
The input list with all the angles rotated by 360 degrees |
Examples:
>>> from phyllotaxis_analysis.analysis_functions import counter_clock_wise
>>> counter_clock_wise([0, 45, 90, 135, 180, 225, 270, 315])
[180, 135, 90, 45, 0, 315, 270, 225]
Source code in src/phyllotaxis_analysis/analysis_functions.py
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
|
extract_sequences Link
extract_sequences(treesIndexes, seq, permutationBlockMaxSize, canonicalAngle, probCheck=True)
extract n
-admissible sequences from a list of n-admissible trees
:Parameters:
- treesIndexes
- a list of [n-admissible tree, index]
such that each tree in the list is the n-admissible tree coding seq[(index - 1): index]
- seq
- sequence of measured angles
- permutationBlockMaxSize
- maximum number of organs involved in permutations
- canonicalAngle
- canonical divergence angle
:Returns:
- prediction
- prediction, i.e. list of theoretical angles coding seq
- notExplainedList
- list of not explained angles
- validPermutations
- list of valid permutations
- invalids
- list of invalidated permutations
Source code in src/phyllotaxis_analysis/analysis_functions.py
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 |
|
invalidate_seq Link
invalidate_seq(S, notExplained, permutationBlockMaxSize)
invalidate permutations preceding a not explained angles down to a splitting point
:Parameters:
- S
- sequence of divergence angles
- notExplained
- list of not explained angles
- permutationBlockMaxSize
- maximum number of organs involved in permutations
:Returns:
invalid
- list of invalidated angles
Source code in src/phyllotaxis_analysis/analysis_functions.py
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 |
|
is_n_admissible Link
is_n_admissible(seq, canonicalAngle, permutationBlockMaxSize=None)
check whether an entered sequence is an n
-admissible sequence
:Parameters:
- seq
- a sequence of theoretical angles
- canonicalAngle
- canonical divergence angle
- permutationBlockMaxSize
- maximum number of organs involved in a permutation
:Returns:
- True if the seq
is n
-admissible, otherwise False
- permutations
- list of permutations
- U
- order index series
Source code in src/phyllotaxis_analysis/analysis_functions.py
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 |
|
is_n_admissible2 Link
is_n_admissible2(seq, n, canonicalAngle, D_n_coeffDict)
check whether an entered sequence is an n
-admissible sequence.
:Parameters:
- seq
- a sequence of theoretical angles
- n
- maximum number of organs involved in permutations
- canonicalAngle
- canonical divergence angle
- D_n_coeffDict
- dictionary of theoretical angles and their coefficients
:Returns:
- True if the seq
is n
-admissible, otherwise it returns False. Also list of permutations
Source code in src/phyllotaxis_analysis/analysis_functions.py
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 |
|
is_n_admissible_first_angles Link
is_n_admissible_first_angles(seq, n, canonicalAngle, D_n_coeffDict)
check whether an entered sequence is an n
-admissible sequence by taking into account a possible permutation at the beginning of the sequence.
:Parameters:
- seq
- a sequence of theoretical angles
- n
- maximum number of organs involved in permutations
- canonicalAngle
- canonical divergence angle
- D_n_coeffDict
- dictionary of theoretical angles and their coefficients
:Returns:
- True if the seq
is n
-admissible, otherwise False
- permutations
- list of permutations
- U
- order index series
Source code in src/phyllotaxis_analysis/analysis_functions.py
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 |
|
is_n_admissible_integers Link
is_n_admissible_integers(U, n)
check whether an entered sequence of integers is an order index series of any n
-admissible sequence.
:Parameters:
- U
- a sequence of integers
- n
- maximum number of organs involved in permutations
:Returns:
- True if the seq
is n
-admissible, otherwise False
- permutations
- list of permutations
Source code in src/phyllotaxis_analysis/analysis_functions.py
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 |
|
is_n_admissible_not_first_angles Link
is_n_admissible_not_first_angles(seq, n, canonicalAngle, D_n_coeffDict)
check whether an entered sequence is an n
-admissible sequence without taking into account a possible permutation at the beginning of the sequence.
:Parameters:
- seq
- a sequence of theoretical angles
- n
- maximum number of organs involved in permutations
- canonicalAngle
- canonical angle
- D_n_coeffDict
- dictionary of theoretical angles and their coefficients
:Returns:
- True if the seq
is n
-admissible, otherwise False
- permutations
- list of permutations
- U
- order index series
Source code in src/phyllotaxis_analysis/analysis_functions.py
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 |
|
is_n_admissible_u Link
is_n_admissible_u(seqU, n)
check whether an entered order index series corresponds to an n
-admissible sequence
:Parameters:
- seqU
- order index series
- n
- an integer
:Returns:
- True if the seq
is n
-admissible, otherwise False
- inversionList
- list of permutations
Source code in src/phyllotaxis_analysis/analysis_functions.py
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 |
|
is_permutation Link
is_permutation(seq, minElement, n)
check whether the entered list is a permutation of successive integers.
:Parameters:
- seq
- a sequence of integers
- n
- an integer
- minElement
- an integer
:Returns:
- True if seq
is a permutation of [minElement, ...., minElement + n - 1]
Source code in src/phyllotaxis_analysis/analysis_functions.py
278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 |
|
is_sub_sequence Link
is_sub_sequence(seq1, seq2)
check whether one sequence is subsequence of the other.
:Parameters: - seq1 - a sequence of angles - seq2 - a sequence of angles
:Returns:
- True if seq1
is a subsequence of seq2
, otherwise returns False.
Source code in src/phyllotaxis_analysis/analysis_functions.py
259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 |
|
lists_complement_as_set Link
lists_complement_as_set(LOfL1, removeList)
return relative complement, given two lists of list (that should be considered as a list).
:Parameters:
- LOfL1
- a list of lists
- removeList
- a list of list
:Returns:
complements
- relative complement of removeList
to LOfL1
Source code in src/phyllotaxis_analysis/analysis_functions.py
577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 |
|
log_of_prob_of_angle Link
log_of_prob_of_angle(x, mu, kappa, tAngles)
calculate logarithmic value of probability of assigning a theoretical angle to a measured angle
:Parameters:
- x
- measured angle
- mu
- theoretical angle
- kappa
- concentration parameter
- tAngles
- list of theoretical angles
:Returns:
- logarithmic value of probability of assigning of mu
, to x
Source code in src/phyllotaxis_analysis/analysis_functions.py
180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 |
|
make_n_admissible_tree Link
make_n_admissible_tree(seq, permutationBlockMaxSize, canonicalAngle, bordersDict, threshold, D_n, theoreticalCoeffAngles, D_n_coeffDict, kappa, seqBegin=False)
make n
-admissible tree coding sequence of measured angles. It stops when it can not code an angle, i.e. at a not explained angle
:Parameters:
- seq
- sequence of measured angles
- permutationBlockMaxSize
- maximum number of organs involved in permutations
- canonicalAngle
- canonical divergence angle
- bordersDict
- dictionary of theoretical angles and the corresponding intervals
- kappa
- concentration parameter
- threshold
- a statistical threshold to prune the n
-admissible trees
- D_n
- list of theoretical angles
- theoreticalCoeffAngles
- list of coefficients of theoretical angles
- D_n_coeffDict
- dictionary of theoretical angles and their coefficients
- kappa
- concentration parameter
- seqBegin
- indicates whether permutations at the beginning of the sequence should be taken into account
:Returns:
- n
-admissible tree
Source code in src/phyllotaxis_analysis/analysis_functions.py
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 |
|
max_prob_angle Link
max_prob_angle(x, kappa, theoreticalAngles)
calculate the list of most probable theoretical angles
:Parameters:
- x
- measured angle
- mu
- theoretical angle
- theoreticalAngles
- list of theoretical angles
:Returns:
- list of most probable theoretical angles that can be assigned to x
Source code in src/phyllotaxis_analysis/analysis_functions.py
197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 |
|
myVMpdf Link
myVMpdf(x, mu, kappa)
Computes the Von Mises probability density function.
The Von Mises distribution is a continuous probability distribution over the circle. It is also known as the circular normal distribution or Tikhonov distribution.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x
|
array_like
|
Quantiles at which to evaluate the probability density function. |
required |
mu
|
float
|
The location parameter of the Von Mises distribution. Represents the mean direction of the distribution. |
required |
kappa
|
float
|
The concentration parameter of the Von Mises distribution. Controls how concentrated the distribution is around its mean. |
required |
Returns:
Type | Description |
---|---|
array_like
|
The value of the probability density function at |
References
.. [1] Von Mises, R., "Das analytische Direktionsproblem für Kreiskegel," Zeitschrift für Angewandte Mathematik und Mechanik, vol. 8, no. 5, pp. 321-329, 1928. .. [2] Mardia, K. V., J. T. Kent, and J. M. Bibby, "Multivariate Analysis," Academic Press, London, UK, pp. 45-46, 1979.
Source code in src/phyllotaxis_analysis/analysis_functions.py
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 |
|
prob_of_angle Link
prob_of_angle(x, mu, kappa, tAngles)
calculate probability of assigning a theoretical angle to a measured angle
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x
|
array_like
|
measured angle |
required |
mu
|
float
|
theoretical angle |
required |
kappa
|
float
|
concentration parameter |
required |
tAngles
|
list
|
list of theoretical angles |
required |
Source code in src/phyllotaxis_analysis/analysis_functions.py
158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 |
|
sub_invalidate_last Link
sub_invalidate_last(inversions, last)
identify from a list of permutations, those that should be invalidated given an element of an invalid permutation
:Parameters:
- inversions
- list of permutations
- last
- an element of an invalid permutation
:Returns:
invalidate
- list of invalid permutations
Source code in src/phyllotaxis_analysis/analysis_functions.py
861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 |
|
theoretical_divergence_angles Link
theoretical_divergence_angles(permutation_block_max_size, alpha)
Calculates theoretical divergence angles for a given permutation block maximum size and alpha value.
This function generates the coefficients for the theoretical divergence angles and then calculates the actual angles based on those coefficients and the provided alpha value. It also checks if there are any equal theoretical divergence angles and raises an error if that is the case.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
permutation_block_max_size
|
int
|
The maximum size of the permutation block. This value should be a positive integer. |
required |
alpha
|
float
|
The alpha value used to calculate the theoretical divergence angles. This value should be a positive number. |
required |
Returns:
Type | Description |
---|---|
list of float
|
A list of the calculated theoretical divergence angles. |
list of int
|
A list of the coefficients used to calculate the theoretical divergence angles. |
Raises:
Type | Description |
---|---|
EqualTheorAngles
|
Raised when there are two or more equal theoretical divergence angles. |
Source code in src/phyllotaxis_analysis/analysis_functions.py
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 |
|