Mercurial > hg > octave-lyh
comparison doc/interpreter/tips.txi @ 14093:050bc580cb60 stable
doc: Various docstring improvements before 3.6.0 release.
* NEWS, aspell-octave.en.pws, intro.txi, oop.txi, testfun.txi, tips.txi,
FIRfilter.m, FIRfilter_aggregation.m, polynomial.m, polynomial_superiorto.m,
usejava.m, pcg.m, pcr.m, nchoosek.m, validatestring.m, assert.m, weekday.m,
cellfun.cc, error.cc, strfns.cc: Various docstring improvements before 3.6.0
release.
author | Rik <octave@nomad.inbox5.com> |
---|---|
date | Wed, 21 Dec 2011 19:46:57 -0800 |
parents | a1e386b9ef4b |
children | 951eacaf9381 |
comparison
equal
deleted
inserted
replaced
14092:22c50cbad2ce | 14093:050bc580cb60 |
---|---|
687 example of which is the @code{nchoosek} function. The Texinfo | 687 example of which is the @code{nchoosek} function. The Texinfo |
688 documentation string for @code{nchoosek} is | 688 documentation string for @code{nchoosek} is |
689 | 689 |
690 @example | 690 @example |
691 -*- texinfo -*- | 691 -*- texinfo -*- |
692 @@deftypefn @{Function File@} @{@} nchoosek (@@var@{n@}, @@var@{k@}) | 692 @@deftypefn @{Function File@} @{@@var@{c@} =@} nchoosek (@@var@{n@}, @@var@{k@}) |
693 | 693 @@deftypefnx @{Function File@} @{@@var@{c@} =@} nchoosek (@@var@{set@}, @@var@{k@}) |
694 Compute the binomial coefficient or all combinations of | 694 |
695 @@var@{n@}. If @@var@{n@} is a scalar then, calculate the | 695 Compute the binomial coefficient or all combinations of a set of items. |
696 binomial coefficient of @@var@{n@} and @@var@{k@}, defined as | 696 |
697 | 697 If @@var@{n@} is a scalar then calculate the binomial coefficient |
698 of @@var@{n@} and @@var@{k@} which is defined as | |
698 @@tex | 699 @@tex |
699 $$ | 700 $$ |
700 @{n \choose k@} = @{n (n-1) (n-2) \cdots (n-k+1) \over k!@} | 701 @{n \choose k@} = @{n (n-1) (n-2) \cdots (n-k+1) \over k!@} |
702 = @{n! \over k! (n-k)!@} | |
701 $$ | 703 $$ |
702 @@end tex | 704 @@end tex |
703 @@ifnottex | 705 @@ifnottex |
704 | 706 |
705 @@example | 707 @@example |
706 @@group | 708 @@group |
707 / \ | 709 / \ |
708 | n | n (n-1) (n-2) @dots{} (n-k+1) | 710 | n | n (n-1) (n-2) @@dots@{@} (n-k+1) n! |
709 | | = ------------------------- | 711 | | = ------------------------- = --------- |
710 | k | k! | 712 | k | k! k! (n-k)! |
711 \ / | 713 \ / |
712 @@end group | 714 @@end group |
713 @@end example | 715 @@end example |
716 | |
714 @@end ifnottex | 717 @@end ifnottex |
715 | 718 @@noindent |
716 If @@var@{n@} is a vector, this generates all combinations | 719 This is the number of combinations of @@var@{n@} items taken in groups of |
717 of the elements of @@var@{n@}, taken @@var@{k@} at a time, | 720 size @@var@{k@}. |
718 one row per combination. The resulting @@var@{c@} has size | 721 |
719 @@code@{[nchoosek (length (@@var@{n@}),@@var@{k@}), @@var@{k@}]@}. | 722 If the first argument is a vector, @@var@{set@}, then generate all |
720 | 723 combinations of the elements of @@var@{set@}, taken @@var@{k@} at a time, with |
721 @@code@{nchoosek@} works only for non-negative integer arguments; use | 724 one row per combination. The result @@var@{c@} has @@var@{k@} columns and |
722 @@code@{bincoeff@} for non-integer scalar arguments and for using vector | 725 @@w@{@@code@{nchoosek (length (@@var@{set@}), @@var@{k@})@}@} rows. |
723 arguments to compute many coefficients at once. | 726 |
724 | 727 For example: |
725 @@seealso@{bincoeff@} | 728 |
729 How many ways can three items be grouped into pairs? | |
730 | |
731 @@example | |
732 @@group | |
733 nchoosek (3, 2) | |
734 @@result@{@} 3 | |
735 @@end group | |
736 @@end example | |
737 | |
738 What are the possible pairs? | |
739 | |
740 @@example | |
741 @@group | |
742 nchoosek (1:3, 2) | |
743 @@result@{@} 1 2 | |
744 1 3 | |
745 2 3 | |
746 @@end group | |
747 @@end example | |
748 | |
749 @@code@{nchoosek@} works only for non-negative, integer arguments. Use | |
750 @@code@{bincoeff@} for non-integer and negative scalar arguments, or for | |
751 computing many binomial coefficients at once with vector inputs | |
752 for @@var@{n@} or @@var@{k@}. | |
753 | |
754 @@seealso@{bincoeff, perms@} | |
726 @@end deftypefn | 755 @@end deftypefn |
727 @end example | 756 @end example |
728 | 757 @noindent |
729 which demonstrates most of the concepts discussed above. | 758 which demonstrates most of the concepts discussed above. |
730 @iftex | 759 @iftex |
731 This documentation string renders as | 760 This documentation string renders as |
732 | 761 |
733 @c Note actually use the output of info below rather than try and | 762 @c Note: use the actual output of info below, rather than try and |
734 @c reproduce it here to prevent it looking different than how it would | 763 @c reproduce it here to prevent it looking different from how it would |
735 @c appear with info. | 764 @c appear with info. |
736 @example | 765 @example |
737 @group | |
738 -- Function File: C = nchoosek (N, K) | 766 -- Function File: C = nchoosek (N, K) |
739 Compute the binomial coefficient or all combinations | 767 -- Function File: C = nchoosek (SET, K) |
740 of N. If N is a scalar then, calculate the binomial | 768 Compute the binomial coefficient or all combinations of a set of |
741 coefficient of N and K, defined as | 769 items. |
770 | |
771 If N is a scalar then calculate the binomial coefficient of N and | |
772 K which is defined as | |
742 | 773 |
743 / \ | 774 / \ |
744 | n | n (n-1) (n-2) @dots{} (n-k+1) n! | 775 | n | n (n-1) (n-2) ... (n-k+1) n! |
745 | | = ------------------------- = --------- | 776 | | = ------------------------- = --------- |
746 | k | k! k! (n-k)! | 777 | k | k! k! (n-k)! |
747 \ / | 778 \ / |
748 | 779 |
749 If N is a vector generate all combinations of the | 780 This is the number of combinations of N items taken in groups of |
750 elements of N, taken K at a time, one row per | 781 size K. |
751 combination. The resulting C has size `[nchoosek | 782 |
752 (length (N), K), K]'. | 783 If the first argument is a vector, SET, then generate all |
753 | 784 combinations of the elements of SET, taken K at a time, with one |
754 `nchoosek' works only for non-negative integer | 785 row per combination. The result C has K columns and |
755 arguments; use `bincoeff' for non-integer scalar | 786 `nchoosek (length (SET), K)' rows. |
756 arguments and for using vector arguments to compute | 787 |
757 many coefficients at once. | 788 For example: |
758 | 789 |
759 See also: bincoeff. | 790 How many ways can three items be grouped into pairs? |
760 @end group | 791 |
761 @end example | 792 nchoosek (3, 2) |
762 | 793 => 3 |
763 using info, whereas in a printed documentation using @TeX{} it will appear | 794 |
764 as | 795 What are the possible pairs? |
765 | 796 |
766 @deftypefn {Function File} {@var{c} =} nchoosek (@var{n}, @var{k}) | 797 nchoosek (1:3, 2) |
767 | 798 => 1 2 |
768 Compute the binomial coefficient or all combinations of @var{n}. | 799 1 3 |
769 If @var{n} is a scalar then, calculate the binomial coefficient | 800 2 3 |
770 of @var{n} and @var{k}, defined as | 801 |
802 `nchoosek' works only for non-negative, integer arguments. Use | |
803 `bincoeff' for non-integer and negative scalar arguments, or for | |
804 computing many binomial coefficients at once with vector inputs | |
805 for N or K. | |
806 | |
807 See also: bincoeff, perms | |
808 @end example | |
809 @noindent | |
810 using info, whereas in a printed documentation using @TeX{} it will | |
811 appear as | |
812 | |
813 @deftypefn {Function File} {@var{c} =} nchoosek (@var{n}, @var{k}) | |
814 @deftypefnx {Function File} {@var{c} =} nchoosek (@var{set}, @var{k}) | |
815 | |
816 Compute the binomial coefficient or all combinations of a set of items. | |
817 | |
818 If @var{n} is a scalar then calculate the binomial coefficient | |
819 of @var{n} and @var{k} which is defined as | |
771 | 820 |
772 @tex | 821 @tex |
773 $$ | 822 $$ |
774 {n \choose k} = {n (n-1) (n-2) \cdots (n-k+1) \over k!} | 823 {n \choose k} = {n (n-1) (n-2) \cdots (n-k+1) \over k!} |
824 = {n! \over k! (n-k)!} | |
775 $$ | 825 $$ |
776 @end tex | 826 @end tex |
777 | 827 |
778 If @var{n} is a vector generate all combinations of the elements | 828 @noindent |
779 of @var{n}, taken @var{k} at a time, one row per combination. The | 829 This is the number of combinations of @var{n} items taken in groups of |
780 resulting @var{c} has size @code{[nchoosek (length (@var{n}), | 830 size @var{k}. |
781 @var{k}), @var{k}]}. | 831 |
782 | 832 If the first argument is a vector, @var{set}, then generate all |
783 @code{nchoosek} works only for non-negative integer arguments; use | 833 combinations of the elements of @var{set}, taken @var{k} at a time, with |
784 @code{bincoeff} for non-integer scalar arguments and for using vector | 834 one row per combination. The result @var{c} has @var{k} columns and |
785 arguments to compute many coefficients at once. | 835 @w{@code{nchoosek (length (@var{set}), @var{k})}} rows. |
786 | 836 |
787 @seealso{bincoeff} | 837 For example: |
838 | |
839 How many ways can three items be grouped into pairs? | |
840 | |
841 @example | |
842 @group | |
843 nchoosek (3, 2) | |
844 @result{} 3 | |
845 @end group | |
846 @end example | |
847 | |
848 What are the possible pairs? | |
849 | |
850 @example | |
851 @group | |
852 nchoosek (1:3, 2) | |
853 @result{} 1 2 | |
854 1 3 | |
855 2 3 | |
856 @end group | |
857 @end example | |
858 | |
859 @code{nchoosek} works only for non-negative, integer arguments. Use | |
860 @code{bincoeff} for non-integer and negative scalar arguments, or for | |
861 computing many binomial coefficients at once with vector inputs for @var{n} | |
862 or @var{k}. | |
863 | |
864 @seealso{bincoeff, perms} | |
788 @end deftypefn | 865 @end deftypefn |
789 | 866 |
790 @end iftex | 867 @end iftex |