summaryrefslogtreecommitdiff
path: root/Master
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2018-07-22 21:18:56 +0000
committerKarl Berry <karl@freefriends.org>2018-07-22 21:18:56 +0000
commitb1496772d2411cb086cb624b017404e97490229e (patch)
treee73d5bd6e75036ed828770dd1fffd9883a0410b0 /Master
parent74b704dd83eb2b8913e207a3e53a035eafbc457c (diff)
statistics (22jul18)
git-svn-id: svn://tug.org/texlive/trunk@48252 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master')
-rw-r--r--Master/texmf-dist/doc/latex/statistics/LICENSE674
-rw-r--r--Master/texmf-dist/doc/latex/statistics/README.md21
-rw-r--r--Master/texmf-dist/doc/latex/statistics/statistics.pdfbin0 -> 427734 bytes
-rw-r--r--Master/texmf-dist/source/latex/statistics/statistics.dtx3613
-rw-r--r--Master/texmf-dist/source/latex/statistics/statistics.ins24
-rw-r--r--Master/texmf-dist/tex/latex/statistics/statistics.sty1512
-rwxr-xr-xMaster/tlpkg/bin/tlpkg-ctan-check2
-rw-r--r--Master/tlpkg/tlpsrc/collection-latexextra.tlpsrc1
-rw-r--r--Master/tlpkg/tlpsrc/collection-mathscience.tlpsrc6
-rw-r--r--Master/tlpkg/tlpsrc/statistics.tlpsrc0
10 files changed, 5849 insertions, 4 deletions
diff --git a/Master/texmf-dist/doc/latex/statistics/LICENSE b/Master/texmf-dist/doc/latex/statistics/LICENSE
new file mode 100644
index 00000000000..41d500f5e7c
--- /dev/null
+++ b/Master/texmf-dist/doc/latex/statistics/LICENSE
@@ -0,0 +1,674 @@
+ GNU GENERAL PUBLIC LICENSE
+ Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The GNU General Public License is a free, copyleft license for
+software and other kinds of works.
+
+ The licenses for most software and other practical works are designed
+to take away your freedom to share and change the works. By contrast,
+the GNU General Public License is intended to guarantee your freedom to
+share and change all versions of a program--to make sure it remains free
+software for all its users. We, the Free Software Foundation, use the
+GNU General Public License for most of our software; it applies also to
+any other work released this way by its authors. You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+them if you wish), that you receive source code or can get it if you
+want it, that you can change the software or use pieces of it in new
+free programs, and that you know you can do these things.
+
+ To protect your rights, we need to prevent others from denying you
+these rights or asking you to surrender the rights. Therefore, you have
+certain responsibilities if you distribute copies of the software, or if
+you modify it: responsibilities to respect the freedom of others.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must pass on to the recipients the same
+freedoms that you received. You must make sure that they, too, receive
+or can get the source code. And you must show them these terms so they
+know their rights.
+
+ Developers that use the GNU GPL protect your rights with two steps:
+(1) assert copyright on the software, and (2) offer you this License
+giving you legal permission to copy, distribute and/or modify it.
+
+ For the developers' and authors' protection, the GPL clearly explains
+that there is no warranty for this free software. For both users' and
+authors' sake, the GPL requires that modified versions be marked as
+changed, so that their problems will not be attributed erroneously to
+authors of previous versions.
+
+ Some devices are designed to deny users access to install or run
+modified versions of the software inside them, although the manufacturer
+can do so. This is fundamentally incompatible with the aim of
+protecting users' freedom to change the software. The systematic
+pattern of such abuse occurs in the area of products for individuals to
+use, which is precisely where it is most unacceptable. Therefore, we
+have designed this version of the GPL to prohibit the practice for those
+products. If such problems arise substantially in other domains, we
+stand ready to extend this provision to those domains in future versions
+of the GPL, as needed to protect the freedom of users.
+
+ Finally, every program is threatened constantly by software patents.
+States should not allow patents to restrict development and use of
+software on general-purpose computers, but in those that do, we wish to
+avoid the special danger that patents applied to a free program could
+make it effectively proprietary. To prevent this, the GPL assures that
+patents cannot be used to render the program non-free.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ TERMS AND CONDITIONS
+
+ 0. Definitions.
+
+ "This License" refers to version 3 of the GNU General Public License.
+
+ "Copyright" also means copyright-like laws that apply to other kinds of
+works, such as semiconductor masks.
+
+ "The Program" refers to any copyrightable work licensed under this
+License. Each licensee is addressed as "you". "Licensees" and
+"recipients" may be individuals or organizations.
+
+ To "modify" a work means to copy from or adapt all or part of the work
+in a fashion requiring copyright permission, other than the making of an
+exact copy. The resulting work is called a "modified version" of the
+earlier work or a work "based on" the earlier work.
+
+ A "covered work" means either the unmodified Program or a work based
+on the Program.
+
+ To "propagate" a work means to do anything with it that, without
+permission, would make you directly or secondarily liable for
+infringement under applicable copyright law, except executing it on a
+computer or modifying a private copy. Propagation includes copying,
+distribution (with or without modification), making available to the
+public, and in some countries other activities as well.
+
+ To "convey" a work means any kind of propagation that enables other
+parties to make or receive copies. Mere interaction with a user through
+a computer network, with no transfer of a copy, is not conveying.
+
+ An interactive user interface displays "Appropriate Legal Notices"
+to the extent that it includes a convenient and prominently visible
+feature that (1) displays an appropriate copyright notice, and (2)
+tells the user that there is no warranty for the work (except to the
+extent that warranties are provided), that licensees may convey the
+work under this License, and how to view a copy of this License. If
+the interface presents a list of user commands or options, such as a
+menu, a prominent item in the list meets this criterion.
+
+ 1. Source Code.
+
+ The "source code" for a work means the preferred form of the work
+for making modifications to it. "Object code" means any non-source
+form of a work.
+
+ A "Standard Interface" means an interface that either is an official
+standard defined by a recognized standards body, or, in the case of
+interfaces specified for a particular programming language, one that
+is widely used among developers working in that language.
+
+ The "System Libraries" of an executable work include anything, other
+than the work as a whole, that (a) is included in the normal form of
+packaging a Major Component, but which is not part of that Major
+Component, and (b) serves only to enable use of the work with that
+Major Component, or to implement a Standard Interface for which an
+implementation is available to the public in source code form. A
+"Major Component", in this context, means a major essential component
+(kernel, window system, and so on) of the specific operating system
+(if any) on which the executable work runs, or a compiler used to
+produce the work, or an object code interpreter used to run it.
+
+ The "Corresponding Source" for a work in object code form means all
+the source code needed to generate, install, and (for an executable
+work) run the object code and to modify the work, including scripts to
+control those activities. However, it does not include the work's
+System Libraries, or general-purpose tools or generally available free
+programs which are used unmodified in performing those activities but
+which are not part of the work. For example, Corresponding Source
+includes interface definition files associated with source files for
+the work, and the source code for shared libraries and dynamically
+linked subprograms that the work is specifically designed to require,
+such as by intimate data communication or control flow between those
+subprograms and other parts of the work.
+
+ The Corresponding Source need not include anything that users
+can regenerate automatically from other parts of the Corresponding
+Source.
+
+ The Corresponding Source for a work in source code form is that
+same work.
+
+ 2. Basic Permissions.
+
+ All rights granted under this License are granted for the term of
+copyright on the Program, and are irrevocable provided the stated
+conditions are met. This License explicitly affirms your unlimited
+permission to run the unmodified Program. The output from running a
+covered work is covered by this License only if the output, given its
+content, constitutes a covered work. This License acknowledges your
+rights of fair use or other equivalent, as provided by copyright law.
+
+ You may make, run and propagate covered works that you do not
+convey, without conditions so long as your license otherwise remains
+in force. You may convey covered works to others for the sole purpose
+of having them make modifications exclusively for you, or provide you
+with facilities for running those works, provided that you comply with
+the terms of this License in conveying all material for which you do
+not control copyright. Those thus making or running the covered works
+for you must do so exclusively on your behalf, under your direction
+and control, on terms that prohibit them from making any copies of
+your copyrighted material outside their relationship with you.
+
+ Conveying under any other circumstances is permitted solely under
+the conditions stated below. Sublicensing is not allowed; section 10
+makes it unnecessary.
+
+ 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
+
+ No covered work shall be deemed part of an effective technological
+measure under any applicable law fulfilling obligations under article
+11 of the WIPO copyright treaty adopted on 20 December 1996, or
+similar laws prohibiting or restricting circumvention of such
+measures.
+
+ When you convey a covered work, you waive any legal power to forbid
+circumvention of technological measures to the extent such circumvention
+is effected by exercising rights under this License with respect to
+the covered work, and you disclaim any intention to limit operation or
+modification of the work as a means of enforcing, against the work's
+users, your or third parties' legal rights to forbid circumvention of
+technological measures.
+
+ 4. Conveying Verbatim Copies.
+
+ You may convey verbatim copies of the Program's source code as you
+receive it, in any medium, provided that you conspicuously and
+appropriately publish on each copy an appropriate copyright notice;
+keep intact all notices stating that this License and any
+non-permissive terms added in accord with section 7 apply to the code;
+keep intact all notices of the absence of any warranty; and give all
+recipients a copy of this License along with the Program.
+
+ You may charge any price or no price for each copy that you convey,
+and you may offer support or warranty protection for a fee.
+
+ 5. Conveying Modified Source Versions.
+
+ You may convey a work based on the Program, or the modifications to
+produce it from the Program, in the form of source code under the
+terms of section 4, provided that you also meet all of these conditions:
+
+ a) The work must carry prominent notices stating that you modified
+ it, and giving a relevant date.
+
+ b) The work must carry prominent notices stating that it is
+ released under this License and any conditions added under section
+ 7. This requirement modifies the requirement in section 4 to
+ "keep intact all notices".
+
+ c) You must license the entire work, as a whole, under this
+ License to anyone who comes into possession of a copy. This
+ License will therefore apply, along with any applicable section 7
+ additional terms, to the whole of the work, and all its parts,
+ regardless of how they are packaged. This License gives no
+ permission to license the work in any other way, but it does not
+ invalidate such permission if you have separately received it.
+
+ d) If the work has interactive user interfaces, each must display
+ Appropriate Legal Notices; however, if the Program has interactive
+ interfaces that do not display Appropriate Legal Notices, your
+ work need not make them do so.
+
+ A compilation of a covered work with other separate and independent
+works, which are not by their nature extensions of the covered work,
+and which are not combined with it such as to form a larger program,
+in or on a volume of a storage or distribution medium, is called an
+"aggregate" if the compilation and its resulting copyright are not
+used to limit the access or legal rights of the compilation's users
+beyond what the individual works permit. Inclusion of a covered work
+in an aggregate does not cause this License to apply to the other
+parts of the aggregate.
+
+ 6. Conveying Non-Source Forms.
+
+ You may convey a covered work in object code form under the terms
+of sections 4 and 5, provided that you also convey the
+machine-readable Corresponding Source under the terms of this License,
+in one of these ways:
+
+ a) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by the
+ Corresponding Source fixed on a durable physical medium
+ customarily used for software interchange.
+
+ b) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by a
+ written offer, valid for at least three years and valid for as
+ long as you offer spare parts or customer support for that product
+ model, to give anyone who possesses the object code either (1) a
+ copy of the Corresponding Source for all the software in the
+ product that is covered by this License, on a durable physical
+ medium customarily used for software interchange, for a price no
+ more than your reasonable cost of physically performing this
+ conveying of source, or (2) access to copy the
+ Corresponding Source from a network server at no charge.
+
+ c) Convey individual copies of the object code with a copy of the
+ written offer to provide the Corresponding Source. This
+ alternative is allowed only occasionally and noncommercially, and
+ only if you received the object code with such an offer, in accord
+ with subsection 6b.
+
+ d) Convey the object code by offering access from a designated
+ place (gratis or for a charge), and offer equivalent access to the
+ Corresponding Source in the same way through the same place at no
+ further charge. You need not require recipients to copy the
+ Corresponding Source along with the object code. If the place to
+ copy the object code is a network server, the Corresponding Source
+ may be on a different server (operated by you or a third party)
+ that supports equivalent copying facilities, provided you maintain
+ clear directions next to the object code saying where to find the
+ Corresponding Source. Regardless of what server hosts the
+ Corresponding Source, you remain obligated to ensure that it is
+ available for as long as needed to satisfy these requirements.
+
+ e) Convey the object code using peer-to-peer transmission, provided
+ you inform other peers where the object code and Corresponding
+ Source of the work are being offered to the general public at no
+ charge under subsection 6d.
+
+ A separable portion of the object code, whose source code is excluded
+from the Corresponding Source as a System Library, need not be
+included in conveying the object code work.
+
+ A "User Product" is either (1) a "consumer product", which means any
+tangible personal property which is normally used for personal, family,
+or household purposes, or (2) anything designed or sold for incorporation
+into a dwelling. In determining whether a product is a consumer product,
+doubtful cases shall be resolved in favor of coverage. For a particular
+product received by a particular user, "normally used" refers to a
+typical or common use of that class of product, regardless of the status
+of the particular user or of the way in which the particular user
+actually uses, or expects or is expected to use, the product. A product
+is a consumer product regardless of whether the product has substantial
+commercial, industrial or non-consumer uses, unless such uses represent
+the only significant mode of use of the product.
+
+ "Installation Information" for a User Product means any methods,
+procedures, authorization keys, or other information required to install
+and execute modified versions of a covered work in that User Product from
+a modified version of its Corresponding Source. The information must
+suffice to ensure that the continued functioning of the modified object
+code is in no case prevented or interfered with solely because
+modification has been made.
+
+ If you convey an object code work under this section in, or with, or
+specifically for use in, a User Product, and the conveying occurs as
+part of a transaction in which the right of possession and use of the
+User Product is transferred to the recipient in perpetuity or for a
+fixed term (regardless of how the transaction is characterized), the
+Corresponding Source conveyed under this section must be accompanied
+by the Installation Information. But this requirement does not apply
+if neither you nor any third party retains the ability to install
+modified object code on the User Product (for example, the work has
+been installed in ROM).
+
+ The requirement to provide Installation Information does not include a
+requirement to continue to provide support service, warranty, or updates
+for a work that has been modified or installed by the recipient, or for
+the User Product in which it has been modified or installed. Access to a
+network may be denied when the modification itself materially and
+adversely affects the operation of the network or violates the rules and
+protocols for communication across the network.
+
+ Corresponding Source conveyed, and Installation Information provided,
+in accord with this section must be in a format that is publicly
+documented (and with an implementation available to the public in
+source code form), and must require no special password or key for
+unpacking, reading or copying.
+
+ 7. Additional Terms.
+
+ "Additional permissions" are terms that supplement the terms of this
+License by making exceptions from one or more of its conditions.
+Additional permissions that are applicable to the entire Program shall
+be treated as though they were included in this License, to the extent
+that they are valid under applicable law. If additional permissions
+apply only to part of the Program, that part may be used separately
+under those permissions, but the entire Program remains governed by
+this License without regard to the additional permissions.
+
+ When you convey a copy of a covered work, you may at your option
+remove any additional permissions from that copy, or from any part of
+it. (Additional permissions may be written to require their own
+removal in certain cases when you modify the work.) You may place
+additional permissions on material, added by you to a covered work,
+for which you have or can give appropriate copyright permission.
+
+ Notwithstanding any other provision of this License, for material you
+add to a covered work, you may (if authorized by the copyright holders of
+that material) supplement the terms of this License with terms:
+
+ a) Disclaiming warranty or limiting liability differently from the
+ terms of sections 15 and 16 of this License; or
+
+ b) Requiring preservation of specified reasonable legal notices or
+ author attributions in that material or in the Appropriate Legal
+ Notices displayed by works containing it; or
+
+ c) Prohibiting misrepresentation of the origin of that material, or
+ requiring that modified versions of such material be marked in
+ reasonable ways as different from the original version; or
+
+ d) Limiting the use for publicity purposes of names of licensors or
+ authors of the material; or
+
+ e) Declining to grant rights under trademark law for use of some
+ trade names, trademarks, or service marks; or
+
+ f) Requiring indemnification of licensors and authors of that
+ material by anyone who conveys the material (or modified versions of
+ it) with contractual assumptions of liability to the recipient, for
+ any liability that these contractual assumptions directly impose on
+ those licensors and authors.
+
+ All other non-permissive additional terms are considered "further
+restrictions" within the meaning of section 10. If the Program as you
+received it, or any part of it, contains a notice stating that it is
+governed by this License along with a term that is a further
+restriction, you may remove that term. If a license document contains
+a further restriction but permits relicensing or conveying under this
+License, you may add to a covered work material governed by the terms
+of that license document, provided that the further restriction does
+not survive such relicensing or conveying.
+
+ If you add terms to a covered work in accord with this section, you
+must place, in the relevant source files, a statement of the
+additional terms that apply to those files, or a notice indicating
+where to find the applicable terms.
+
+ Additional terms, permissive or non-permissive, may be stated in the
+form of a separately written license, or stated as exceptions;
+the above requirements apply either way.
+
+ 8. Termination.
+
+ You may not propagate or modify a covered work except as expressly
+provided under this License. Any attempt otherwise to propagate or
+modify it is void, and will automatically terminate your rights under
+this License (including any patent licenses granted under the third
+paragraph of section 11).
+
+ However, if you cease all violation of this License, then your
+license from a particular copyright holder is reinstated (a)
+provisionally, unless and until the copyright holder explicitly and
+finally terminates your license, and (b) permanently, if the copyright
+holder fails to notify you of the violation by some reasonable means
+prior to 60 days after the cessation.
+
+ Moreover, your license from a particular copyright holder is
+reinstated permanently if the copyright holder notifies you of the
+violation by some reasonable means, this is the first time you have
+received notice of violation of this License (for any work) from that
+copyright holder, and you cure the violation prior to 30 days after
+your receipt of the notice.
+
+ Termination of your rights under this section does not terminate the
+licenses of parties who have received copies or rights from you under
+this License. If your rights have been terminated and not permanently
+reinstated, you do not qualify to receive new licenses for the same
+material under section 10.
+
+ 9. Acceptance Not Required for Having Copies.
+
+ You are not required to accept this License in order to receive or
+run a copy of the Program. Ancillary propagation of a covered work
+occurring solely as a consequence of using peer-to-peer transmission
+to receive a copy likewise does not require acceptance. However,
+nothing other than this License grants you permission to propagate or
+modify any covered work. These actions infringe copyright if you do
+not accept this License. Therefore, by modifying or propagating a
+covered work, you indicate your acceptance of this License to do so.
+
+ 10. Automatic Licensing of Downstream Recipients.
+
+ Each time you convey a covered work, the recipient automatically
+receives a license from the original licensors, to run, modify and
+propagate that work, subject to this License. You are not responsible
+for enforcing compliance by third parties with this License.
+
+ An "entity transaction" is a transaction transferring control of an
+organization, or substantially all assets of one, or subdividing an
+organization, or merging organizations. If propagation of a covered
+work results from an entity transaction, each party to that
+transaction who receives a copy of the work also receives whatever
+licenses to the work the party's predecessor in interest had or could
+give under the previous paragraph, plus a right to possession of the
+Corresponding Source of the work from the predecessor in interest, if
+the predecessor has it or can get it with reasonable efforts.
+
+ You may not impose any further restrictions on the exercise of the
+rights granted or affirmed under this License. For example, you may
+not impose a license fee, royalty, or other charge for exercise of
+rights granted under this License, and you may not initiate litigation
+(including a cross-claim or counterclaim in a lawsuit) alleging that
+any patent claim is infringed by making, using, selling, offering for
+sale, or importing the Program or any portion of it.
+
+ 11. Patents.
+
+ A "contributor" is a copyright holder who authorizes use under this
+License of the Program or a work on which the Program is based. The
+work thus licensed is called the contributor's "contributor version".
+
+ A contributor's "essential patent claims" are all patent claims
+owned or controlled by the contributor, whether already acquired or
+hereafter acquired, that would be infringed by some manner, permitted
+by this License, of making, using, or selling its contributor version,
+but do not include claims that would be infringed only as a
+consequence of further modification of the contributor version. For
+purposes of this definition, "control" includes the right to grant
+patent sublicenses in a manner consistent with the requirements of
+this License.
+
+ Each contributor grants you a non-exclusive, worldwide, royalty-free
+patent license under the contributor's essential patent claims, to
+make, use, sell, offer for sale, import and otherwise run, modify and
+propagate the contents of its contributor version.
+
+ In the following three paragraphs, a "patent license" is any express
+agreement or commitment, however denominated, not to enforce a patent
+(such as an express permission to practice a patent or covenant not to
+sue for patent infringement). To "grant" such a patent license to a
+party means to make such an agreement or commitment not to enforce a
+patent against the party.
+
+ If you convey a covered work, knowingly relying on a patent license,
+and the Corresponding Source of the work is not available for anyone
+to copy, free of charge and under the terms of this License, through a
+publicly available network server or other readily accessible means,
+then you must either (1) cause the Corresponding Source to be so
+available, or (2) arrange to deprive yourself of the benefit of the
+patent license for this particular work, or (3) arrange, in a manner
+consistent with the requirements of this License, to extend the patent
+license to downstream recipients. "Knowingly relying" means you have
+actual knowledge that, but for the patent license, your conveying the
+covered work in a country, or your recipient's use of the covered work
+in a country, would infringe one or more identifiable patents in that
+country that you have reason to believe are valid.
+
+ If, pursuant to or in connection with a single transaction or
+arrangement, you convey, or propagate by procuring conveyance of, a
+covered work, and grant a patent license to some of the parties
+receiving the covered work authorizing them to use, propagate, modify
+or convey a specific copy of the covered work, then the patent license
+you grant is automatically extended to all recipients of the covered
+work and works based on it.
+
+ A patent license is "discriminatory" if it does not include within
+the scope of its coverage, prohibits the exercise of, or is
+conditioned on the non-exercise of one or more of the rights that are
+specifically granted under this License. You may not convey a covered
+work if you are a party to an arrangement with a third party that is
+in the business of distributing software, under which you make payment
+to the third party based on the extent of your activity of conveying
+the work, and under which the third party grants, to any of the
+parties who would receive the covered work from you, a discriminatory
+patent license (a) in connection with copies of the covered work
+conveyed by you (or copies made from those copies), or (b) primarily
+for and in connection with specific products or compilations that
+contain the covered work, unless you entered into that arrangement,
+or that patent license was granted, prior to 28 March 2007.
+
+ Nothing in this License shall be construed as excluding or limiting
+any implied license or other defenses to infringement that may
+otherwise be available to you under applicable patent law.
+
+ 12. No Surrender of Others' Freedom.
+
+ If conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot convey a
+covered work so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you may
+not convey it at all. For example, if you agree to terms that obligate you
+to collect a royalty for further conveying from those to whom you convey
+the Program, the only way you could satisfy both those terms and this
+License would be to refrain entirely from conveying the Program.
+
+ 13. Use with the GNU Affero General Public License.
+
+ Notwithstanding any other provision of this License, you have
+permission to link or combine any covered work with a work licensed
+under version 3 of the GNU Affero General Public License into a single
+combined work, and to convey the resulting work. The terms of this
+License will continue to apply to the part which is the covered work,
+but the special requirements of the GNU Affero General Public License,
+section 13, concerning interaction through a network will apply to the
+combination as such.
+
+ 14. Revised Versions of this License.
+
+ The Free Software Foundation may publish revised and/or new versions of
+the GNU General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+ Each version is given a distinguishing version number. If the
+Program specifies that a certain numbered version of the GNU General
+Public License "or any later version" applies to it, you have the
+option of following the terms and conditions either of that numbered
+version or of any later version published by the Free Software
+Foundation. If the Program does not specify a version number of the
+GNU General Public License, you may choose any version ever published
+by the Free Software Foundation.
+
+ If the Program specifies that a proxy can decide which future
+versions of the GNU General Public License can be used, that proxy's
+public statement of acceptance of a version permanently authorizes you
+to choose that version for the Program.
+
+ Later license versions may give you additional or different
+permissions. However, no additional obligations are imposed on any
+author or copyright holder as a result of your choosing to follow a
+later version.
+
+ 15. Disclaimer of Warranty.
+
+ THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
+APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
+HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
+OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
+IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
+ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 16. Limitation of Liability.
+
+ IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
+THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
+GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
+USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
+DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
+PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
+EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGES.
+
+ 17. Interpretation of Sections 15 and 16.
+
+ If the disclaimer of warranty and limitation of liability provided
+above cannot be given local legal effect according to their terms,
+reviewing courts shall apply local law that most closely approximates
+an absolute waiver of all civil liability in connection with the
+Program, unless a warranty or assumption of liability accompanies a
+copy of the Program in return for a fee.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+state the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+ statistics
+ Copyright (C) 2014-2018 Julien RIVAUD
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+Also add information on how to contact you by electronic and paper mail.
+
+ If the program does terminal interaction, make it output a short
+notice like this when it starts in an interactive mode:
+
+ statistics Copyright (C) 2014-2018 Julien RIVAUD
+ This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, your program's commands
+might be different; for a GUI interface, you would use an "about box".
+
+ You should also get your employer (if you work as a programmer) or school,
+if any, to sign a "copyright disclaimer" for the program, if necessary.
+For more information on this, and how to apply and follow the GNU GPL, see
+<http://www.gnu.org/licenses/>.
+
+ The GNU General Public License does not permit incorporating your program
+into proprietary programs. If your program is a subroutine library, you
+may consider it more useful to permit linking proprietary applications with
+the library. If this is what you want to do, use the GNU Lesser General
+Public License instead of this License. But first, please read
+<http://www.gnu.org/philosophy/why-not-lgpl.html>.
diff --git a/Master/texmf-dist/doc/latex/statistics/README.md b/Master/texmf-dist/doc/latex/statistics/README.md
new file mode 100644
index 00000000000..4a98c88a4af
--- /dev/null
+++ b/Master/texmf-dist/doc/latex/statistics/README.md
@@ -0,0 +1,21 @@
+# The statistics package
+
+The `statistics` package can compute and typeset statistics like
+frequency tables, cumulative distribution functions (increasing or decreasing,
+in frequency or absolute count domain), from the counts of individual values,
+or ranges, or even the raw value list with repetitions.
+
+It can also compute and draw a bar diagram in case of individual values, or,
+when the data repartition is known from ranges, an histogram or the continuous
+cumulative distribution function.
+
+You can ask `statistics` to display no result, selective results or all
+of them. Similarly `statistics` can draw only some parts of the graphs.
+Every part of the generated tables or graphics is customizable.
+
+
+(C) Copyright 2014-2018 RIVAUD Julien
+
+This package may be distributed and/or modified under the conditions of the
+General Public License (GPL), either version 3 of this license or (at your
+option) any later version.
diff --git a/Master/texmf-dist/doc/latex/statistics/statistics.pdf b/Master/texmf-dist/doc/latex/statistics/statistics.pdf
new file mode 100644
index 00000000000..13ba2fb5b16
--- /dev/null
+++ b/Master/texmf-dist/doc/latex/statistics/statistics.pdf
Binary files differ
diff --git a/Master/texmf-dist/source/latex/statistics/statistics.dtx b/Master/texmf-dist/source/latex/statistics/statistics.dtx
new file mode 100644
index 00000000000..bdb85dbff95
--- /dev/null
+++ b/Master/texmf-dist/source/latex/statistics/statistics.dtx
@@ -0,0 +1,3613 @@
+% \iffalse meta-comment
+% vim: tw=80 spl=en
+%
+%% File: statistics.dtx (C) Copyright 2014-2018 RIVAUD Julien
+%%
+%% It may be distributed and/or modified under the conditions of the
+%% General Public License (GPL), either version 3 of this
+%% license or (at your option) any later version.
+%
+%<*driver|package>
+% The version of expl3 required is tested as early as possible, as
+% some really old versions do not define \ProvidesExplPackage.
+\NeedsTeXFormat{LaTeX2e}[1995/12/01]
+\RequirePackage{expl3}[2016/01/19]
+%</driver|package>
+%<*driver>
+\documentclass[full]{l3doc}
+\usepackage{statistics}
+\usepackage{fontspec}
+\usepackage{xparse}
+\usepackage{xcolor}
+\usepackage{geometry}
+\geometry{
+ a4paper,
+ vmargin=2.5cm, right=1.5cm, textwidth=385pt,
+ marginparwidth=21cm-1.5cm-0.5cm-0.4cm-385pt,
+ %marginparsep=0.4cm,
+}
+%</driver>
+%<*driver|package>
+\def\ExplFileName{statistics}
+\def\ExplFileDescription{Compute and typeset statistics table and graphics}
+\def\ExplFileDate{2018/07/21}
+\def\ExplFileVersion{2.0}
+%</driver|package>
+%<*driver>
+\ExplSyntaxOn
+\let\tltostr\tl_to_str:N
+\NewDocumentEnvironment{demo}{}{
+ \char_set_catcode_other:N \\
+ \peek_meaning:NTF [ {
+ \__statsdocs_demo_begin:
+ }{
+ \__statsdocs_demo_begin: []
+ }
+}{
+ \mode_if_vertical:TF {
+ \penalty 0
+ }{
+ \par\nobreak
+ }
+ \skip_vertical:N \abovedisplayskip
+ \noindent\leavevmode
+ \hbox_set:Nn \l_tmpb_box {
+ \colorbox{yellow!5!white}{
+ \parbox{\linewidth}{
+ \raggedright
+ \tl_use:N \l_tmpb_tl
+ }
+ }
+ }
+ \hbox_set:Nn \l_tmpa_box {
+ \colorbox{blue!5!white}{
+ \parbox{\linewidth}{
+ \ttfamily
+ \raggedright
+ \tl_use:N \l_tmpa_tl
+ }
+ }
+ }
+ \fp_set:Nn \l_tmpa_fp {
+ round(
+ 3000 *
+ \dim_ratio:nn { \box_ht:N \l_tmpb_box } { \box_ht:N \l_tmpa_box }
+ )
+ }
+ \box_use:N \l_tmpa_box \\ \box_use:N \l_tmpb_box
+ \int_set:Nn \interlinepenalty {\fp_to_int:N \l_tmpa_fp}
+ \par
+ \penalty 0
+ \skip_vertical:N \belowdisplayskip
+}
+\cs_new_protected:Nn \__statsdocs_demo_begin: {
+ \char_set_catcode_escape:N \\
+ \__statsdocs_demo_begin:w
+}
+\NewDocumentCommand \__statsdocs_demo_begin:w { +O{} } {
+ \char_set_catcode_other:N \^^M
+ \char_set_catcode_other:n {32}
+ \char_set_catcode_other:N \#
+ \char_set_catcode_other:N \\
+ \char_set_catcode_other:N \{
+ \char_set_catcode_other:N \}
+ \__statsdocs_read_demo:w
+}
+\group_begin:
+\char_set_catcode_group_begin:N \[
+\char_set_catcode_group_end:N \]
+\char_set_catcode_escape:N \|
+\char_set_catcode_other:N \{
+\char_set_catcode_other:N \}
+\char_set_catcode_other:N \\
+|cs_new_protected:Npn |__statsdocs_read_demo:w #1 \end{demo}[
+ |__statsdocs_do_demo:n [#1]
+]
+|group_end:
+\cs_new_protected:Nn \__statsdocs_do_demo:n {
+ \str_set:Nn \l_tmpa_str {#1}
+ \tl_trim_spaces:N \l_tmpa_str
+ \str_set:Nx \l_tmpb_str {\char_generate:nn{`\^^M}{12}}
+ \str_if_eq_x:nnT \l_tmpb_str { \str_head:N \l_tmpa_str } {
+ \str_set:Nx \l_tmpa_str { \str_tail:N \l_tmpa_str }
+ }
+ \tl_reverse:N \l_tmpa_str
+ \str_if_eq_x:nnT \l_tmpb_str { \str_head:N \l_tmpa_str } {
+ \str_set:Nx \l_tmpa_str { \str_tail:N \l_tmpa_str }
+ }
+ \tl_reverse:N \l_tmpa_str
+ \tl_set:Nx \l_tmpa_tl {~\l_tmpa_str}
+ \exp_args:NNV \tl_replace_all:Nnn \l_tmpa_tl \l_tmpb_str {\par}
+ \tl_set:Nx \l_tmpb_tl {\char_generate:nn{32}{12}}
+ \exp_args:NNnV \tl_replace_all:Nnn \l_tmpa_tl {~} \l_tmpb_tl
+ \exp_args:NNnV \tl_set_rescan:Nnn \l_tmpb_tl {
+ \char_set_catcode_escape:N \\
+ \char_set_catcode_space:n {32}
+ \char_set_catcode_parameter:N \#
+ \char_set_catcode_end_line:N \^^M
+ \char_set_catcode_group_begin:N \{
+ \char_set_catcode_group_end:N \}
+ } \l_tmpa_str
+ \end{demo}
+}
+\ExplSyntaxOff
+\NewDocumentEnvironment{key}{}{\begin{variable}}{\end{variable}}
+\begin{document}
+ \DocInput{\jobname.dtx}
+\end{document}
+%</driver>
+% \fi
+%
+% \title{^^A
+% The \textsf{\ExplFileName} package\\ \ExplFileDescription^^A
+% \thanks{This file describes v\ExplFileVersion,
+% last revised \ExplFileDate.}^^A
+% }
+%
+% \author{^^A
+% Julien ``\_FrnchFrgg\_'' \textsc{Rivaud}\thanks
+% {^^A
+% E-mail:
+% \href{mailto:frnchfrgg@free.fr}
+% {frnchfrgg@free.fr}^^A
+% }^^A
+% }
+%
+% \date{Released \ExplFileDate}
+%
+% \maketitle
+%
+% \tableofcontents
+%
+% \begin{documentation}
+%
+% \section{\pkg{\ExplFileName} documentation}
+%
+% The \pkg{\ExplFileName} package can compute and typeset statistics like
+% frequency tables, cumulative distribution functions (increasing or decreasing,
+% in frequency or absolute count domain), from the counts of individual values,
+% or ranges, or even the raw value list with repetitions.
+%
+% It can also compute and draw a bar diagram in case of individual values, or,
+% when the data repartition is known from ranges, an histogram or the continuous
+% cumulative distribution function.
+%
+% You can ask \pkg{\ExplFileName} to display no result, selective results or all
+% of them. Similarly \pkg{\ExplFileName} can draw only some parts of the graphs.
+% Every part of the generated tables or graphics is customizable.
+%
+% \subsection{Specifying and converting data}
+%
+% To compute and typeset things, \pkg{\ExplFileName} starts from what this
+% documentation calls a \meta{data source}. Such a source can take two forms:
+% \begin{itemize}
+% \item A comma-separated list of \meta{value} |[=| \meta{count} |]|;
+% \item A \cs{\meta{macro}} containing such a list.
+% \end{itemize}
+%
+% If \meta{count} is missing, it defaults to~$1$. \emph{A priori} the
+% \meta{value}s need not be unique nor sorted, but \cs{StatsTable} and
+% \cs{StatsGraph} expect them to be. If you want your data to be in the form of
+% a raw list of unsorted and repeated values, you can thus use the following
+% command to convert the data to a form suitable for \cs{StatsTable} and
+% \cs{StatsGraph}:
+%
+% \begin{function}{\StatsSortData}
+% \begin{syntax}
+% \cs{StatsSortData} \cs{\meta{destination}} = \marg{data source}
+% \end{syntax}
+% This command expect each \meta{value} in the \meta{data source} to be
+% convertible to a floating point number (as understood by \pkg{l3fp} from the
+% \LaTeX3 kernel). It defines \cs{\meta{destination}} to hold an equivalent
+% data source, where \meta{value}s are sorted in increasing order, and
+% \meta{count}s are consolidated. As for all other \pkg{\ExplFileName}
+% commands, \meta{data source} can be either given directly between braces, or
+% as a \cs{\meta{macro}} which contains the list.
+% \end{function}
+%
+% \begin{demo}
+% \StatsSortData \mydata = { 2, 11=8, 6=3, 2=2, 11=1 }
+% \def \rawdata { 2=2, 11=9, 6, 2, 6, 6 }
+% \StatsSortData \yourdata = \rawdata
+% mydata contains [\mydata]\\
+% yourdata contains [\yourdata]
+% \end{demo}
+%
+% The \cs{StatsTable} command will always assume that the \meta{data source} is
+% sorted and will not try to parse the \meta{value}s. On the contrary,
+% \cs{StatsGraph} \emph{will} parse each \meta{value}, and will act differently
+% depending on whether every \meta{value} is a \meta{range} or the form
+% \hbox{\cs{IN} \meta{|[| or |]|} \meta{min} |;| \meta{max} \meta{|[| or |]|}},
+% or not.
+%
+% If your \meta{data source} is not given in ranges, but you want to count the
+% values falling in each \meta{range} of a list you can use:
+%
+% \begin{function}{\StatsRangeData}
+% \begin{syntax}
+%\cs{StatsSortData}\
+%\cs{\meta{destination}}\
+%=\
+%\marg{data source}\
+%(\meta{range list})
+% \end{syntax}
+% This command expect each \meta{value} in the \meta{data source} to be
+% convertible to a floating point number (as understood by \pkg{l3fp} from the
+% \LaTeX3 kernel). It also expects \meta{range list} to be a comma-separated
+% list of \meta{range}s, and will define \cs{\meta{destination}} to a
+% \meta{data source} whose \meta{value}s are the said \meta{range}s and whose
+% counts are, well\dots\ the number of floating point values that lie in those
+% \meta{range}s.
+%
+% \cs{StatsRangeData} does not need the \meta{range}s to be sorted, nor even
+% disjoint, but in that case the behavior of \cs{StatsGraph} is unspecified.
+% \end{function}
+%
+% Here is an example\footnote{The \cs{tltostr} command is defined in this
+% documentation to be an alias for the \LaTeX3 command \cs{tl_to_str:N} which is
+% equivalent to \cs{detokenize}\cs{expandafter}|\{|\cs{\meta{macro}}|\}|.}:
+% \begin{demo}
+% \StatsRangeData \facebook = { 0, 1, 1.5, 1.5, 2, 3, 2.4, 2, 2.4=5,
+% 3, 4=10, 5=6, 6=9, 6.5=5, 7, 7.1, 7.2,
+% 7.3, 7.4, 7.5, 7.6, 7.7, 7, 7, 8, 8, 8,
+% 9=5, 12=12}
+% (\IN[0;1;[, \IN[1;2;[, \IN[2;4;[,
+% \IN[4;7;[, \IN[7;10;[, \IN[10;14;[)
+% \tltostr \facebook
+% \end{demo}
+% \def \facebook {
+% \IN[0;1;[ = 1, \IN[1;2;[ = 3, \IN[2;4;[ = 10,
+% \IN[4;7;[ = 30, \IN[7;10;[ = 18, \IN[10;14;[ = 12
+% }
+%
+% This data source will be used throughout the documentation.
+% \label{def:datasource}
+%
+% \subsection{Setting options}
+%
+% \begin{function}{\statisticssetup}
+% \begin{syntax}
+% \cs{statisticssetup} \oarg{module} \marg{options}
+% \end{syntax}
+% This command lets you specify options for several tables or graphs. The
+% options are set locally to the current group. Options for tables are in the
+% |table| \meta{module} and are the same as in the optional arguments of
+% \cs{StatsTable}. Options for grapsh are in the |graph| \meta{module} and are
+% the same as in the optional arguments of \cs{StatsGraph}. You can also use
+% \cs{statisticssetup} without a \meta{module} and prefix all keys by the module
+% name and a forward slash.
+% % \end{function}
+%
+% \begin{demo}
+% \statisticssetup{table/values=My values}
+% \statisticssetup[table]{counts=FooBar}
+% \StatsTable \facebook
+% \end{demo}
+%
+% \subsection{Statistics tables}
+%
+% \subsubsection{\cs{StatsTable} invocation}
+%
+% To typeset a table full of statistics values, you use the command:
+%
+% \begin{function}{\StatsTable}
+% \begin{syntax}
+% \cs{StatsTable} \oarg{options_1} \marg{data source} \oarg{options_2}
+% \end{syntax}
+% \meta{options_1} and \meta{options_2} are both optional and taken into
+% account. You will probably not use both at the same time even if
+% \cs{StatsTable} will accept it (and apply \meta{options_2} after
+% \meta{options_1}, potentially overriding some settings). The idea is to let
+% you decide where you feel the options should be. I find more logical to
+% specify options after a \cs{macro} data source, but before an inline
+% \marg{data source}. Your mileage may vary.
+% \end{function}
+%
+% If you do not use any option, you only get the line of values\footnote{The
+% \cs{facebook} data source is defined on page \pageref{def:datasource}.}:
+% \begin{demo}
+% \StatsTable \facebook
+% \end{demo}
+%
+% OK, this is ugly. Let us add some reasonable amount of space (a better choice
+% would be to use the \pkg{cellprops} package to control the spacing and a lot
+% more):
+% \begin{demo}
+% \setlength\extrarowheight{1.5pt}
+% \StatsTable \facebook
+% \end{demo}
+% \setlength\extrarowheight{1.5pt}
+%
+% \subsubsection{Choosing and naming rows}
+%
+% Let's add some rows to the table:
+%
+% \begin{key}{values, counts, frequencies, icc, icf, dcc, dcf}
+% \begin{syntax}
+% values $[$ = \meta{row header text} $]$
+% counts $[$ = \meta{row header text} $]$
+% frequencies $[$ = \meta{row header text} $]$
+% icc $[$ = \meta{row header text} $]$
+% icf $[$ = \meta{row header text} $]$
+% dcc $[$ = \meta{row header text} $]$
+% dcf $[$ = \meta{row header text} $]$
+% \end{syntax}
+% These keys add the corresponding rows to the table. |icc| means increasing
+% cumulative counts, |icf| is the same with frequencies, |dcc| is the row of
+% decreasing cumulative counts and |dcf| for frequencies. If you omit
+% \meta{row header text} the key only activates the corresponding row; if you
+% additionally use a value then the first cell of the row will use that value as
+% text.
+%
+% The initial header is |\valuename| for values, |\countname| for counts,
+% |\freqname| for frequencies, |\iccname| for icc, |\icfname| for icf,
+% |\dccname| for dcc and |\dcfname| for dcf.
+% \end{key}
+%
+% \begin{demo}
+% \StatsTable \facebook[
+% values=Time in \si{h},
+% counts, frequencies, icc, dcc, icf, dcf
+% ]
+% \end{demo}
+%
+% \begin{key}{novalues, nocounts, nofrequencies,
+% noicc, nodcc, noicf, nodcf}
+% \begin{syntax}
+% novalues, nocounts, nofrequencies, noicc, nodcc, noicf, nodcf
+% \end{syntax}
+% If you want to \emph{disable} a row you can use the \texttt{no\meta{row}}~key.
+% This is particularly useful for the |values| row, but you might need these
+% keys to disable a row that you previously enabled with \cs{statisticssetup}.
+%
+% \begin{demo}
+% \StatsTable \facebook [novalues, counts, icc]
+% \end{demo}
+% \end{key}
+%
+% \begin{key}{values/header, counts/header, frequencies/header,
+% icc/header, icf/header, dcc/header, dcf/header}
+% \begin{syntax}
+% values/header = \meta{row header text}
+% counts/header = \meta{row header text}
+% frequencies/header = \meta{row header text}
+% icc/header = \meta{row header text}
+% icf/header = \meta{row header text}
+% dcc/header = \meta{row header text}
+% dcf/header = \meta{row header text}
+% \end{syntax}
+% These keys set the corresponding row header text, which will be used as the
+% first cell of the row if the row is enabled. These keys does not enable their
+% row by themselves, contrary to keys like |values| or |counts|.
+%
+% The initial header is |\valuename| for values, |\countname| for counts,
+% |\freqname| for frequencies, |\iccname| for icc, |\icfname| for icf,
+% |\dccname| for dcc and |\dcfname| for dcf.
+% \end{key}
+%
+% \begin{demo}
+% \statisticssetup{table/counts/header=People count}
+% \StatsTable \facebook[counts, frequencies, icc]
+% \end{demo}
+%
+% \subsubsection{Formatting cells}
+%
+% \begin{key}[label={table/values/format, table/counts/format,
+% table/frequencies/format, table/icc/format, table/icf/format,
+% table/dcc/format, table/dcf/format}]
+% {values/format, counts/format, frequencies/format,
+% icc/format, icf/format, dcc/format, dcf/format}
+% \begin{syntax}
+% values/format = \meta{formatting code}
+% counts/format = \meta{formatting code}
+% frequencies/format = \meta{formatting code}
+% icc/format = \meta{formatting code}
+% icf/format = \meta{formatting code}
+% dcc/format = \meta{formatting code}
+% dcf/format = \meta{formatting code}
+% \end{syntax}
+% Each key in this list takes a value which will be used for each cell in the
+% corresponding row. In this value, every occurrence of |#1| will be replaced by
+% the content of the cell, which can be further configured by the
+% |allcounts/format| key (for the rows |counts|, |icc| and~|dcc|) or the
+% |allfreqs/format| key (for the rows |frequencies|, |icf| and~|dcf|). The idea
+% is that the latter keys are intended for number formatting (decimal count,
+% decimal separator, etc.) while the \texttt{\meta{row}/format} keys are
+% intended for font/color changes. In this key, \cs{currentcolumn} expands to
+% the data column number, starting from~$1$, to enable different formatting
+% depending on the column. These keys are all initially equal to |#1| which means
+% they pass-through the content unmodified.
+% \end{key}
+%
+% \begin{demo}
+% \StatsTable \facebook[
+% counts, icc,
+% icc/format = \colorbox{blue!\currentcolumn 0!white}{#1}
+% ]
+% \end{demo}
+%
+% \begin{key}{allcounts/format}
+% \begin{syntax}
+% allcounts/format = \meta{formatting code}
+% \end{syntax}
+% This key take some formatting code, in which every occurrence of |#1| will be
+% replaced by the integer count\footnotemark in each cell of every row
+% containing counts. The initial value is |\num{#1}|, using the \pkg{siunitx}
+% package.
+%
+% The result of this formatting code will then be passed to |counts/format|,
+% |icc/format| or |dcc/format| depending on the row, for further parsing and
+% formatting.
+% \end{key}
+% \footnotetext{As returned by \cs{fp_use:N} or \cs{fp_eval:n}.}
+%
+% \begin{demo}
+% \StatsTable \facebook[
+% counts, icc,
+% icc/format = \colorbox{blue!\currentcolumn 0!white}{#1},
+% allcounts/format = {\num[round-integer-to-decimal,
+% round-mode=figures]{#1}}
+% ]
+% \end{demo}
+%
+% \begin{key}{allfreqs/format}
+% \begin{syntax}
+% allfreqs/format = \meta{formatting code}
+% \end{syntax}
+% This key take some formatting code, in which every occurrence of |#1| will be
+% replaced by the current frequency\footnotemark in each cell of every row
+% containing frequencies. The initial value is |\num{#1}|, using the
+% \pkg{siunitx} package.
+%
+% The result of this formatting code will then be passed to |freqs/format|,
+% |icf/format| or |dcf/format| depending on the row, for further parsing and
+% formatting.
+%
+% The initial value is set by the |allfreqs/format/percent| key and typesets
+% values in percentage (that is, multiplied by~$100$ with a trailing~$\%$).
+% \end{key}
+% \footnotetext{As returned by \cs{fp_use:N} or \cs{fp_eval:n}.}
+%
+% \begin{demo}
+% \StatsTable \facebook[
+% icc, frequencies, icf,
+% allfreqs/format = {\num[round-mode=places,
+% round-integer-to-decimal,
+% round-precision=3]{#1}}
+% ]
+% \end{demo}
+% Note that if you use |allfreqs/format| to round the frequencies to an
+% acceptable precision, your frequencies might not add up to~$1$ anymore, and
+% summing the frequencies up to some value might not give the same result as
+% computing the cumulative frequency from the cumulative count. If you
+% want to avoid that, consider using the |digits| key of the |table| module,
+% which rounds the cumulative frequencies \emph{then} computes the individual
+% frequencies as differences of consecutive cumulative ones. This essentially
+% spreads the rounding errors so that they cancel each other, with a result not
+% unlike that of the \textsc{Bresenham} algorithm.
+%
+% \begin{key}{allfreqs/format/percent}
+% \begin{syntax}
+% allfreqs/format/percent
+% \end{syntax}
+% This key sets up |allfreqs/format| to display the frequencies as percentages,
+% that is, multiplied by~$100$ with a trailing~$\%$. This is the initial
+% setting.
+%
+% \begin{texnote}
+% This key is a shorthand for\\
+% |allfreqs/format = \SI{\fp_eval:n{#1*100}}{\percent}|.
+% \end{texnote}
+% \end{key}
+%
+% \begin{demo}
+% \StatsTable \facebook[ frequencies, icf, allfreqs/format/percent ]
+% \end{demo}
+%
+% \begin{key}{allfreqs/format/real}
+% \begin{syntax}
+% allfreqs/format/real
+% \end{syntax}
+% This key sets up |allfreqs/format| to |\num{#1}| which displays the
+% frequencies as straight real numbers.
+% \end{key}
+%
+% \begin{demo}
+% \StatsTable \facebook[ frequencies, icf, allfreqs/format/real ]
+% \end{demo}
+%
+% \begin{key}{digits}
+% \begin{syntax}
+% digits = \meta{integer}
+% \end{syntax}
+% This key sets the number of digits after the decimal point to use for rounding
+% cumulative frequencies. Point-wise frequencies are computed from these rounded
+% cumulative frequencies to ensure consistency with the cumulative counts, and
+% ensure the sum of frequencies equals~$1$. This essentially
+% spreads the rounding errors so that they cancel each other, with a result not
+% unlike that of the \textsc{Bresenham} algorithm.
+%
+% The rounding takes place before any formatting by |allfreqs/format| or
+% individual \texttt{\meta{row}/format}. The initial value is~$3$ (which means
+% one digit after the decimal separator in percentage).
+% \end{key}
+%
+% \begin{demo}
+% \StatsTable \facebook[ frequencies, icf, digits=2 ]
+% \end{demo}
+%
+% \subsubsection{Hiding and showing column contents}
+%
+% In addition to \texttt{\meta{row}/format}, |allcounts/format| and
+% |allfreqs/format| which can all use \cs{currentcolumn} to apply different
+% formatting to different columns, you can also use the following keys:
+%
+% \begin{key}[label=table/showonly]{showonly, showonly/hidden, showonly/shown}
+% \begin{syntax}
+% showonly = \meta{integer and integer range list}
+% showonly/hidden = \meta{formatting code}
+% showonly/shown = \meta{formatting code}
+% \end{syntax}
+% The |showonly| key enables you to choose which columns you want \emph{shown}
+% --- and thus which ones you want to have their contents hidden. It takes a
+% comma-separated list of single numbers or \texttt{\meta{start}-\meta{end}}
+% ranges of numbers. An empty value means \emph{show everything}, and this is
+% the initial value. To hide all contents, you can set |showonly| to a
+% non-existent column number like~$0$.
+%
+% Every column whose number is in the |showonly| list (of ranges) is deemed
+% \emph{shown}, which means all cells will be ultimately wrapped in the
+% |showonly/shown| formatting code, where as usual |#1|~is replaced by the
+% contents. That key initially just passes through the contents as-is.
+%
+% Every column whose number is \emph{not} in the list is \emph{hidden},
+% \emph{i.e.} its cell contents are wrapped in the |showonly/hidden| formatting
+% code. This key is initially empty which means the contents are ignored and the
+% cell stays empty --- which means its width will collapse and only the column
+% separation will remain. You can decide to still typeset the contents in white,
+% or even put them in a PDF~``OCG layer'' with the \pkg{ocgx2} package for
+% instance.
+% \end{key}
+%
+% \begin{demo}
+% \StatsTable \facebook[ counts, frequencies, showonly={2,4-6} ]
+% \StatsTable \facebook[ counts, frequencies, showonly={2,4-6},
+% showonly/hidden = \color{white}#1 ]
+% \end{demo}
+%
+% \subsubsection{Formatting the table}
+%
+% \begin{key}{maxcols}
+% \begin{syntax}
+% maxcols = \meta{integer}
+% \end{syntax}
+% Setting this key to a positive integer~$n$ makes \cs{StatsTable} wrap after
+% having added $n$~columns to the current table. The table is closed, and a new
+% one is created with the row headers typeset anew. Setting this key to a
+% negative number or zero disables wrapping. The initial value is~$0$.
+% \end{key}
+%
+% \begin{key}{tablesep}
+% \begin{syntax}
+% tablesep = \meta{\TeX\ content}
+% \end{syntax}
+% This key holds some \TeX\ content that will be inserted after each table when
+% wrapping. It should probably contain something that creates a line return
+% (either |\\| or |\par|), but can contain arbitrary code.
+% The initial value is |\\|.
+% \end{key}
+%
+% \begin{demo}
+% \StatsTable \facebook[ counts, maxcols=4,
+% tablesep=\par{\color{red}\hrule} ]
+% \end{demo}
+%
+% \begin{key}{preline}
+% \begin{syntax}
+% preline = \meta{array content}
+% \end{syntax}
+% This key holds some \TeX\ content that will be inserted first in the
+% \env{array} environment, before any row content. It should probably be some
+% kind of \cs{noalign} material, like a \cs{hline} or similar constructs.
+% The initial value is \cs{firsthline}, with a fallback to \cs{hline} if the
+% former doesn't exist.
+% \end{key}
+%
+% \begin{key}{postline}
+% \begin{syntax}
+% postline = \meta{array content}
+% \end{syntax}
+% This key holds some \TeX\ content that will be inserted last in the
+% \env{array} environment, after any row content. It should probably be some
+% kind of \cs{noalign} material, like a \cs{hline} or similar constructs.
+% The initial value is \cs{lasthline}, with a fallback to \cs{hline} if the
+% former doesn't exist.
+% \end{key}
+%
+% \begin{key}{outline}
+% \begin{syntax}
+% outline = \meta{array content}
+% \end{syntax}
+% This key sets both |preline| and |postline| to the same value.
+% \end{key}
+%
+% \begin{key}{newline}
+% \begin{syntax}
+% newline = \meta{array content}
+% \end{syntax}
+% This key holds some \TeX\ content that will be inserted at the end of each
+% row, to separate it from the next. \emph{It should contain some kind of
+% \cs{cr}}, probably in the form of |\\|, but can also contain \cs{hline}s after
+% the |\\|. The initial value is |\\| which creates tables without lines
+% separating rows (as \pkg{booktabs} would recommend).
+% \end{key}
+%
+% \begin{demo}
+% \setlength\extrarowheight{1ex}
+% \StatsTable \facebook[ counts, preline=\hline\hline,
+% postline=\hline\hline\hline,
+% newline=\\[1ex]\hline ]
+% \end{demo}
+%
+% \begin{key}{coltype}
+% \begin{syntax}
+% coltype = \meta{preamble elements}
+% \end{syntax}
+% This key sets the part of the array preamble that will be repeated for each
+% content column in the table. It can contain any preamble content, like "|" for
+% vertical lines, but should only countain a single column specifier.
+% The initial value is "c".
+% \end{key}
+%
+% \begin{key}{headcoltype}
+% \begin{syntax}
+% headcoltype = \meta{preamble elements}
+% \end{syntax}
+% This key sets the part of the array preamble that will be used for the first
+% column in the table, which contains the headers. It can contain any preamble
+% content, like "|" for vertical lines, but should only countain a single column
+% specifier. The initial value is "l".
+% \end{key}
+%
+% \begin{demo}
+% \StatsTable \facebook[ counts, coltype=@{}c, headcoltype=r ]
+% \end{demo}
+%
+% Note: these keys are here for convenience, but if you find yourself trying to
+% do very clever things in them, you should consider using the \pkg{cellprops}
+% package which is able to do much more complex border and background layouts
+% with ease. In particular they probably shouldn't be used to workaround the
+% very poor spacing of \env{array}: there are better solutions.
+%
+% Several classic uses of these keys can be replaced by the following key:
+% \begin{key}{frame}
+% \begin{syntax}
+% frame = none $\vert$ clean $\vert$ full
+% \end{syntax}
+% The |frame| key selects a preset for |preline|, |postline|, |headcoltype| and
+% |coltype|. The possible presets are:
+% \begin{itemize}
+% \item |none|: clears |preline| and |postline|, sets |headcoltype = l| and
+% |coltype = c|. This removes all lines in the table and is useful if you
+% use other means like \pkg{cellprops} to style the table.
+% \item |clean|: sets |preline = \firsthline|, |postline = \lasthline|,
+% |headcoltype = l| and |coltype = c|. This corresponds to the initial
+% setting, and yields a layout similar to \pkg{booktabs} recommendations,
+% especially if you set \cs{firsthline} and \cs{lasthline} to be a little
+% thicker.
+% \item |full|: sets |preline = \firsthline|, |postline = \lasthline|,
+% "headcoltype = |l|" and "coltype = c|". This separates all cells
+% with rules.
+% \end{itemize}
+% \end{key}
+%
+% \begin{demo}
+% \statisticssetup{table/showonly/hidden=\color{white}#1}
+% \StatsTable \facebook[ counts, frequencies, frame=none ]
+% \StatsTable \facebook[ counts, frequencies, frame=full, showonly=2-4 ]
+% \end{demo}
+%
+% \begin{key}{valign}
+% \begin{syntax}
+% valign = t $\vert$ c $\vert$ b
+% \end{syntax}
+% The value of this key is used for the optional argument of the \env{array}
+% environment. This enables to align either the baseline of the first line, that
+% of the last line, or the vertical center of the table with the surrounding
+% baseline. The initial value is |t|.
+% \end{key}
+%
+%
+% \subsection{Statistics graphs}
+%
+% \subsubsection{\cs{StatsGraph} invocation}
+%
+% To typeset a graphic from the statistics values, you use the command:
+% \begin{function}{\StatsGraph}
+% \begin{syntax}
+% \cs{StatsGraph} \oarg{options_1} \marg{data source} \oarg{options_2}
+% \end{syntax}
+% \meta{options_1} and \meta{options_2} are both optional and taken into
+% account. You will probably not use both at the same time even if
+% \cs{StatsGraph} will accept it (and apply \meta{options_2} after
+% \meta{options_1}, potentially overriding some settings). The idea is to let
+% you decide where you feel the options should be. I find more logical to
+% specify options after a \cs{macro} data source, but before an inline
+% \marg{data source}. Your mileage may vary.
+% \end{function}
+%
+% \begin{demo}
+% \StatsGraph \facebook
+% \end{demo}
+%
+% \cs{StatsGraph} will draw a different kind of graph depending on the
+% \meta{data source} itself, and the |cumulative| option key. A summary is
+% shown in the table below:
+% \begin{center}
+% \setlength\extrarowheight{1ex}
+% \begin{tabular}{ccc}
+% \firsthline
+% values are ranges & without |cumulative| & with |cumulative| \\[0.8ex]
+% \hline
+% no & bar diagram\footnotemark & \emph{not implemented yet} \\[1ex]
+% yes & histogram &
+% \parbox[c]{10em}{\centering cumulative distribution function} \\[2ex]
+% \lasthline
+% \end{tabular}
+% \footnotetext{In this documentation this is called a \emph{comb graph}.}
+% \end{center}
+%
+% \begin{demo}
+% \def \combdata { 36=3, 37=8, 38=2, 39=6, 40=6, 41=3, 42=2, 45=2, 46=2 }
+% \StatsGraph \combdata
+% \end{demo}
+% \def \combdata { 36=3, 37=8, 38=2, 39=6, 40=6, 41=3, 42=2, 45=2, 46=2 }
+%
+% \begin{demo}
+% \StatsGraph \facebook [cumulative]
+% \end{demo}
+%
+% \subsubsection{TikZ picture and datavisualization settings}
+%
+% \begin{key}{picture, picture/reset}
+% \begin{syntax}
+% picture = \meta{TikZ key options}
+% picture/reset
+% \end{syntax}
+% The |picture| key \emph{appends} content to the optional argument of the
+% \env{tikzpicture} environment. It can contain any list of TikZ keys. The
+% |picture/reset| key clears all content accumulated by the |picture| key,
+% including the initial value.
+%
+% The initial value is:\\
+% |baseline = (current bounding box.center), label position = right|.
+% \end{key}
+%
+% \begin{key}{axissystem, axissystem/reset}
+% \begin{syntax}
+% axissystem = \meta{TikZ cartesian axis system options}
+% axissystem/reset
+% \end{syntax}
+% The |axissystem| key adds keys to the list of options passed to the
+% |scientific axes| datavisualization key, The |axissystem/reset| key clears all
+% content accumulated by the |axissystem| key, including the initial value,
+% which is set by the initial value of the |width| key.
+% \end{key}
+%
+% \begin{demo}
+% \StatsGraph \combdata [axissystem={end labels, clean}]
+% \end{demo}
+%
+% Two small helper keys are provided for a very common usage of |axissystem|:
+%
+% \begin{key}{width}
+% \begin{syntax}
+% width = \meta{\TeX\ dimension expression}
+% \end{syntax}
+% This key sets the width of the graphic to the given \meta{\TeX\ dimension
+% expression}, labels and padding excluded. The expression is evaluated at graph
+% creation time. The initial value is |0.75\columnwidth|.
+% \begin{texnote}
+% This key is a shortcut for |axissystem = { width = |\meta{dimension}| }|
+% \end{texnote}
+% \end{key}
+%
+% \begin{key}{height}
+% \begin{syntax}
+% height = \meta{\TeX\ dimension expression}
+% \end{syntax}
+% This key sets the width of the graphic to the given \meta{\TeX\ dimension
+% expression}, labels and padding excluded. The expression is evaluated at graph
+% creation time. Initially this is \emph{unset}, which means the default of
+% the cartesian axis system will be used, that is the choosen width divided by
+% the golden ratio $\varphi = \frac{1+\sqrt{5}}{2}$.
+% \begin{texnote}
+% This key is a shortcut for |axissystem = { height = |\meta{dimension}| }|
+% \end{texnote}
+% \end{key}
+%
+% To have more precise control over the scale of the graph, you can use the
+% individual axis options provided by \pkg{\ExplFileName} to set an explicit
+% scaling with TikZ DataVisualization keys like |unit length|. See the PGF/TikZ
+% manual for more information.
+%
+% \begin{demo}
+% \statisticssetup[graph]{ width = 0.25\columnwidth, height=4cm }
+% \centering
+% \StatsGraph \facebook
+% \StatsGraph \facebook [cumulative]
+% \StatsGraph \combdata
+% \end{demo}
+%
+% \begin{key}{tikzinfo', tikzinfo'/reset}
+% \begin{syntax}
+% tikzinfo' = \meta{TikZ picture code}
+% tikzinfo'/reset
+% \end{syntax}
+% This key \emph{appends} content to be added in the |info'| section of the
+% |\datavisualization| command. It can contain any TikZ code, and can use the
+% |visualization cs| coordinate system. The result of this TikZ code is drawn
+% \emph{before} the data itself and will end up behind unless you play with TikZ
+% layers. Some information might be unavailable or wrong since the data has not
+% been drawn yet.
+%
+% The |tikzinfo'/reset| key clears all content accumulated by the |tikzinfo'|
+% key. The initial value is empty.
+% \end{key}
+%
+% \begin{key}{tikzinfo, tikzinfo/reset}
+% \begin{syntax}
+% tikzinfo = \meta{TikZ picture code}
+% tikzinfo/reset
+% \end{syntax}
+% This key \emph{appends} content to be added in the |info| section of the
+% |\datavisualization| command. It can contain any TikZ code, and can use the
+% |visualization cs| coordinate system. The result of this TikZ code is drawn
+% \emph{after} the data itself and will end up in front of it unless you play
+% with TikZ layers.
+%
+% The |tikzinfo/reset| key clears all content accumulated by the |tikzinfo|
+% key. The initial value is empty.
+% \end{key}
+%
+% \begin{demo}
+% \StatsGraph \facebook [
+% cumulative,
+% tikzinfo = {
+% \path (data bounding box.south west) coordinate (O);
+% \path (visualization cs:x=8, y=50) coordinate (A);
+% \draw[red] (O |- A) -- (A) -- (A |- O);
+% }
+% ]
+% \end{demo}
+%
+% \subsubsection{Selecting which parts of the graph are shown}
+%
+% By default, the complete graph is shown; you can ask \cs{StatsGraph} to only
+% show the parts corresponding to some of the input data:
+%
+% \begin{key}[label=graph/showonly]{showonly}
+% \begin{syntax}
+% showonly = \meta{integer and integer range list}
+% \end{syntax}
+% The |showonly| key enables you to set which parts of the graph you want
+% \emph{shown}. It takes a comma-separated list of single numbers or
+% \texttt{\meta{start}-\meta{end}} ranges of numbers. An empty value means
+% \emph{show everything}, and this is the initial value. To hide all contents,
+% you can set |showonly| to a non-existent part number like~$-1$.
+% \end{key}
+%
+% \medskip
+% For comb graphs, the $n$-th part is the vertical bar corresponding to the
+% $n$-th value in the data source. For histograms, this is the rectangle
+% corresponding to the $n$-th range.
+%
+% For cumulative distribution functions of data sources with ranges, this is the
+% direct image of the $n$-th range by the function. The horizontal segment
+% between $-\infty$ and the lower bound of the first range is assigned
+% number~$0$, and the part right of the last range is selected by number~$N+1$
+% where $N$~is the total number of ranges.
+%
+% Currently, the drawing of hidden parts is inhibited altogether, but in the
+% future it is planned to have them drawn with another visualizer and a separate
+% style.
+%
+% \begin{demo}
+% \statisticssetup{ graph/width=0.45\columnwidth }
+% \StatsGraph \facebook [ showonly={2,4-6} ]
+% \StatsGraph \facebook [ cumulative, showonly={1,3-5,7} ]
+% \end{demo}
+%
+% \subsubsection{Unit selection and vertical axis settings}
+%
+% \begin{key}[label={graph/counts, graph/frequencies}]{counts, frequencies}
+% \begin{syntax}
+% counts $[$ = \meta{label} $]$
+% frequencies $[$ = \meta{label} $]$
+% \end{syntax}
+% These keys select the corresponding unit to use for the vertical axis of comb
+% graphs and cumulative distribution graphs, and for the area display of
+% histograms. Additionnally, if a \meta{label} is provided, it is passed to the
+% |counts/label| or the |frequencies/label| key.
+%
+% The initially selected unit is |counts|.
+% \end{key}
+%
+% \begin{key}{comb/counts, comb/frequencies,
+% histogram/counts, histogram/frequencies,
+% cumulative/counts, cumulative/frequencies}
+% \begin{syntax}
+% \meta{graph type}/counts $[$ = \meta{label} $]$
+% \meta{graph type}/frequencies $[$ = \meta{label} $]$
+% \end{syntax}
+% These keys select the unit to use for specific types of graphs separately.
+% They can be used in the inline options of \cs{StatsGraph} too, but they
+% probably only make sense in \cs{statisticssetup} to define different defaults
+% for different graph types.
+% \begin{texnote}
+% The |counts| key is actually a meta-key for\\
+% |comb/counts, histogram/counts, cumulative/counts|, which applies the same
+% value (or no value at all) to all three type-specific keys. The |frequencies|
+% key is similar.
+% \end{texnote}
+% \end{key}
+%
+% \begin{demo}
+% \statisticssetup[graph]{
+% width=0.4\columnwidth,
+% frequencies=Hello world, comb/counts=Students
+% }
+% \StatsGraph \facebook \hfill \StatsGraph \combdata \\
+% \StatsGraph \facebook [cumulative] \hfill \StatsGraph \facebook[counts]
+% \end{demo}
+%
+% Note that setting a label for the vertical axis of histogram does not make
+% much sense, even if your decision will be respected.
+%
+% \begin{key}{counts/label, frequencies/label,
+% comb/counts/label, comb/frequencies/label,
+% histogram/counts/label, histogram/frequencies/label,
+% cumulative/counts/label, cumulative/frequencies/label}
+% \begin{syntax}
+% \meta{unit}/label = \meta{label}
+% \meta{graph type}/\meta{unit}/label = \meta{label}
+% \end{syntax}
+% These keys set the label to use for the $y$~axis of the graph when the
+% corresponding unit is selected, \emph{without} selecting it at that point.
+% This is useful to provide your own defaults through \cs{statisticssetup}.
+%
+% The keys |counts/label| and |frequencies/label| set the label for all three
+% graph types, while the others are here to set individual defaults.
+% \end{key}
+%
+% Initial values are as follows:
+% \begin{itemize}
+% \item |comb/counts/label = \countname|
+% \item |comb/frequencies/label = \freqname|
+% \item |cumulative/counts/label = \ccountname|
+% \item |cumulative/frequencies/label = \cfreqname|
+% \item |histogram/counts/label| and |histogram/frequencies/label| are unset
+% \end{itemize}
+%
+% \begin{texnote}
+% The \texttt{\meta{type}/\meta{unit}/label} key is a shorthand for
+% \texttt{\meta{type}/\meta{unit}/axis} | = { label = |\meta{label}| }|, which
+% means that using \texttt{\meta{type}/\meta{unit}/axis/reset} will also remove
+% any defined label.
+% \end{texnote}
+% \begin{texnote}
+% As before, \texttt{\meta{unit}/label = \meta{label}} is equivalent to\par
+% \begingroup\obeylines\ttfamily
+% comb/\meta{unit}/label = \meta{label},
+% histogram/\meta{unit}/label = \meta{label},
+% cumulative/\meta{unit}/label = \meta{label}
+% \endgroup
+% \end{texnote}
+%
+% \begin{key}{y/label, comb/y/label, histogram/y/label, cumulative/y/label}
+% \begin{syntax}
+% y/label = \meta{label}
+% \meta{graph type}/y/label = \meta{label}
+% \end{syntax}
+% These keys set the label to use for the $y$~axis of the graph for both units
+% at the same time. |y/label| sets the label for all graph types and all units
+% simultaneously, while \texttt{\meta{graph type}/y/label} can be used for
+% individual graph types.
+% \end{key}
+%
+% This can be useful to set the label in inline options without having to
+% explicitely type the graph type or the selected unit:
+%
+% \begin{demo}
+% \statisticssetup[graph]{
+% width=0.38\columnwidth,
+% comb/frequencies, cumulative/counts,
+% }
+% \StatsGraph \combdata [ y/label=Students ]
+% \StatsGraph \facebook [ cumulative, y/label=Respondents ]
+% \end{demo}
+%
+% \begin{key}{counts/axis, frequencies/axis,
+% comb/counts/axis, comb/frequencies/axis,
+% histogram/counts/axis, histogram/frequencies/axis,
+% cumulative/counts/axis, cumulative/frequencies/axis,
+% counts/axis/reset, frequencies/axis/reset,
+% comb/.../axis/reset,
+% histogram/.../axis/reset,
+% cumulative/.../axis/reset}
+% \begin{syntax}
+% \meta{unit}/axis = \meta{TikZ datavisualization axis options}
+% \meta{unit}/axis/reset
+% \meta{graph type}/\meta{unit}/axis =\
+%\meta{TikZ datavisualization axis options}
+% \meta{graph type}/\meta{unit}/axis/reset
+% \end{syntax}
+% The \texttt{\meta{unit}/axis} keys append options to the TikZ $y$~axis when
+% the corresponding unit is selected. You can clear these options with
+% \texttt{\meta{unit}/axis/reset}. The \texttt{\meta{graph
+% type}/\meta{unit}/axis} and \texttt{\meta{graph type}/\meta{unit}/axis/reset}
+% keys do the same, but only for a specific graph type.
+%
+% Initial values are as follows:
+% \begin{itemize}
+% \item |comb/counts/axis| and |cumulative/counts/axis| are equal to\\
+% |ticks and grid={many, int about strategy, integer minor steps},|\\
+% |label=|\meta{initial value of the label key}
+% \item |cumulative/counts/axis| and |cumulative/frequencies/axis| are
+% equal to\\
+% |ticks and grid=many, label=|\meta{initial value of the label key}
+% \item |histogram/counts/axis| and |histogram/frequencies/axis| are equal to\\
+% |ticks=none, grid=|\meta{code to auto-compute the step} (see the
+% |histogram/autostep| key below).
+% \end{itemize}
+% \end{key}
+%
+% \begin{key}{y/axis, y/axis/reset,
+% comb/axis, comb/axis/reset,
+% histogram/axis, histogram/axis/reset,
+% cumulative/axis, cumulative/axis/reset}
+% \begin{syntax}
+% y/axis = \meta{TikZ datavisualization axis options}
+% y/axis/reset
+% \meta{graph type}/y/axis = \meta{TikZ datavisualization axis options}
+% \meta{graph type}/y/axis/reset
+% \end{syntax}
+% The \texttt{y/axis} keys append options to the TikZ $y$~axis for all possible
+% units and all graph types at the same time. The \texttt{y/axis/reset} key
+% clears these options for all units and all types simultaneously.
+%
+% The \texttt{\meta{graph type}/y/axis} and \texttt{\meta{graph
+% type}/y/axis/reset} keys do the same, but only for a specific graph type.
+% \end{key}
+%
+% \begin{demo}
+% \statisticssetup[graph]{
+% width=0.4\columnwidth,
+% comb/frequencies/axis = { ticks={step=0.08} },
+% histogram/y/axis = { grid = none },
+% }
+% \StatsGraph \combdata [ frequencies, y/axis = {
+% ticks={style=blue}, unit length=4cm per 0.25 units,
+% } ]
+% \hfill \StatsGraph \facebook
+% \end{demo}
+%
+% \begin{key}{/tikz/datavisualization/integer minor steps}
+% \begin{syntax}
+% integer minor steps $[$ = \meta{integer expression} $]$
+% \end{syntax}
+% This is not a key in the |graph| module, but a TikZ key. It adds code to
+% automatically compute |minor steps between steps| after the axis step has been
+% computed with the choosen strategy, so that the following constraints are
+% respected:
+% \begin{itemize}
+% \item a minor step corresponds to an integer number;
+% \item at most \meta{integer expression} ticks are present on the axis (minor
+% and major included, subminor not counted).
+% \end{itemize}
+% \end{key}
+%
+% If ommited, the \meta{integer expression} defaults to~$50$.
+%
+% This TikZ key should not explode if the computed step is not an integer, but
+% will probably not give a useful result, and in particular whether the minor
+% step will be integer is not defined in that case.
+%
+% \begin{texnote}
+% The key is independent of \pkg{statistics} and could be reused elsewhere.
+% \end{texnote}
+%
+% \begin{key}{counts/format, frequencies/format, y/format,
+% comb/counts/format, comb/frequencies/format, comb/y/format,
+% histogram/counts/format, histogram/frequencies/format,
+% histogram/y/format,
+% cumulative/counts/format, cumulative/frequencies/format,
+% cumulative/y/format}
+% \begin{syntax}
+% \meta{unit}/format = \meta{formatting code}
+% \meta{graph type}/\meta{unit}/format = \meta{formatting code}
+% \end{syntax}
+% These keys set the format to use for all counts or frequenties that are
+% typeset on the graphs. This includes the ticks on axes, and areas above
+% histogram rectangles. The value should be \TeX\ code to render the actual
+% number, in which all occurrences of |#1| are replaced by the number to
+% typeset.
+%
+% Keys of the form |\meta{graph type}/\meta{unit}/format| are used to set the
+% formatter of numbers in a specific unit when used in a specific graph. Keys of
+% the form |\meta{unit}/format| set the formatter for all graph types at the
+% same time, which is often desirable since it is rare that a frequency needs to
+% be typeset differently in \emph{e.g.} comb graphs and histograms.
+%
+% You can use |\meta{graph type}/y/format| or |y/format| to set the formatter
+% for both units at the same time, which is mainly useful for inline options to
+% avoid repeating the selected unit for each key.
+%
+% Initial settings are: |counts/format = \num{#1}| and
+% |frequencies/format/percent| (see below for an exlpanation of that key).
+% \end{key}
+%
+% \begin{demo}
+% \StatsGraph \combdata [
+% y/label=, width=0.4\columnwidth,
+% y/format=#1\text{ student\ifnum#1=1\else s\fi}
+% ]
+% \end{demo}
+%
+% \begin{key}{frequencies/format/real,
+% comb/frequencies/format/real,
+% histogram/frequencies/format/real,
+% cumulative/frequencies/format/real}
+% \begin{syntax}
+% frequencies/format/real = \meta{number of decimals}
+% \meta{graph type}/frequencies/format/real = \meta{number of decimals}
+% \end{syntax}
+% These keys make the corresponding format typeset its argument as a real
+% number, using the \cs{num} command of the \pkg{siunitx} package.
+% \begin{texnote}
+% This is equivalent to:\\
+% |frequencies/format = \num[round-mode=places,round-precision=##1]{####1}|
+% \end{texnote}
+% \end{key}
+%
+% \begin{key}{frequencies/format/percent,
+% comb/frequencies/format/percent,
+% histogram/frequencies/format/percent,
+% cumulative/frequencies/format/percent}
+% \begin{syntax}
+% frequencies/format/percent = \meta{number of decimals}
+% \meta{graph type}/frequencies/format/percent = \meta{number of decimals}
+% \end{syntax}
+% These keys make the corresponding format typeset its argument as a percentage,
+% using the \cs{num} command of the \pkg{siunitx} package. This is the initial
+% setting.
+% \begin{texnote}
+% This is equivalent to:\\
+% |frequencies/format = { \SI[round-mode=places,round-precision=##1]{| \\
+% | \fp_eval:n{####1*100}| \\
+% |}{\percent}|
+% \end{texnote}
+% \end{key}
+%
+% \begin{key}{counts/margin, frequencies/margin, y/margin,
+% comb/counts/margin, comb/frequencies/margin, comb/y/margin,
+% histogram/counts/margin, histogram/frequencies/margin,
+% histogram/y/margin,
+% cumulative/counts/margin, cumulative/frequencies/margin,
+% cumulative/y/margin}
+% \begin{syntax}
+% \meta{unit}/margin = \meta{numeric expression}
+% \meta{graph type}/\meta{unit}/margin = \meta{numeric expression}
+% \end{syntax}
+% These keys set the margin that will be used for the relevant axis in the
+% corresponding graph type, that is the amount of space above the data that
+% will be reserved by \cs{StatsGraph}. The \meta{numeric expression} should
+% compute a count or a frequency depending on the selected unit, and will
+% correspond to the empty space reserved above the graph \emph{in this very
+% unit}.
+%
+% In this expression, the following constants will be available: \cs{min} which
+% is the minimum count or frequency where something is drawn in the graph
+% (currently this is always zero); \cs{max} which is the maximum count or
+% frequency in the graph; and \cs{range} which is |\max - \min|.
+%
+% As usual, keys of the form |\meta{graph type}/\meta{unit}/margin| are used to
+% define the margin in a specific unit when used in a specific graph, whereas
+% keys of the form |\meta{unit}/margin| set the margin for all graph types at
+% the same time.
+%
+% You can use |\meta{graph type}/y/margin| or |y/margin| to set the margin
+% for both units at the same time, which is mainly useful for inline options to
+% avoid repeating the selected unit for each key.
+%
+% The inital value is |y/margin = \range / 10|.
+% \end{key}
+%
+% \begin{texnote}
+% This expression will be evaluated with the rules of |\fp_eval:n|
+% (with |\fp_gset:Nn| to be exact).
+% \end{texnote}
+%
+% \begin{demo}
+% \StatsGraph \combdata [ width=0.4\columnwidth, y/margin=2 ]
+% \end{demo}
+%
+% \subsubsection{Horizontal axis settings}
+%
+% \begin{key}{values/label, x/label,
+% comb/values/label, comb/x/label,
+% histogram/values/label, histogram/x/label,
+% cumulative/values/label, cumulative/x/label}
+% \begin{syntax}
+% values/label = \meta{label}, x/label = \meta{label}
+% \meta{graph type}/values/label = \meta{label}
+% \meta{graph type}/x/label = \meta{label}
+% \end{syntax}
+% These keys set the label to use for the $x$~axis of the graph when the
+% corresponding graph type is used. The keys with |x| are aliases for the
+% similar keys with |values|. If you omit the graph type, this sets the label
+% for all graph types simultaneously.
+%
+% The initial value is |values/label = \valuename|.
+% \end{key}
+%
+% \begin{texnote}
+% The \texttt{\meta{type}/values/label} key is a shorthand for
+% \texttt{\meta{type}/values/axis} | = { label = |\meta{label}| }|, which
+% means that using \texttt{\meta{type}/values/axis/reset} will also remove
+% any defined label.
+% \end{texnote}
+%
+% \begin{demo}
+% \statisticssetup[graph]{
+% width=0.38\columnwidth,
+% comb/frequencies, cumulative/counts,
+% }
+% \StatsGraph \combdata [ values/label=Shoe size ]
+% \StatsGraph \facebook [ cumulative, x/label=Time spent on Facebook ]
+% \end{demo}
+%
+% \begin{key}{values/axis, x/axis,
+% comb/values/axis, comb/x/axis,
+% histogram/values/axis, histogram/x/axis,
+% cumulative/values/axis, cumulative/x/axis,
+% values/axis/reset, x/axis/reset,
+% comb/values/axis/reset, comb/x/axis/reset,
+% histogram/values/axis/reset, histogram/x/axis/reset,
+% cumulative/values/axis/reset, cumulative/x/axis/reset}
+% \begin{syntax}
+% \meta{graph type}/values/axis = \meta{TikZ datavisualization axis options}
+% \meta{graph type}/x/axis = \meta{TikZ datavisualization axis options}
+% \meta{graph type}/values/axis/reset, \meta{graph type}/x/axis/reset
+% \end{syntax}
+% The \texttt{\meta{graph type}/values/axis} key append options to the TikZ
+% $x$~axis when the corresponding graph type is used. You can clear these
+% options with \texttt{\meta{graph type}/values/axis}. The keys with |x| are
+% aliases for the similar keys with |values|. If you omit the graph type, this
+% sets the label for all graph types simultaneously.
+%
+% The initial value is:
+% \begin{verbatim}
+% values/axis = {
+% label = \valuename,
+% ticks and grid={many, integer minor steps}
+% }
+% \end{verbatim}
+% \end{key}
+%
+% \begin{demo}
+% \statisticssetup[graph]{
+% width=0.4\columnwidth,
+% comb/frequencies/axis = { ticks={step=0.08} },
+% histogram/y/axis = { grid = none },
+% }
+% \StatsGraph \combdata [ frequencies, y/axis = {
+% ticks={style=blue}, unit length=4cm per 0.25 units,
+% } ]
+% \hfill \StatsGraph \facebook
+% \end{demo}
+%
+% \begin{key}{values/format, x/format,
+% comb/values/format, comb/x/format,
+% histogram/values/format, histogram/x/format,
+% cumulative/values/format, cumulative/x/format}
+% \begin{syntax}
+% values/format = \meta{formatting code}, x/format = \meta{formatting code}
+% \meta{graph type}/values/format = \meta{formatting code}
+% \meta{graph type}/x/format = \meta{formatting code}
+% \end{syntax}
+% These keys set the format to use for all values that are typeset on the
+% graphs, which currently means the values typeset alongside ticks on the
+% x~axis. The \meta{formatting code} should be \TeX\ code to render the actual
+% number, in which all occurrences of |#1| are replaced by the value to
+% typeset. The formatting code is typeset in math mode.
+%
+% Keys of the form |\meta{graph type}/value/format| are used to set the
+% formatter of values when used in a specific graph. The keys with |x| are
+% aliases for the similar keys with |values|. If you omit the graph type, this
+% sets the label for all graph types simultaneously.
+%
+% The initial value is |values/format = \num{#1}|.
+% \end{key}
+%
+% \begin{demo}
+% \StatsGraph \combdata [
+% width=0.5\columnwidth,
+% x/format=\fbox{$#1$}
+% ]
+% \end{demo}
+%
+% \begin{key}{values/margin, x/margin,
+% comb/values/margin, comb/x/margin,
+% histogram/values/margin, histogram/x/margin,
+% cumulative/values/margin, cumulative/x/margin}
+% \begin{syntax}
+% values/margin = \meta{numeric expression},\
+%x/margin = \meta{numeric expression}
+% \meta{graph type}/values/margin = \meta{numeric expression}
+% \meta{graph type}/x/margin = \meta{numeric expression}
+% \end{syntax}
+% These keys set the margin that will be used for the x~axis in the
+% corresponding graph type, that is the amount of space left and right of the
+% data that will be reserved by \cs{StatsGraph}. The \meta{numeric expression},
+% when evaluated, will correspond to the empty space reserved left of the
+% smallest value and right of the biggest one, with the same scale as the values
+% themselves.
+%
+% In this expression, the following constants will be available: \cs{min} which
+% is the minimum value in the graph; \cs{max} which is the maximum value;
+% \cs{range} which is |\max - \min|; and \cs{xstep} which is the distance
+% between two minor ticks in the graph (this is the axis step if
+% |minor steps between steps| is empty).
+%
+% The inital value is |x/margin = \xstep / 2|.
+% \end{key}
+%
+% \begin{texnote}
+% This expression will be evaluated with the rules of |\fp_eval:n|
+% (with |\fp_gset:Nn| to be exact).
+% \end{texnote}
+%
+% \begin{demo}
+% \StatsGraph \combdata [ width=0.5\columnwidth, x/margin=2 ]
+% \end{demo}
+%
+% \subsubsection{Settings specific to cumulative graphs}
+%
+% \begin{key}{cumulative}
+% \begin{syntax}
+% cumulative $[$ = \meta{truth value} $]$
+% \end{syntax}
+% This key activates or deactivates the cumulative mode of \cs{StatsGraph}. The
+% \meta{truth value} must be either |true| or |false| or be ommited, in which
+% case it defaults to |true|.
+%
+% This mode is currently ignored if the counts are given for pointwise values,
+% as opposed to value ranges. Support is planned but a suitable interface still
+% needs to be devised for settings corresponding to the discontinuities.
+%
+% The initial value is |cumulative = false|.
+% \end{key}
+%
+% \begin{key}{decreasing}
+% \begin{syntax}
+% decreasing $[$ = \meta{truth value} $]$
+% \end{syntax}
+% This key selects whether the cumulative mode of \cs{StatsGraph} plots the
+% decreasing cumulative distribution function (that maps $x$ to the frequency of
+% $\left[x;+\infty\right[$) instead of the classical increasing one (mapping $x$
+% to the frequency of $\left]-\infty;x\right]$). The \meta{truth value} must be
+% either |true| or |false| or be ommited, in which case it defaults to |true|.
+%
+% The initial value is |decreasing = false|.
+% \end{key}
+%
+% \begin{demo}
+% \statisticssetup[graph]{ width = 0.25\columnwidth, height=4cm }
+% \centering
+% \StatsGraph \facebook
+% \StatsGraph \facebook [cumulative]
+% \StatsGraph \facebook [cumulative, decreasing]
+% \end{demo}
+%
+% \subsubsection{Settings specific to histograms}
+%
+% \begin{key}{histogram/areas}
+% \begin{syntax}
+% histogram/areas $[$ = \meta{truth value} $]$
+% \end{syntax}
+% This key activates or deactivates the typesetting of counts or frequencies
+% above the rectangles in the histogram. They correspond to the area of the
+% rectangle according to histogram rules, which explains the name of the key.
+%
+% If ommited the \meta{truth value} defaults to |true|, which is also the
+% initial value.
+% \end{key}
+%
+% \begin{demo}
+% \StatsGraph \facebook [width=0.5\columnwidth, histogram/areas = false]
+% \end{demo}
+%
+% \begin{key}{histogram/areas/style, histogram/areas/style/reset}
+% \begin{syntax}
+% histogram/areas/style = \meta{TikZ node options}
+% histogram/areas/style/reset
+% \end{syntax}
+% This key appends options to the TikZ nodes containing the areas (counts or
+% frequencies). Note that the typesetting of the areas will be controlled by
+% the \texttt{histogram/\meta{unit}/format} keys, which means that the
+% |histogram/areas/style| is intended for common styling.
+%
+% The initial value is |histogram/areas/style = { auto, font=\small }|.
+%
+% \begin{texnote}
+% The node is positionned in the middle of the top edge of the rectangle so if
+% you do not want it there some style option like |auto| or |above| should be
+% used.
+% \end{texnote}
+% \end{key}
+%
+% \begin{demo}
+% \StatsGraph \facebook [ histogram/areas/style/reset,
+% histogram/areas/style = { fill=white } ]
+% \end{demo}
+%
+% \begin{key}{histogram/counts/autostep, histogram/frequencies/autostep,
+% histogram/y/autostep}
+% \begin{syntax}
+% histogram/\meta{unit}/autostep $[$ = \meta{floating point expression} $]$
+% histogram/y/autostep $[$ = \meta{floating point expression} $]$
+% \end{syntax}
+% This key setups the y~axis grid so that a grid tile corresponds to
+% \meta{floating point expression} items. This expression is interpreted as a
+% count, but you can use the \cs{total} constant which is the total count.
+% In particular, |\total/100| represents exactly \SI{1}{\percent}.
+%
+% This key essentially divides the \meta{floating point expression} by the
+% horizontal distance between minor steps of the values axis, then uses the
+% result as the vertical step. As a convenience, |histogram/y/autostep| forwards
+% its value to |histogram/legend/area| in addition to the
+% \texttt{histogram/\meta{unit}/autostep} keys.
+%
+% If ommited the \meta{floating point expression} defaults to $1$.
+% The initial value is |histogram/y/autostep = 1|.
+%
+% \begin{texnote}
+% \texttt{histogram/\meta{unit}/autostep} uses
+% \texttt{histogram/\meta{unit}/axis} internally, so
+% \texttt{histogram/\meta{unit}/axis/reset} will neuter its effect.
+% \end{texnote}
+% \end{key}
+%
+% \begin{demo}
+% \StatsGraph \facebook [frequencies, histogram/y/autostep=2*\total/100]
+% \end{demo}
+%
+% \begin{key}{histogram/legend, histogram/legend/x, histogram/legend/w}
+% \begin{syntax}
+% histogram/legend = "{" \meta{legend keys} "}"
+% histogram/legend/x = $[$ \meta{floating point expression} $]$
+% histogram/legend/w = \meta{floating point expression}
+% \end{syntax}
+% If |histogram/legend/x| is set to an empty value, no legend will be typeset.
+% Else, it should be a \meta{floating point expression} which corresponds to the
+% \emph{value} at which the left side of the legend rectangle will lie. In that
+% case |histogram/legend/w| should be a \meta{floating point expression}
+% representing the width (in value units) of the legend rectangle.
+%
+% In both of these expressions, the following constants are available:
+% \end{key}
+% \begin{itemize}
+% \item \cs{min} which is the minimum value where data is present;
+% \item \cs{max} which is the maximum value where data is present;
+% \item \cs{range} which is |\max - \min|;
+% \item \cs{xstep} which is the distance between two minor steps of the x axis.
+% \end{itemize}
+%
+% In fact, you probably will not set these keys directly, but will use the
+% |histogram/legend| key, which requires as value a comma-separated list of
+% sub-keys that will be used under the |histogram/legend/| path. In particular,
+% |histogram/legend = { x=2, y=3 }| is equivalent to
+% |histogram/legend/x=2, histogram/legend/y=3|.
+%
+% \begin{key}{histogram/legend/y, histogram/legend/h, histogram/legend/area}
+% \begin{syntax}
+% histogram/legend/y = \meta{floating point expression}
+% histogram/legend/h = \meta{floating point expression}
+% histogram/legend/area = \meta{floating point expression}
+% \end{syntax}
+% If |histogram/legend/x| is not empty, |histogram/legend/y| and
+% |histogram/legend/h| should be \meta{floating point expression}s which
+% correspond to the y~coordinate of the bottom side and the vertical dimension
+% respectively of the legend rectangle, in count per value units.
+%
+% In both of these expressions, the following constants are available:
+% \end{key}
+% \begin{itemize}
+% \item \cs{min} which is the $y$~coordinate of the bottom of all histogram
+% rectangles (this is always~$0$);
+% \item \cs{max} which is the $y$~coordinate of the tallest histogram rectangle;
+% \item \cs{range} which is |\max - \min|;
+% \item \cs{xstep} which is the distance between two minor steps of the x axis.
+% \item \cs{width} which is the width of the legend rectangle as computed by
+% evaluating |histogram/legend/w|;
+% \item \cs{total} which is the total number of elements, useful when you want
+% to size the legend using frequencies (the dimensions here always use counts).
+% \end{itemize}
+% Additionnally, when evaluating |histogram/legend/y| the |\height|~constant
+% will be available and equal to the just computed value of
+% |histogram/legend/h|.
+%
+% The key |histogram/legend/area = |\meta{fp expression} is a shorthand for:\\
+% |histogram/legend/h = (|\meta{fp expression}|) / \width|.
+%
+% Again, you probably will not set these keys directly but using the
+% |histogram/legend| key.
+%
+% \begin{key}{histogram/legend/options, histogram/legend/options/reset,
+% histogram/legend/label}
+% \begin{syntax}
+% histogram/legend/options = \meta{TikZ node options}
+% histogram/legend/options/reset
+% histogram/legend/label = \meta{TikZ label value}
+% \end{syntax}
+% The key |histogram/legend/options| appends the \meta{TikZ node options} to the
+% list of options that will be passed to the TikZ node responsible for the
+% legend rectangle, \emph{after} the options in |histogram/style|. You can use
+% it to tweak the apparance of the legend.
+%
+% The key |histogram/legend/label = |\meta{label} is a shorthand for:\\
+% |histogram/legend/options = { label = {|\meta{fp expression}|} }|, and thus
+% uses the TikZ label syntax.
+%
+% Again, you probably will not set these keys directly but using the
+% |histogram/legend| key.
+% \end{key}
+%
+% The initial value is |histogram/legend = { x=, y=0, w=\xstep, area=1 }| which
+% means that no legend is typeset, and the legend options are empty.
+%
+% \begin{texnote}
+% |area=1| is actually set by the initial value of |histogram/y/autostep|.
+% \end{texnote}
+%
+% \begin{demo}
+% \statisticssetup[graph]{ width = 0.48\columnwidth }
+% \StatsGraph \facebook [
+% histogram/legend = { x=9, y=8, label=1 student }
+% ]
+% \StatsGraph \facebook [
+% frequencies, histogram/y/autostep=0.02*\total,
+% histogram/legend = { x=12, y=2*\height, w=2, area=0.08*\total,
+% label=above:\SI{8}{\percent} }
+% ]
+% \end{demo}
+%
+% \end{documentation}
+%
+% \cleardoublepage
+% \begin{implementation}
+%
+% \section{\pkg{\ExplFileName} implementation}
+%
+% \begin{macrocode}
+%<*package>
+%<@@=statistics>
+% \end{macrocode}
+%
+% \begin{macrocode}
+\ProvidesExplPackage
+ {\ExplFileName}{\ExplFileDate}{\ExplFileVersion}{\ExplFileDescription}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\RequirePackage{xparse}
+\RequirePackage{siunitx}
+\RequirePackage{tikz}
+\RequirePackage{etoolbox}
+
+\ExplSyntaxOff
+\usetikzlibrary{datavisualization, fit}
+\ExplSyntaxOn
+% \end{macrocode}
+%
+% Translations
+%
+% \begin{macrocode}
+\tl_new:N \valuename
+\tl_new:N \countname
+\tl_new:N \freqname
+\tl_new:N \ccountname
+\tl_new:N \cfreqname
+\tl_new:N \iccname
+\tl_new:N \icfname
+\tl_new:N \dccname
+\tl_new:N \dcfname
+
+\tl_set:Nn \valuename { Values }
+\tl_set:Nn \countname { Count }
+\tl_set:Nn \ccountname { Cumulative~count }
+\tl_set:Nn \freqname { Frequency }
+\tl_set:Nn \cfreqname { Cumulative~frequency }
+\tl_set:Nn \iccname { ICC }
+\tl_set:Nn \icfname { ICF }
+\tl_set:Nn \dccname { DCC }
+\tl_set:Nn \dcfname { DCF }
+
+\AtEndPreamble {
+ \tl_if_exist:NT \captionsfrench {
+ \tl_put_right:Nn \captionsfrench {
+ \tl_set:Nn \valuename { Modalit\'e }
+ \tl_set:Nn \countname { Effectif }
+ \tl_set:Nn \ccountname { Effectif~cumul\'e }
+ \tl_set:Nn \freqname { Fr\'equence }
+ \tl_set:Nn \cfreqname { Fr\'equence~cumul\'ee }
+ \tl_set:Nn \iccname { ECC }
+ \tl_set:Nn \icfname { FCC }
+ \tl_set:Nn \dccname { ECD }
+ \tl_set:Nn \dcfname { FCD }
+ }
+ }
+}
+% \end{macrocode}
+%
+% \subsection{Common facilities}
+%
+% \begin{macrocode}
+\cs_new_protected:Nn \@@_keys_define:nn {
+ \keys_define:nn { statistics / #1 } { #2 }
+}
+\cs_new_protected:Nn \@@_setup:nn {
+ \keys_set:nn { statistics / #1 } { #2 }
+}
+\NewDocumentCommand \statisticssetup { o +m } {
+ \IfNoValueTF { #1 } {
+ \keys_set:nn { statistics } { #2 }
+ }{
+ \keys_set:nn { statistics / #1 } { #2 }
+ }
+}
+
+\tl_new:N \l_@@_data_tl
+\seq_new:N \l_@@_show_seq
+
+\int_new:N \l_@@_nbvals_int
+\int_new:N \l_@@_currange_int
+
+\fp_new:N \l_@@_total_fp
+\fp_new:N \l_@@_curtotal_fp
+
+\fp_new:N \l_@@_range_min_fp
+\fp_new:N \l_@@_range_max_fp
+\tl_new:N \l_@@_range_minrel_tl
+\tl_new:N \l_@@_range_maxrel_tl
+\cs_new_protected_nopar:Npn
+ \@@_parse_range:w \IN#1#2;#3;#4#5\q_stop {
+% \end{macrocode}
+%
+% \begin{itemize}
+% \item |#1| is the first |[| or |]|
+% \item |#4| is the second |[| or |]| and |#5| eats all trailing tokens
+% \end{itemize}
+%
+% \begin{macrocode}
+ \fp_set:Nn \l_@@_range_min_fp { #2 }
+ \fp_set:Nn \l_@@_range_max_fp { #3 }
+}
+\cs_new_protected_nopar:Npn
+ \@@_parse_range_full:w \IN#1#2;#3;#4#5\q_stop {
+ \fp_set:Nn \l_@@_range_min_fp { #2 }
+ \fp_set:Nn \l_@@_range_max_fp { #3 }
+ \tl_if_eq:nnTF { #1 } { [ } {
+ \tl_set:Nn \l_@@_range_minrel_tl { <=}
+ }{
+ \tl_set:Nn \l_@@_range_minrel_tl { < }
+ }
+ \tl_if_eq:nnTF { #4 } { ] } {
+ \tl_set:Nn \l_@@_range_maxrel_tl { <= }
+ }{
+ \tl_set:Nn \l_@@_range_maxrel_tl { < }
+ }
+ \exp_args:NNnx
+ \prg_set_conditional:Nnn \@@_if_in_range:n { T } {
+ \exp_not:N \fp_compare:nTF {
+ \exp_not:N \l_@@_range_min_fp
+ \exp_not:V \l_@@_range_minrel_tl
+ \exp_not:n { ##1 }
+ \exp_not:V \l_@@_range_maxrel_tl
+ \exp_not:N \l_@@_range_max_fp }{
+ \exp_not:N \prg_return_true:
+ }{
+ \exp_not:N \prg_return_false:
+ }
+ }
+}
+% \end{macrocode}
+%
+% \subsection{Compute and typeset statistics tables}
+%
+% \begin{macrocode}
+\NewDocumentCommand \@@_IN:w { m u{;} u{;} m } {
+ \ensuremath{ \left#1 \num{#2} \mathbin{;} \num{#3} \right#4 }
+}
+
+\cs_new_protected:Nn \@@_setshow:n {
+ \seq_clear:N \l_@@_show_seq
+ \clist_map_inline:nn {#1} {
+ \tl_if_in:nnTF {##1} {-} {
+ \@@_setshow_aux:w ##1 \q_stop
+ }{
+ \seq_put_right:Nn \l_@@_show_seq {##1}
+ }
+ }
+}
+\cs_new_protected:Npn \@@_setshow_aux:w #1 - #2 \q_stop {
+ \int_step_inline:nnnn {#1} {1} {#2} {
+ \seq_put_right:Nn \l_@@_show_seq {##1}
+ }
+}
+\cs_new_protected_nopar:Nn \@@_set_if_shown:N {
+ \seq_if_empty:NTF \l_@@_show_seq {
+ \bool_set_true:N #1
+ }{
+ \seq_if_in:NVTF
+ \l_@@_show_seq
+ \l_@@_currange_int {
+ \bool_set_true:N #1
+ }{
+ \bool_set_false:N #1
+ }
+ }
+}
+
+\@@_keys_define:nn { table } {
+ showonly .value_required:n = true,
+ showonly .code:n = \@@_setshow:n{#1},
+
+ showonly/hidden .value_required:n = true,
+ showonly/hidden .code:n = {
+ \cs_set_protected:Nn
+ \@@_table_hidden_format:n
+ { #1 }
+ },
+ showonly/hidden .initial:n = ,
+
+ showonly/shown .value_required:n = true,
+ showonly/shown .code:n = {
+ \cs_set_protected:Nn
+ \@@_table_shown_format:n
+ { #1 }
+ },
+ showonly/shown .initial:n = #1,
+
+ maxcols .int_set:N = \l_@@_table_maxcols_int,
+ maxcols .value_required:n = true,
+ maxcols .initial:n = 0,
+
+ tablesep .tl_set:N = \l_@@_table_sep_tl,
+ tablesep .value_required:n = true,
+ tablesep .initial:n = \\,
+
+ valign .tl_set:N = \l_@@_table_valign_tl,
+ valign .value_required:n = true,
+ valign .initial:n = t,
+
+ coltype .tl_set:N = \l_@@_table_coltype_tl,
+ coltype .value_required:n = true,
+
+ headcoltype .tl_set:N = \l_@@_table_headcoltype_tl,
+ headcoltype .value_required:n = true,
+
+ newline .tl_set:N = \l_@@_table_newline_tl,
+ newline .value_required:n = true,
+
+ preline .tl_set:N = \l_@@_table_preline_tl,
+ preline .value_required:n = true,
+
+ postline .tl_set:N = \l_@@_table_postline_tl,
+ postline .value_required:n = true,
+
+ outline .meta:n = { preline={#1}, postline={#1} },
+ outline .value_required:n = true,
+
+ frame .choice:,
+ frame/full .meta:n = { preline=\firsthline, postline=\lasthline,
+ newline=\\\hline,
+ headcoltype=|l|, coltype=c| },
+ frame/full .value_forbidden:n = true,
+
+ frame/none .meta:n = { outline=, newline=\\,
+ headcoltype=l, coltype=c },
+ frame/none .value_forbidden:n = true,
+
+ frame/clean .meta:n = { preline=\firsthline, postline=\lasthline,
+ newline=\\,
+ headcoltype=l, coltype=c },
+ frame/clean .initial:n = ,
+ frame/clean .value_forbidden:n = true,
+
+ digits .int_set:N = \l_@@_table_round_int,
+ digits .initial:n = 3,
+
+ allcounts/format .code:n = {
+ \cs_set_protected:Nn
+ \@@_table_allcounts_format:n
+ { #1 }
+ },
+ allcounts/format .value_required:n = true,
+ allcounts/format .initial:n = { \num{#1} },
+
+ allfreqs/format .code:n = {
+ \cs_set_protected:Nn
+ \@@_table_allfreqs_format:n
+ { #1 }
+ },
+ allfreqs/format .value_required:n = true,
+
+ allfreqs/format/real .meta:n = {
+ allfreqs/format = \num{##1}
+ },
+ allfreqs/format/real .value_forbidden:n = true,
+
+ allfreqs/format/percent .meta:n = {
+ allfreqs/format = \SI{\fp_eval:n{##1*100}}{\percent}
+ },
+ allfreqs/format/percent .initial:n = ,
+ allfreqs/format/percent .value_forbidden:n = true,
+
+ allfreqs/format/scaled .meta:n = {
+ allfreqs/format = \num{\fp_eval:n{##1*#1}}
+ },
+ allfreqs/format/scaled .value_required:n = true,
+}
+
+\cs_new:Nn \@@_define_row:nnn {
+% \end{macrocode}
+%
+% \begin{itemize}
+% \item |#1| (tl): row name;
+% \item |#2| (bool): enabled by default
+% \item |#3| (tl): default header;
+% \end{itemize}
+%
+% \begin{macrocode}
+ \tl_new:c { l_@@_table_#1_name_tl }
+ \bool_new:c { l_@@_table_#1_bool }
+ \@@_keys_define:nn { table } {
+ #1 .code:n = {
+ \bool_set_true:c { l_@@_table_#1_bool }
+ \quark_if_no_value:nF { ##1 } {
+ \@@_setup:nn { table } {
+ #1/header = { ##1 }
+ }
+ }
+ },
+ #1 .default:n = \q_no_value,
+
+ no#1 .code:n =
+ \bool_set_false:c { l_@@_table_#1_bool },
+ no#1 .value_forbidden:n = true,
+
+ #1/header .tl_set:c = { l_@@_table_#1_name_tl },
+ #1/header .value_required:n = true,
+ #1/header .initial:n = { #3 },
+
+ #1/format .code:n = {
+ \cs_set_protected:cn
+ { _@@_table_#1_format:n }
+ { ##1 }
+ },
+ #1/format .value_required:n = true,
+ #1/format .initial:n = { ##1 },
+ }
+ \bool_set:cn { l_@@_table_#1_bool } { #2 }
+}
+
+\@@_define_row:nnn { values } \c_true_bool \valuename
+\@@_define_row:nnn { counts } \c_false_bool \countname
+\@@_define_row:nnn { frequencies } \c_false_bool \freqname
+\@@_define_row:nnn { icc } \c_false_bool \iccname
+\@@_define_row:nnn { icf } \c_false_bool \icfname
+\@@_define_row:nnn { dcc } \c_false_bool \dccname
+\@@_define_row:nnn { dcf } \c_false_bool \dcfname
+
+\@@_setup:nn { table } {
+ values/format = \ensuremath{#1},
+}
+
+\cs_undefine:N \@@_define_row:nnn
+
+\seq_new:N \l_@@_table_contents_seq
+\tl_new:N \l_@@_table_preamble_tl
+
+\tl_new:N \l_@@_table_values_tl
+\tl_new:N \l_@@_table_counts_tl
+\tl_new:N \l_@@_table_frequencies_tl
+\tl_new:N \l_@@_table_icc_tl
+\tl_new:N \l_@@_table_icf_tl
+\tl_new:N \l_@@_table_dcc_tl
+\tl_new:N \l_@@_table_dcf_tl
+
+\fp_new:N \l_@@_table_curICF_fp
+\fp_new:N \l_@@_table_prevICF_fp
+
+\bool_new:N \l_@@_table_firstrow_bool
+
+
+\cs_generate_variant:Nn \keyval_parse:NNn { NNV }
+\NewDocumentCommand \StatsTable { +O{} +m +O{} } {
+ \group_begin:
+% \end{macrocode}
+%
+% Ensure some macros exist with sensible definitions
+%
+% \begin{macrocode}
+ \cs_if_exist:NF \firsthline {
+ \cs_set_eq:NN \firsthline \hline
+ }
+ \cs_if_exist:NF \lasthline {
+ \cs_set_eq:NN \lasthline \hline
+ }
+ \cs_if_exist:NF \IN {
+ \cs_set_eq:NN \IN \@@_IN:w
+ }
+% \end{macrocode}
+%
+% Handle optional settings
+%
+% \begin{macrocode}
+ \@@_setup:nn { table } { #1, #3 }
+% \end{macrocode}
+%
+% Get the data inline or from a variable
+%
+% \begin{macrocode}
+ \tl_if_single:nTF { #2 } {
+% \end{macrocode}
+%
+% Generate meaningful error by using the non-existent variable
+%
+% \begin{macrocode}
+ \cs_if_exist:NF #2 { #2 }
+ \tl_set_eq:NN \l_@@_data_tl #2
+ }{
+ \tl_set:Nn \l_@@_data_tl { #2 }
+ }
+% \end{macrocode}
+%
+% Compute the total population count/frequency
+%
+% \begin{macrocode}
+ \fp_zero:N \l_@@_total_fp
+ \keyval_parse:NNV
+ \@@_table_count:n
+ \@@_table_count:nn
+ \l_@@_data_tl
+% \end{macrocode}
+%
+% Loop again and output the table
+%
+% \begin{macrocode}
+ \@@_table_start:
+ \fp_zero:N \l_@@_table_prevICF_fp
+ \keyval_parse:NNV
+ \@@_table_make:n
+ \@@_table_make:nn
+ \l_@@_data_tl
+ \@@_table_end:
+% \end{macrocode}
+%
+% Done
+%
+% \begin{macrocode}
+ \group_end:
+}
+% \end{macrocode}
+%
+% table building functions
+%
+% \begin{macrocode}
+\cs_new_protected_nopar:Nn \@@_table_start: {
+% \end{macrocode}
+%
+% Init column count
+%
+% \begin{macrocode}
+ \int_zero:N \l_@@_nbvals_int
+% \end{macrocode}
+%
+% Start rows with headers
+%
+% \begin{macrocode}
+ \clist_map_inline:nn { values, counts, frequencies, icc, icf, dcc, dcf } {
+ \tl_set:cx { l_@@_table_##1_tl } {
+ \exp_not:N \ensuremath { \exp_not:N \hbox {
+ \exp_not:c { l_@@_table_##1_name_tl }
+ } }
+ }
+ }
+}
+\cs_new_protected_nopar:Nn \@@_table_end: {
+% \end{macrocode}
+%
+% Build-up the table preamble
+%
+% \begin{macrocode}
+ \tl_set:Nx \l_@@_table_preamble_tl {
+ \exp_not:n { \begin{array}[ }
+ \exp_not:V \l_@@_table_valign_tl
+ \exp_not:n { ] }
+ { \exp_not:V \l_@@_table_headcoltype_tl
+ \prg_replicate:nn { \l_@@_nbvals_int }
+ { \exp_not:V \l_@@_table_coltype_tl } }
+ }
+% \end{macrocode}
+%
+% Add each row if needed.
+%
+% \begin{macrocode}
+ \seq_clear:N \l_@@_table_contents_seq
+ \clist_map_inline:nn { values, counts, icc, dcc, frequencies, icf, dcf } {
+ \bool_if:cT { l_@@_table_##1_bool } {
+ \seq_put_right:Nv
+ \l_@@_table_contents_seq
+ { l_@@_table_##1_tl }
+ }
+ }
+ $\tl_use:N \l_@@_table_preamble_tl
+ \l_@@_table_preline_tl
+ \seq_use:Nn
+ \l_@@_table_contents_seq
+ { \l_@@_table_newline_tl }
+ \\ \l_@@_table_postline_tl
+ \end{array}$
+}
+% \end{macrocode}
+%
+% Counting auxiliaries
+%
+% \begin{macrocode}
+\cs_new_protected_nopar:Nn \@@_table_count:n {
+ \@@_table_count:nn {} { 1 }
+}
+\cs_new_protected_nopar:Nn \@@_table_count:nn {
+ \fp_add:Nn \l_@@_total_fp { #2 }
+}
+% \end{macrocode}
+%
+% Accumulating content
+%
+% \begin{macrocode}
+\cs_new_protected_nopar:Nn \@@_table_make:n {
+ \@@_table_make:nn { #1 } { 1 }
+}
+\cs_new_protected_nopar:Nn \@@_table_make:nn {
+% \end{macrocode}
+%
+% Maybe close the table and create a new one
+%
+% \begin{macrocode}
+ \int_compare:nT
+ { 0 < \l_@@_table_maxcols_int
+ = \l_@@_nbvals_int } {
+ \@@_table_end:
+ \tl_use:N \l_@@_table_sep_tl
+ \@@_table_start:
+ }
+ \int_incr:N \l_@@_nbvals_int
+ \int_incr:N \l_@@_currange_int
+ \fp_add:Nn \l_@@_curtotal_fp { #2 }
+% \end{macrocode}
+%
+% Hidden or not
+%
+% \begin{macrocode}
+ \@@_set_if_shown:N \l_tmpa_bool
+ \tl_set:Nx \l_tmpa_tl {
+ \exp_not:n { & \tl_set:Nn \currentcolumn } {
+ \int_use:N \l_@@_currange_int
+ }
+ }
+ \bool_if:NTF \l_tmpa_bool {
+ \tl_put_right:Nn \l_tmpa_tl
+ {\@@_table_shown_format:n}
+ }{
+ \tl_put_right:Nn \l_tmpa_tl
+ {\@@_table_hidden_format:n}
+ }
+% \end{macrocode}
+%
+% Values
+%
+% \begin{macrocode}
+ \bool_if:NT \l_@@_table_values_bool {
+ \tl_put_right:Nx \l_@@_table_values_tl {
+ \exp_not:V \l_tmpa_tl {
+ \exp_not:n {
+ \@@_table_values_format:n { #1 }
+ }
+ }
+ }
+ }
+% \end{macrocode}
+%
+% Counts
+%
+% \begin{macrocode}
+ \bool_if:NT \l_@@_table_counts_bool {
+ \tl_put_right:Nx \l_@@_table_counts_tl {
+ \exp_not:V \l_tmpa_tl {
+ \exp_not:n {
+ \@@_table_counts_format:n {
+ { \@@_table_allcounts_format:n { #2 } }
+ }
+ }
+ }
+ }
+ }
+% \end{macrocode}
+%
+% ICC
+%
+% \begin{macrocode}
+ \bool_if:NT \l_@@_table_icc_bool {
+ \tl_put_right:Nx \l_@@_table_icc_tl {
+ \exp_not:V \l_tmpa_tl {
+ \exp_not:n { \@@_table_icc_format:n }
+ {
+ \exp_not:n{ \@@_table_allcounts_format:n }
+ { \fp_use:N \l_@@_curtotal_fp }
+ }
+ }
+ }
+ }
+% \end{macrocode}
+%
+% DCC ( = 1 - ICC + curcount )
+%
+% \begin{macrocode}
+ \bool_if:NT \l_@@_table_dcc_bool {
+ \tl_put_right:Nx \l_@@_table_dcc_tl {
+ \exp_not:V \l_tmpa_tl {
+ \exp_not:n { \@@_table_dcc_format:n }
+ {
+ \exp_not:n{ \@@_table_allcounts_format:n }
+ {
+ \fp_eval:n {
+ \l_@@_total_fp
+ - \l_@@_curtotal_fp
+ + #2
+ }
+ }
+ }
+ }
+ }
+ }
+% \end{macrocode}
+%
+% Frequencies (we compute them from the ICFs so that rounded freqs add up to 1)
+%
+% \begin{macrocode}
+ \fp_set:Nn \l_@@_table_curICF_fp {
+ round(\l_@@_curtotal_fp
+ / \l_@@_total_fp,
+ \l_@@_table_round_int)
+ }
+ \bool_if:NT \l_@@_table_frequencies_bool {
+ \tl_put_right:Nx \l_@@_table_frequencies_tl {
+ \exp_not:V \l_tmpa_tl {
+ \exp_not:n { \@@_table_frequencies_format:n }
+ {
+ \exp_not:n{ \@@_table_allfreqs_format:n }
+ {
+ \fp_eval:n {
+ \l_@@_table_curICF_fp
+ - \l_@@_table_prevICF_fp
+ }
+ }
+ }
+ }
+ }
+ }
+% \end{macrocode}
+%
+% ICF
+%
+% \begin{macrocode}
+ \bool_if:NT \l_@@_table_icf_bool {
+ \tl_put_right:Nx \l_@@_table_icf_tl {
+ \exp_not:V \l_tmpa_tl {
+ \exp_not:n { \@@_table_icf_format:n }
+ {
+ \exp_not:n{ \@@_table_allfreqs_format:n }
+ { \fp_to_decimal:N \l_@@_table_curICF_fp }
+ }
+ }
+ }
+ }
+% \end{macrocode}
+%
+% DCF ( = 1 - ICF + curfreq = 1 - prevICF )
+%
+% \begin{macrocode}
+ \bool_if:NT \l_@@_table_dcf_bool {
+ \tl_put_right:Nx \l_@@_table_dcf_tl {
+ \exp_not:V \l_tmpa_tl {
+ \exp_not:n { \@@_table_dcf_format:n }
+ {
+ \exp_not:n{ \@@_table_allfreqs_format:n }
+ {
+ \fp_eval:n {
+ 1 - \l_@@_table_prevICF_fp
+ }
+ }
+ }
+ }
+ }
+ }
+% \end{macrocode}
+%
+% Prepare for next iteration
+%
+% \begin{macrocode}
+ \fp_set_eq:NN
+ \l_@@_table_prevICF_fp
+ \l_@@_table_curICF_fp
+}
+% \end{macrocode}
+%
+% \subsection{Compute and typeset statistics graphics}
+%
+% \begin{macrocode}
+\cs_new_protected:Nn \@@_make_forwarded_key:nnnn {
+% \end{macrocode}
+%
+% \begin{itemize}
+% \item |#1| (tl): common prefix
+% \item |#2| (tl): middle
+% \item |#3| (clist): replacements
+% \item |#4| (tl): common suffix
+% \end{itemize}
+%
+% \begin{macrocode}
+ \tl_clear:N \l_tmpa_tl
+ \clist_map_inline:nn {#3} {
+ \tl_put_right:Nx \l_tmpa_tl {
+ \exp_not:n {#1}
+ \tl_if_empty:nF {#1} { \tl_if_empty:nF {##1} {\exp_not:N /} }
+ \exp_not:n {##1}
+ \tl_if_empty:nF {#4} { \tl_if_empty:nF {##1} {\exp_not:N /} }
+ \exp_not:n {#4,}
+ }
+ }
+ \tl_set:Nx \l_tmpb_tl {
+ \exp_not:n {#1}
+ \tl_if_empty:nF {#1} { \tl_if_empty:nF {#2} {\exp_not:N /} }
+ \exp_not:n {#2}
+ \tl_if_empty:nF {#4} { \tl_if_empty:nF {#2} {\exp_not:N /} }
+ \exp_not:n {#4}
+ }
+ \use:x {
+ \exp_not:n { \@@_keys_define:nn { graph } }
+ {
+ \exp_not:V \l_tmpb_tl \exp_not:n { .default:n = \q_no_value, }
+ \exp_not:V \l_tmpb_tl
+ \exp_not:n { .code:n = \@@_forwarded_key:nn }
+ { \exp_not:V \l_tmpa_tl }
+ { \exp_not:n { ##1 } }
+ }
+ }
+}
+\cs_new_protected:Nn \@@_forwarded_key:nn {
+ \quark_if_no_value:nTF { #2 } {
+ \@@_setup:nn { graph } { #1 }
+ }{
+ \clist_set:Nn \l_tmpa_clist { #1,{} }
+ \use:x {
+ \exp_not:n { \@@_setup:nn { graph } } {
+ \clist_use:Nn \l_tmpa_clist { = {#2}, }
+ }
+ }
+ }
+}
+\cs_new_protected_nopar:Nn \@@_forward_keys:nn {
+% \end{macrocode}
+%
+% \begin{itemize}
+% \item |#1| (clist): destination prefixes
+% \item |#2| (clist): keys
+% \end{itemize}
+%
+% \begin{macrocode}
+ \clist_map_inline:nn {#2} {
+ \@@_make_forwarded_key:nnnn {} {} { #1 } { ##1 }
+ }
+}
+
+\cs_new:Nn \@@_create_append_reset:nn {
+% \end{macrocode}
+%
+% \begin{itemize}
+% \item |#1| (tl): key basename
+% \item |#2| (var): suffix of variable to store options into
+% \end{itemize}
+%
+% \begin{macrocode}
+ \tl_new:c { l_@@_graph_#2_tl }
+ \@@_keys_define:nn { graph } {
+ #1 .value_required:n = true,
+ #1 .code:n = \tl_put_right:cn
+ { l_@@_graph_#2_tl }
+ { ##1, },
+
+ #1/reset .value_forbidden:n = true,
+ #1/reset .code:n = \tl_clear:c
+ { l_@@_graph_#2_tl },
+ }
+}
+
+\cs_new:Nn \@@_DO:nn { \@@_create_append_reset:nn {#1}{options_#2} }
+
+\cs_new:Nn \@@_define_unit:nn {
+% \end{macrocode}
+%
+% \begin{itemize}
+% \item |#1| (tl): unit name (plural)
+% \item |#2| (tl): graph type
+% \end{itemize}
+%
+% \begin{macrocode}
+ \@@_DO:nn { #2/#1/axis } { #2_#1axis }
+ \@@_keys_define:nn { graph } {
+ #2/#1 .code:n = {
+ \tl_set:cn {l_@@_graph_#2_unit_tl} { #1 }
+ \quark_if_no_value:nF { ##1 } {
+ \@@_setup:nn { graph }{ #2/#1/label = { ##1 } }
+ }
+ },
+ #2/#1 .default:n = \q_no_value,
+
+ #2/#1/label .meta:n = { #2/#1/axis = { label = { ##1 } } },
+ #2/#1/label .value_required:n = true,
+
+ #2/#1/format .code:n = {
+ \cs_set_protected:cn
+ { @@_graph_#2_#1_format:n }
+ { ##1 }
+ },
+ #2/#1/format .value_required:n = true,
+
+ #2/#1/margin .tl_set:c = l_@@_graph_#2_#1_vmargin_tl,
+ #2/#1/margin .value_required:n = true,
+ }
+}
+
+\@@_DO:nn { picture } { pic }
+\@@_DO:nn { axissystem } { system }
+
+\@@_DO:nn { histogram/areas/style } { areas }
+\@@_DO:nn { histogram/legend/options } { legend }
+
+\clist_map_inline:nn { histogram, cumulative, comb } {
+ \@@_define_unit:nn { counts } { #1 }
+ \@@_define_unit:nn { frequencies } { #1 }
+ \@@_DO:nn { #1/style } { #1 }
+ \@@_DO:nn { #1/values/axis } { #1_xaxis }
+ \@@_keys_define:nn { graph/#1 } {
+ values/margin .value_required:n = true,
+ values/margin .tl_set:c = l_@@_graph_#1_hmargin_tl,
+
+ values/label .meta:n = { values/axis = { label = { ##1 } } },
+ values/label .value_required:n = true,
+
+ values/format .code:n = { \cs_set_protected:cn
+ {@@_graph_#1_values_format:n} { ##1 }
+ },
+ values/format .value_required:n = true,
+
+ frequencies/format/real .meta:n = {
+ frequencies/format = {
+ \num[round-mode=places,round-precision=##1]{####1}
+ }
+ },
+ frequencies/format/real .default:n = 1,
+
+ frequencies/format/percent .meta:n = {
+ frequencies/format = {
+ \SI[round-mode=places,round-precision=##1]{
+ \fp_eval:n{####1*100}
+ }{\percent}
+ }
+ },
+ frequencies/format/percent .default:n = 1,
+ }
+ \@@_make_forwarded_key:nnnn {#1/values}{}{label}{}
+ \clist_map_inline:nn { axis, axis/reset, label, margin, format } {
+ \@@_make_forwarded_key:nnnn {#1}{x}{values}{##1}
+ \@@_make_forwarded_key:nnnn {#1}{y}{counts, frequencies}{##1}
+ }
+}
+
+\cs_undefine:N \@@_DO:nn
+\cs_undefine:N \@@_define_unit:nnn
+
+\@@_forward_keys:nn { histogram, cumulative, comb } {
+ values, values/label, values/margin, values/format,
+ values/axis, values/axis/reset,
+ x/label, x/axis, x/axis/reset, x/margin, x/format,
+ counts, counts/label, counts/margin, counts/format,
+ counts/axis, counts/axis/reset,
+ frequencies, frequencies/label, frequencies/margin,
+ frequencies/format, frequencies/format/real, frequencies/format/percent,
+ frequencies/axis, frequencies/axis/reset,
+ y/label, y/axis, y/axis/reset, y/margin, y/format,
+ style, style/reset
+}
+
+\@@_create_append_reset:nn { tikzinfo' } { userpreinfo }
+\@@_create_append_reset:nn { tikzinfo } { userpostinfo }
+
+\cs_undefine:N \@@_forward_keys:nn
+\cs_undefine:N \@@_make_forwarded_key:nnnn
+\cs_undefine:N \@@_create_append_reset:nn
+
+\@@_keys_define:nn { graph } {
+ showonly .value_required:n = true,
+ showonly .code:n = \@@_setshow:n{#1},
+
+ height .value_required:n = true,
+ height .meta:n = { axissystem = { height = { #1 } } },
+
+ width .value_required:n = true,
+ width .meta:n = { axissystem = { width = { #1 } } },
+
+ cumulative .bool_set:N = \l_@@_graph_cumulative_bool,
+ cumulative .default:n = true,
+
+ decreasing .bool_set:N = \l_@@_graph_decreasing_bool,
+ decreasing .default:n = true,
+
+ histogram/areas .bool_set:N = \l_@@_graph_areas_bool,
+ histogram/areas .default:n = true,
+
+ histogram/legend/label .value_required:n = true,
+ histogram/legend/label .meta:n = {
+ histogram/legend/options = {label={#1}} },
+
+ histogram/legend/area .value_required:n = true,
+ histogram/legend/area .meta:n = {
+ histogram/legend/h = (#1)/\width },
+
+ histogram/legend .value_required:n = true,
+ histogram/legend .code:n = {
+ \@@_setup:nn { graph / histogram/legend } {
+ #1
+ }
+ },
+
+ histogram/y/autostep .value_required:n = true,
+ histogram/y/autostep .meta:n = {
+ histogram/counts/autostep = {#1},
+ histogram/frequencies/autostep = {#1},
+ histogram/legend/area = {#1},
+ },
+}
+\tl_map_inline:nn {xywh} {
+ \@@_keys_define:nn { graph / histogram / legend } {
+ #1 .value_required:n = true,
+ #1 .tl_set:c = {l_@@_graph_legend_#1_tl},
+ }
+}
+\clist_map_inline:nn { counts, frequencies } {
+ \@@_keys_define:nn { graph/histogram/#1 } {
+ autostep .default:n = 1,
+ autostep .meta:n = { axis = {
+ grid = { compute~step =
+ \group_begin:
+ \tl_set:Nx \total { \fp_to_decimal:N \l_@@_total_fp }
+ \fp_gset:Nn \g_tmpa_fp { ##1 }
+ \group_end:
+ \tl_set:Nx \tikz@lib@dv@step {
+ \fp_eval:n {\g_tmpa_fp / \g_@@_graph_xstep_fp }
+ }
+ }
+ }},
+ }
+}
+
+\@@_setup:nn { graph }{
+ width = 0.75\columnwidth,
+ cumulative = false,
+ decreasing = false,
+
+ values/axis = {
+ label = \valuename,
+ ticks~and~grid={many, integer~minor~steps}
+ },
+ values/margin = \xstep / 2,
+ values/format = \num{#1},
+
+ y/margin = \range/10,
+
+ counts/format = { \num{#1} },
+ counts/axis = { ticks~and~grid={
+ many, int~about~strategy, integer~minor~steps,
+ } },
+ comb/counts/label = \countname,
+ cumulative/counts/label = \ccountname,
+
+ frequencies/format/percent,
+ frequencies/axis = { ticks~and~grid=many },
+ comb/frequencies/label = \freqname,
+ cumulative/frequencies/label = \cfreqname,
+
+ histogram/y/axis/reset,
+ histogram/y/axis = {ticks = none},
+ histogram/y/autostep = 1,
+ histogram/legend = { x=, y=0, w=\xstep },
+ histogram/style = { semithick, black, fill=black, fill~opacity=0.1 },
+ histogram/areas,
+ histogram/areas/style = { auto, font=\small },
+
+ comb/style = { ultra~thick },
+
+ counts,
+
+ picture = {
+ baseline = (current~bounding~box.center),
+ label~position = right,
+ },
+}
+
+\tl_const:Nn \c_@@_graph_savexstep_tl {
+ grid = { compute~step/.append = {
+ \cs_if_eq:NNF \tikz@lib@dv@step \relax {
+ \pgfkeysgetvalue
+ {/tikz/data~visualization/minor~steps~between~steps}
+ \l_tmpa_tl
+ \fp_gset:Nn \g_@@_graph_xstep_fp {
+ \tikz@lib@dv@step
+ / (\fp_max:nn{0\l_tmpa_tl + 1}{1})
+ }
+ }
+ }}
+}
+% \end{macrocode}
+%
+% To detect that the user didn't set |minor steps between steps| himself after
+% having used |integer minor steps| (which can be a default setting), we add a
+% handler to the key that sets its value but also empties
+% \cs{l_@@_graph_maxminor_tl} so that we do not overwrite anything.
+%
+% \begin{macrocode}
+\tl_new:N \l_@@_graph_maxminor_tl
+\int_new:N \l_@@_graph_minorsteps_int
+\fp_new:N \l_@@_graph_ims_step_fp
+\fp_new:N \l_@@_graph_ims_range_fp
+\fp_new:N \l_@@_graph_ims_threshold_fp
+\tikzdatavisualizationset{
+integer~minor~steps/.style={
+ /utils/exec = \tl_set:Nn \l_@@_graph_maxminor_tl {#1},
+ minor~steps~between~steps/.code=
+ \tl_clear:N \l_@@_graph_maxminor_tl
+ \pgfkeyssetvalue
+ {/tikz/data~visualization/minor~steps~between~steps}
+ {##1} ,
+ compute~step/.append = {
+ \tl_set_eq:NN \l_tmpa_tl \tikz@lib@dv@step
+ \tl_if_empty:NT \l_@@_graph_maxminor_tl {
+ \tl_set_eq:NN \l_tmpa_tl \relax
+ }
+ \tl_if_eq:NNF \l_tmpa_tl \relax {
+ \fp_set:Nn \l_@@_graph_ims_step_fp { \l_tmpa_tl }
+ \tikz@lib@dv@mapper.get~in~range~interval()
+ \pgfdvinrangeinterval.get~min~and~max()
+ \pgfdvmathexitbyscientificformat \l_tmpa_tl \pgfdvmin
+ \pgfdvmathexitbyscientificformat \l_tmpb_tl \pgfdvmax
+ \fp_set:Nn \l_@@_graph_ims_range_fp { \l_tmpb_tl - \l_tmpa_tl }
+ \fp_set:Nn \l_@@_graph_ims_threshold_fp {
+ \fp_max:nn {
+ \l_@@_graph_ims_step_fp * (\l_@@_graph_maxminor_tl)
+ }{
+ \l_@@_graph_ims_range_fp
+ }
+ }
+ \int_set:Nn \l_@@_graph_minorsteps_int
+ { \fp_to_int:N \l_@@_graph_ims_step_fp }
+ \bool_while_do:nn {
+ \fp_compare_p:n {
+ \l_@@_graph_minorsteps_int * \l_@@_graph_ims_range_fp
+ > \l_@@_graph_ims_threshold_fp
+ }
+ }{
+ \tl_map_inline:nn {{2}{5}{10}} {
+ \fp_compare:nF {
+ \l_@@_graph_minorsteps_int * \l_@@_graph_ims_range_fp
+ > \l_@@_graph_ims_threshold_fp * ##1
+ }{
+ \int_compare:nT {
+ \int_mod:nn{\l_@@_graph_minorsteps_int}{##1} = 0
+ }{
+ \int_set:Nn
+ \l_@@_graph_minorsteps_int
+ { \l_@@_graph_minorsteps_int / ##1 }
+ \tl_map_break:
+ }
+ }
+ }
+ \fp_compare:nT {
+ \l_@@_graph_minorsteps_int * \l_@@_graph_ims_range_fp
+ > \l_@@_graph_ims_threshold_fp
+ }{
+ \tl_map_inline:nn {{3}{2}{5}{\l_@@_graph_minorsteps_int}} {
+ \int_compare:nT {
+ \int_mod:nn{\l_@@_graph_minorsteps_int}{##1} = 0
+ }{
+ \int_set:Nn
+ \l_@@_graph_minorsteps_int
+ { \l_@@_graph_minorsteps_int / ##1 }
+ \tl_map_break:
+ }
+ }
+ }
+ }
+ \int_compare:nNnTF \l_@@_graph_minorsteps_int > 1 {
+ \use:x { \exp_not:n {
+ \pgfkeyssetvalue
+ {/tikz/data~visualization/minor~steps~between~steps}
+ }
+ { \int_eval:n {\l_@@_graph_minorsteps_int-1} }
+ }
+ }{
+ \pgfkeyssetvalue
+ {/tikz/data~visualization/minor~steps~between~steps}
+ {}
+ }
+ \tl_clear:N \l_@@_graph_maxminor_tl
+ }
+ }
+},
+integer~minor~steps/.default=50,
+}
+% \end{macrocode}
+%
+% First define a lot of variables:
+%
+% \begin{macrocode}
+\bool_new:N \l_@@_graph_allranges_bool
+
+\fp_new:N \l_@@_graph_curvalue_fp
+\fp_new:N \l_@@_graph_curheight_fp
+\fp_new:N \l_@@_graph_prevheight_fp
+\fp_new:N \l_@@_graph_maxheight_fp
+\fp_new:N \l_@@_graph_minvalue_fp
+\fp_new:N \l_@@_graph_maxvalue_fp
+\fp_new:N \g_@@_graph_xstep_fp
+\int_new:N \g_@@_graph_last_int
+
+\tl_new:N \l_@@_graph_tikzdata_tl
+\tl_new:N \l_@@_graph_tikzinfo_tl
+\clist_new:N \l_@@_graph_tikzincludex_clist
+\clist_new:N \l_@@_graph_tikzincludey_clist
+\tl_new:N \l_@@_graph_tikzpicture_tl
+% \end{macrocode}
+%
+% No scale for counts, divide by total for freqs
+%
+% \begin{macrocode}
+\fp_new:N \l_@@_graph_scale_fp
+\fp_new:N \l_@@_graph_counts_scale_fp
+\fp_new:N \l_@@_graph_frequencies_scale_fp
+\fp_set:Nn \l_@@_graph_counts_scale_fp { 1 }
+
+
+\NewDocumentCommand \StatsGraph { +O{} +m +O{} } {
+ \group_begin:
+ \int_gincr:N \g_@@_graph_last_int
+% \end{macrocode}
+%
+% Read saved x step, for automatic margin and histogram y step
+%
+% \begin{macrocode}
+ \tl_set:Nx \l_tmpa_tl {
+ \exp_not:n { g_@@_graph_xstep_ }
+ \int_use:N \g_@@_graph_last_int
+ \exp_not:n { _tl }
+ }
+ \tl_if_exist:cTF { \l_tmpa_tl } {
+ \fp_gset:Nn \g_@@_graph_xstep_fp
+ { \tl_use:c {\l_tmpa_tl} }
+ }{
+ \fp_gset:Nn \g_@@_graph_xstep_fp { \c_one }
+ }
+% \end{macrocode}
+%
+% Handle optional settings
+%
+% \begin{macrocode}
+ \@@_setup:nn { graph } { #1, #3 }
+% \end{macrocode}
+%
+% Get the data inline or from a variable
+%
+% \begin{macrocode}
+ \tl_if_single:nTF { #2 } {
+% \end{macrocode}
+%
+% Generate meaningful error by using the non-existent variable.
+%
+% \begin{macrocode}
+ \cs_if_exist:NF #2 { #2 }
+ \tl_set_eq:NN \l_@@_data_tl #2
+ }{
+ \tl_set:Nn \l_@@_data_tl { #2 }
+ }
+% \end{macrocode}
+%
+% Zero the maximum height in the graph, and setup min and max values.
+%
+% \begin{macrocode}
+ \fp_zero:N \l_@@_graph_maxheight_fp
+ \fp_set:Nn \l_@@_graph_minvalue_fp {inf}
+ \fp_set:Nn \l_@@_graph_maxvalue_fp {-inf}
+% \end{macrocode}
+%
+% The following loop does 2 things:
+% \begin{itemize}
+% \item Counting the number of ranges and the total population count
+% \item Detecting whether the ranges are intervals or single numbers
+% \end{itemize}
+%
+% \begin{macrocode}
+ \fp_zero:N \l_@@_total_fp
+ \int_zero:N \l_@@_nbvals_int
+ \bool_set_true:N \l_@@_graph_allranges_bool
+ \keyval_parse:NNV
+ \@@_graph_prepare:n
+ \@@_graph_prepare:nn
+ \l_@@_data_tl
+% \end{macrocode}
+%
+% The remainder is different whether we do histogram, cumulative, or comb
+%
+% \begin{macrocode}
+ \tl_clear:N \l_@@_graph_tikzdata_tl
+ \tl_clear:N \l_@@_graph_tikzinfo_tl
+ \int_zero:N \l_@@_currange_int
+ \bool_if:NTF \l_@@_graph_allranges_bool {
+ \bool_if:NTF \l_@@_graph_cumulative_bool {
+% \end{macrocode}
+%
+% We draw a cumulative distribution function
+%
+% \begin{macrocode}
+ \@@_graph_dopicture_cumulative:
+ }{
+% \end{macrocode}
+%
+% We draw an histogram
+%
+% \begin{macrocode}
+ \@@_graph_dopicture_hist:
+ }
+ }{
+% \end{macrocode}
+%
+% We draw a comb graph
+%
+% \begin{macrocode}
+ \@@_graph_dopicture_comb:
+ }
+% \end{macrocode}
+%
+% Write xstep info to aux file
+%
+% \begin{macrocode}
+ \iow_now:Nx \@auxout {
+ \exp_not:n {
+ \ExplSyntaxOn
+ \tl_gset:cn
+ }
+ {
+ \exp_not:n {g_@@_graph_xstep_}
+ \int_use:N \g_@@_graph_last_int
+ \exp_not:n {_tl}
+ }
+ {
+ \fp_to_decimal:N \g_@@_graph_xstep_fp
+ }
+ \exp_not:n {
+ \ExplSyntaxOff
+ }
+ }
+ \group_end:
+}
+% \end{macrocode}
+%
+% First pass
+%
+% \begin{macrocode}
+\cs_new_protected_nopar:Nn \@@_graph_prepare:n {
+ \@@_graph_prepare:nn { #1 } { 1 }
+}
+\cs_new_protected_nopar:Nn \@@_graph_prepare:nn {
+ \int_incr:N \l_@@_nbvals_int
+ \fp_add:Nn \l_@@_total_fp { #2 }
+ \exp_args:Nx \tl_if_eq:nnF { \tl_head:n {#1} }{ \IN } {
+ \bool_set_false:N \l_@@_graph_allranges_bool
+ }
+}
+% \end{macrocode}
+%
+% Shared utility functions
+%
+% \begin{macrocode}
+\cs_new_protected_nopar:Nn \@@_graph_addpoint:nnn {
+ \tl_put_right:Nx \l_@@_graph_tikzdata_tl {
+ \exp_not:N \pgfkeys {
+ \exp_not:n { /data~point/name = #1 }
+ \int_use:N \l_@@_currange_int
+ \exp_not:n { ,/data~point/x = } \fp_eval:n { #2 }
+ \exp_not:n { ,/data~point/y = } \fp_eval:n { #3 }
+ }
+ \exp_not:n { \pgfdatapoint }
+ }
+}
+\cs_new_protected_nopar:Nn \@@_graph_outlier: {
+ \tl_put_right:Nn \l_@@_graph_tikzdata_tl {
+ \pgfkeys{/data~point/outlier = true}
+ \pgfdatapoint
+ \pgfkeys{/data~point/outlier = }
+ }
+}
+\cs_new_protected_nopar:Nn \@@_graph_setup:n {
+ \fp_set_eq:Nc \l_@@_graph_hmargin_tl {l_@@_graph_#1_hmargin_tl}
+ \tl_set_eq:Nc \l_@@_graph_unit_tl { l_@@_graph_#1_unit_tl }
+ \tl_set_eq:Nc \l_@@_graph_vmargin_tl
+ {l_@@_graph_#1_ \l_@@_graph_unit_tl _vmargin_tl}
+ \tl_set_eq:Nc
+ \l_@@_graph_options_yaxis_tl
+ {l_@@_graph_options_#1_ \l_@@_graph_unit_tl axis_tl}
+ \cs_set_eq:Nc
+ \@@_graph_y_format:n
+ {@@_graph_#1_ \l_@@_graph_unit_tl _format:n}
+ \cs_set_eq:Nc
+ \@@_graph_values_format:n
+ {@@_graph_#1_values_format:n}
+ \fp_set_eq:NN
+ \l_@@_graph_frequencies_scale_fp
+ \l_@@_total_fp
+ \fp_set_eq:Nc
+ \l_@@_graph_scale_fp
+ {l_@@_graph_ \l_@@_graph_unit_tl _scale_fp}
+}
+\cs_new_protected_nopar:Nn \@@_graph_update_minmaxval:NN {
+ \fp_set:Nn \l_@@_graph_minvalue_fp {
+ min( \l_@@_graph_minvalue_fp, #1 )
+ }
+ \fp_set:Nn \l_@@_graph_maxvalue_fp {
+ max( \l_@@_graph_maxvalue_fp, #2 )
+ }
+}
+\cs_new_protected_nopar:Nn \@@_graph_update_maxheight: {
+ \fp_set:Nn \l_@@_graph_maxheight_fp {
+ max( \l_@@_graph_maxheight_fp , \l_@@_graph_curheight_fp )
+ }
+}
+\cs_new_protected_nopar:Nn \@@_graph_handle_hmargin: {
+ \group_begin:
+ \tl_set:Nx \min { \fp_to_decimal:N \l_@@_graph_minvalue_fp }
+ \tl_set:Nx \max { \fp_to_decimal:N \l_@@_graph_maxvalue_fp }
+ \tl_set:Nx \range {
+ \fp_eval:n { \l_@@_graph_maxvalue_fp - \l_@@_graph_minvalue_fp }
+ }
+ \tl_set:Nx \xstep { \fp_to_decimal:N \g_@@_graph_xstep_fp }
+ \exp_args:NNV \fp_gset:Nn \g_tmpa_fp \l_@@_graph_hmargin_tl
+ \group_end:
+ \clist_put_right:Nx \l_@@_graph_tikzincludex_clist {
+ \fp_eval:n { \l_@@_graph_minvalue_fp - \g_tmpa_fp }
+ }
+ \clist_put_right:Nx \l_@@_graph_tikzincludex_clist {
+ \fp_eval:n { \l_@@_graph_maxvalue_fp + \g_tmpa_fp }
+ }
+}
+\cs_new_protected_nopar:Nn \@@_graph_handle_vmargin: {
+ \group_begin:
+ \tl_set:Nn \min { 0 }
+ \tl_set:Nx \max { \fp_to_decimal:N \l_@@_graph_maxheight_fp }
+ \tl_set_eq:NN \range \max
+ \exp_args:NNV \fp_gset:Nn \g_tmpa_fp \l_@@_graph_vmargin_tl
+ \group_end:
+ \clist_put_right:Nx \l_@@_graph_tikzincludey_clist {
+ \fp_eval:n { \l_@@_graph_maxheight_fp + \g_tmpa_fp }
+ }
+}
+% \end{macrocode}
+%
+% Second pass, histogram
+%
+% \begin{macrocode}
+\cs_new_protected_nopar:Nn \@@_graph_dopicture_hist: {
+ \@@_graph_setup:n {histogram}
+% \end{macrocode}
+%
+% Loop through the list again to fill tikz data and labels
+%
+% \begin{macrocode}
+ \keyval_parse:NNV
+ \@@_graph_make_hist:n
+ \@@_graph_make_hist:nn
+ \l_@@_data_tl
+% \end{macrocode}
+%
+% Maybe add a legend
+%
+% \begin{macrocode}
+ \tl_if_empty:NF \l_@@_graph_legend_x_tl {
+ \group_begin:
+ \tl_set:Nx \min { \fp_to_decimal:N \l_@@_graph_minvalue_fp }
+ \tl_set:Nx \max { \fp_to_decimal:N \l_@@_graph_maxvalue_fp }
+ \tl_set:Nx \range {
+ \fp_eval:n { \l_@@_graph_maxvalue_fp - \l_@@_graph_minvalue_fp }
+ }
+ \tl_set:Nx \xstep { \fp_to_decimal:N \g_@@_graph_xstep_fp }
+ \exp_args:NNV \fp_gset:Nn \g_tmpa_fp \l_@@_graph_legend_x_tl
+ \exp_args:NNV \fp_gset:Nn \g_tmpb_fp \l_@@_graph_legend_w_tl
+ \group_end:
+ \tl_set:Nx \l_@@_graph_legend_x_tl { \fp_to_decimal:N \g_tmpa_fp }
+ \tl_set:Nx \l_@@_graph_legend_w_tl { \fp_to_decimal:N \g_tmpb_fp }
+
+ \group_begin:
+ \tl_set:Nn \min { 0 }
+ \tl_set:Nx \max { \fp_to_decimal:N \l_@@_graph_maxheight_fp }
+ \tl_set_eq:NN \range \max
+ \tl_set:Nx \xstep { \fp_to_decimal:N \g_@@_graph_xstep_fp }
+ \tl_set_eq:NN \width \l_@@_graph_legend_w_tl
+ \tl_set:Nx \total { \fp_to_decimal:N \l_@@_total_fp }
+ \exp_args:NNV \fp_gset:Nn \g_tmpb_fp \l_@@_graph_legend_h_tl
+ \tl_set:Nx \height { \fp_to_decimal:N \g_tmpb_fp }
+ \exp_args:NNV \fp_gset:Nn \g_tmpa_fp \l_@@_graph_legend_y_tl
+ \group_end:
+
+ \tl_put_right:Nx \l_@@_graph_tikzinfo_tl {
+ \exp_not:n { \path (visualization~cs }
+ \token_to_str:N : \exp_not:n { x= }
+ \exp_not:V \l_@@_graph_legend_x_tl
+ \exp_not:n { ,y= }
+ \fp_to_decimal:N \g_tmpa_fp
+ \exp_not:n { ) coordinate (LSW) (visualization~cs }
+ \token_to_str:N : \exp_not:n { x= }
+ \fp_eval:n {
+ \l_@@_graph_legend_x_tl +
+ \l_@@_graph_legend_w_tl
+ }
+ \exp_not:n { ,y= }
+ \fp_eval:n { \g_tmpa_fp + \g_tmpb_fp }
+ \exp_not:n { ) coordinate (LNE);
+ \node[ fit=(LSW)~(LNE), draw, inner~sep=0pt,
+ }
+ \exp_not:V \l_@@_graph_options_histogram_tl
+ \exp_not:N ,
+ \exp_not:V \l_@@_graph_options_legend_tl
+ \exp_not:n { ] {}; }
+ }
+ }
+% \end{macrocode}
+%
+% Create the picture itself
+%
+% \begin{macrocode}
+ \@@_graph_handle_hmargin:
+ \@@_graph_handle_vmargin:
+ \tl_set:Nx \l_@@_graph_tikzpicture_tl {
+ \exp_not:n { \begin{tikzpicture}[ }
+ \exp_not:V \l_@@_graph_options_pic_tl
+ \exp_not:n { ] \datavisualization
+ [scientific~axes = } {
+ \exp_not:V
+ \l_@@_graph_options_system_tl
+ }
+ \exp_not:n { , x~axis = } {
+ \exp_not:n { include~value/.list = } {
+ \exp_not:V \l_@@_graph_tikzincludex_clist
+ }
+ \exp_not:n { , ticks = { tick~typesetter/.code = {
+ $\@@_graph_values_format:n { \fp_eval:n{####1} }$ }}, }
+ \exp_not:V
+ \l_@@_graph_options_histogram_xaxis_tl
+ \exp_not:n { , }
+ \exp_not:V
+ \c_@@_graph_savexstep_tl
+ }
+ \exp_not:n { , y~axis = } {
+ \exp_not:n { include~value/.list = } {
+ \exp_not:V \l_@@_graph_tikzincludey_clist
+ }
+ \exp_not:n { , }
+ \exp_not:V
+ \l_@@_graph_options_yaxis_tl
+ }
+ \exp_not:n { , visualize~as~line = histogram,
+ histogram = } {
+ \exp_not:n { polygon, style = } {
+ \exp_not:n { every~path/.append~style = } {
+ \exp_not:V \l_@@_graph_options_histogram_tl
+ } } }
+ \exp_not:n { ] data [set = histogram, format = TeX~code] } {
+ \exp_not:V \l_@@_graph_tikzdata_tl
+ }
+ \exp_not:n { info' } {
+ \exp_not:V \l_@@_graph_userpreinfo_tl
+ }
+ \exp_not:n { info } {
+ \exp_not:V \l_@@_graph_tikzinfo_tl
+ \exp_not:V \l_@@_graph_userpostinfo_tl
+ }
+ \exp_not:n { ; \end{tikzpicture} }
+ }
+ \tl_use:N \l_@@_graph_tikzpicture_tl
+}
+\cs_new_protected_nopar:Nn \@@_graph_make_hist:n {
+ \@@_graph_make_hist:nn { #1 } { 1 }
+}
+\cs_new_protected_nopar:Nn \@@_graph_make_hist:nn {
+ \int_incr:N \l_@@_currange_int
+% \end{macrocode}
+%
+% Extract interval data
+%
+% \begin{macrocode}
+ \@@_parse_range:w #1 \q_stop
+% \end{macrocode}
+%
+% Compute rectangle height
+%
+% \begin{macrocode}
+ \fp_set:Nn \l_@@_graph_curheight_fp {
+ (#2) / ( \l_@@_range_max_fp -
+ \l_@@_range_min_fp)
+ }
+% \end{macrocode}
+%
+% Add margins to axes
+%
+% \begin{macrocode}
+ \@@_graph_update_minmaxval:NN \l_@@_range_min_fp \l_@@_range_max_fp
+ \@@_graph_update_maxheight:
+% \end{macrocode}
+%
+% Check if we want to show this element
+%
+% \begin{macrocode}
+ \@@_set_if_shown:N \l_tmpa_bool
+% \end{macrocode}
+%
+% Append the rectangle to the TikZ datavisualization content
+%
+% \begin{macrocode}
+ \@@_graph_addpoint:nnn { SW }
+ { \l_@@_range_min_fp }
+ { 0 }
+ \bool_if:NF \l_tmpa_bool {
+% \end{macrocode}
+%
+% Add an outlier point to inhibit the rectangle drawing
+%
+% \begin{macrocode}
+ \@@_graph_outlier:
+ }
+ \@@_graph_addpoint:nnn { NW }
+ { \l_@@_range_min_fp }
+ { \l_@@_graph_curheight_fp }
+ \bool_if:NF \l_tmpa_bool { \@@_graph_outlier: }
+ \@@_graph_addpoint:nnn { NE }
+ { \l_@@_range_max_fp }
+ { \l_@@_graph_curheight_fp }
+ \bool_if:NF \l_tmpa_bool { \@@_graph_outlier: }
+ \@@_graph_addpoint:nnn { SE }
+ { \l_@@_range_max_fp }
+ { 0 }
+ \bool_if:NT \l_tmpa_bool {
+% \end{macrocode}
+%
+% Maybe append a freq or count label on middle top of the rect
+%
+% \begin{macrocode}
+ \bool_if:NT \l_@@_graph_areas_bool {
+ \@@_graph_addlabel:nn
+ \@@_graph_y_format:n
+ { \fp_eval:n {#2 / \l_@@_graph_scale_fp} }
+ }
+ }
+ \@@_graph_outlier:
+}
+\cs_new_protected_nopar:Nn \@@_graph_addlabel:nn {
+ \tl_put_right:Nx \l_@@_graph_tikzinfo_tl {
+ \exp_not:n { \path (NW }
+ \int_use:N \l_@@_currange_int
+ \exp_not:n { ) -- node[ }
+ \exp_not:V \l_@@_graph_options_areas_tl
+ \exp_not:N ] {
+ \exp_not:n { $ #1 } { #2 } \exp_not:N $
+ } \exp_not:n { (NE }
+ \int_use:N \l_@@_currange_int
+ \exp_not:n { ); }
+ }
+}
+% \end{macrocode}
+%
+% second pass, comb
+%
+% \begin{macrocode}
+\cs_new_protected:Nn \@@_graph_dopicture_comb: {
+ \@@_graph_setup:n {comb}
+% \end{macrocode}
+%
+% Loop through the list again to fill tikz data and labels
+%
+% \begin{macrocode}
+ \keyval_parse:NNV
+ \@@_graph_make_comb:n
+ \@@_graph_make_comb:nn
+ \l_@@_data_tl
+% \end{macrocode}
+%
+% Create the picture itself
+%
+% \begin{macrocode}
+ \@@_graph_handle_hmargin:
+ \@@_graph_handle_vmargin:
+ \tl_set:Nx \l_@@_graph_tikzpicture_tl {
+ \exp_not:n { \begin{tikzpicture}[ }
+ \exp_not:V \l_@@_graph_options_pic_tl
+ \exp_not:n { ] \datavisualization
+ [scientific~axes = } {
+ \exp_not:V
+ \l_@@_graph_options_system_tl
+ }
+ \exp_not:n { , x~axis = } {
+ \exp_not:n { include~value/.list = } {
+ \exp_not:V \l_@@_graph_tikzincludex_clist
+ }
+ \exp_not:n { , ticks = { tick~typesetter/.code = {
+ $\@@_graph_values_format:n { \fp_eval:n{####1} }$ }}, }
+ \exp_not:V
+ \l_@@_graph_options_comb_xaxis_tl
+ \exp_not:n { , }
+ \exp_not:V
+ \c_@@_graph_savexstep_tl
+ }
+ \exp_not:n { , y~axis = } {
+ \exp_not:n { include~value/.list = } {
+ \exp_not:V \l_@@_graph_tikzincludey_clist
+ }
+ \exp_not:n { , }
+ \exp_not:n { , ticks = { tick~typesetter/.code = {
+ $\@@_graph_y_format:n { \fp_eval:n{####1} }$ }}, }
+ \exp_not:V
+ \l_@@_graph_options_yaxis_tl
+ }
+ \exp_not:n { , visualize~as~line = bar~graph,
+ bar~graph = } {
+ \exp_not:n { style = } {
+ \exp_not:n { every~path/.append~style = } {
+ \exp_not:V \l_@@_graph_options_comb_tl
+ } } }
+ \exp_not:n { ] data [set = bar~graph, format = TeX~code] } {
+ \exp_not:V \l_@@_graph_tikzdata_tl
+ }
+ \exp_not:n { info' } {
+ \exp_not:V \l_@@_graph_userpreinfo_tl
+ }
+ \exp_not:n { info } {
+ \exp_not:V \l_@@_graph_tikzinfo_tl
+ \exp_not:V \l_@@_graph_userpostinfo_tl
+ }
+ \exp_not:n { ; \end{tikzpicture} }
+ }
+ \tl_use:N \l_@@_graph_tikzpicture_tl
+}
+\cs_new_protected_nopar:Nn \@@_graph_make_comb:n {
+ \@@_graph_make_comb:nn { #1 } { 1 }
+}
+\cs_new_protected_nopar:Nn \@@_graph_make_comb:nn {
+ \int_incr:N \l_@@_currange_int
+% \end{macrocode}
+%
+% Set value
+%
+% \begin{macrocode}
+ \fp_set:Nn \l_@@_graph_curvalue_fp {
+ #1
+ }
+% \end{macrocode}
+%
+% Compute height
+%
+% \begin{macrocode}
+ \fp_set:Nn \l_@@_graph_curheight_fp {
+ (#2) / \l_@@_graph_scale_fp
+ }
+% \end{macrocode}
+%
+% Add margins to axes
+%
+% \begin{macrocode}
+ \@@_graph_update_minmaxval:NN
+ \l_@@_graph_curvalue_fp \l_@@_graph_curvalue_fp
+ \@@_graph_update_maxheight:
+% \end{macrocode}
+%
+% Check if we want to show this element
+%
+% \begin{macrocode}
+ \@@_set_if_shown:N \l_tmpa_bool
+% \end{macrocode}
+%
+% Append the bar to the TikZ datavisualization content
+%
+% \begin{macrocode}
+ \@@_graph_addpoint:nnn { S }
+ { \l_@@_graph_curvalue_fp }
+ { 0 }
+ \bool_if:NF \l_tmpa_bool {
+% \end{macrocode}
+%
+% add an outlier to inhibit the bar drawing
+%
+% \begin{macrocode}
+ \@@_graph_outlier:
+ }
+ \@@_graph_addpoint:nnn { N }
+ { \l_@@_graph_curvalue_fp }
+ { \l_@@_graph_curheight_fp }
+ \@@_graph_outlier:
+}
+% \end{macrocode}
+%
+% second pass, cumulative
+%
+% \begin{macrocode}
+\cs_new_protected_nopar:Nn \@@_graph_dopicture_cumulative: {
+ \@@_graph_setup:n {cumulative}
+% \end{macrocode}
+%
+% Increasing or decreasing starting point
+%
+% \begin{macrocode}
+ \bool_if:NTF \l_@@_graph_decreasing_bool {
+ \fp_set_eq:NN \l_@@_curtotal_fp
+ \l_@@_total_fp
+ }{
+ \fp_zero:N \l_@@_curtotal_fp
+ }
+ \fp_set:Nn \l_@@_graph_curheight_fp {
+ \l_@@_curtotal_fp
+ / \l_@@_graph_scale_fp
+ }
+ \@@_graph_update_maxheight:
+% \end{macrocode}
+%
+% Loop through the list again to fill tikz data and labels
+%
+% \begin{macrocode}
+ \keyval_parse:NNV
+ \@@_graph_make_cumulative:n
+ \@@_graph_make_cumulative:nn
+ \l_@@_data_tl
+% \end{macrocode}
+%
+% After the last point we should be piecewise constant, which is the $N+1$-th
+% item for |showonly| purposes. We call \cs{@@_graph_handle_hmargin:} even if we
+% will add actual data in the margin, because that method computes the correct
+% value for the margin from the options.
+%
+% \begin{macrocode}
+ \@@_graph_handle_hmargin:
+ \int_incr:N \l_@@_currange_int
+ \@@_set_if_shown:N \l_tmpa_bool
+ \bool_if:NF \l_tmpa_bool { \@@_graph_outlier: }
+ \@@_graph_addpoint:nnn { E }
+ { \l_@@_graph_maxvalue_fp + \g_tmpa_fp }
+ { \l_@@_graph_curheight_fp }
+% \end{macrocode}
+%
+% Before the first point we should be piecewise constant. We stash the TikZ data
+% away to prepend the first point and maybe an outlier if the segment should be
+% hidden, then append the stashed data. The initial segment is numbered~$0$.
+%
+% \begin{macrocode}
+ \tl_set_eq:NN \l_tmpa_tl \l_@@_graph_tikzdata_tl
+ \tl_clear:N \l_@@_graph_tikzdata_tl
+ \int_zero:N \l_@@_currange_int
+ \@@_graph_addpoint:nnn { B }
+ { \l_@@_graph_minvalue_fp - \g_tmpa_fp }
+ { \l_@@_graph_maxheight_fp - \l_@@_graph_curheight_fp }
+ \@@_set_if_shown:N \l_tmpa_bool
+ \bool_if:NF \l_tmpa_bool { \@@_graph_outlier: }
+ \tl_put_right:NV \l_@@_graph_tikzdata_tl \l_tmpa_tl
+% \end{macrocode}
+%
+% Create the picture itself
+%
+% \begin{macrocode}
+ \@@_graph_handle_vmargin:
+ \tl_set:Nx \l_@@_graph_tikzpicture_tl {
+ \exp_not:n { \begin{tikzpicture}[ }
+ \exp_not:V \l_@@_graph_options_pic_tl
+ \exp_not:n { ] \datavisualization
+ [scientific~axes = } {
+ \exp_not:V
+ \l_@@_graph_options_system_tl
+ }
+ \exp_not:n { , x~axis = } {
+ \exp_not:n { include~value/.list = } {
+ \exp_not:V \l_@@_graph_tikzincludex_clist
+ }
+ \exp_not:n { , ticks = { tick~typesetter/.code = {
+ $\@@_graph_values_format:n { \fp_eval:n{####1} }$ }}, }
+ \exp_not:V
+ \l_@@_graph_options_cumulative_xaxis_tl
+ \exp_not:n { , }
+ \exp_not:V
+ \c_@@_graph_savexstep_tl
+ }
+ \exp_not:n { , y~axis = } {
+ \exp_not:n { include~value/.list = } {
+ \exp_not:V \l_@@_graph_tikzincludey_clist
+ }
+ \exp_not:n { , }
+ \exp_not:n { , ticks = { tick~typesetter/.code = {
+ $\@@_graph_y_format:n { \fp_eval:n{####1} }$ }}, }
+ \exp_not:V
+ \l_@@_graph_options_yaxis_tl
+ }
+ \exp_not:n { , visualize~as~line = cumulative,
+ cumulative = } {
+ \exp_not:n { style = } {
+ \exp_not:n { every~path/.append~style = } {
+ \exp_not:V \l_@@_graph_options_cumulative_tl
+ } } }
+ \exp_not:n { ] data [set = cumulative, format = TeX~code] } {
+ \exp_not:V \l_@@_graph_tikzdata_tl
+ }
+ \exp_not:n { info' } {
+ \exp_not:V \l_@@_graph_userpreinfo_tl
+ }
+ \exp_not:n { info } {
+ \exp_not:V \l_@@_graph_tikzinfo_tl
+ \exp_not:V \l_@@_graph_userpostinfo_tl
+ }
+ \exp_not:n { ; \end{tikzpicture} }
+ }
+ \tl_use:N \l_@@_graph_tikzpicture_tl
+}
+\cs_new_protected_nopar:Nn \@@_graph_make_cumulative:n {
+ \@@_graph_make_hist:nn { #1 } { 1 }
+}
+\cs_new_protected_nopar:Nn \@@_graph_make_cumulative:nn {
+% \end{macrocode}
+%
+% Extract interval data
+%
+% \begin{macrocode}
+ \@@_parse_range:w #1 \q_stop
+% \end{macrocode}
+%
+% Compute running total and new height
+%
+% \begin{macrocode}
+ \fp_set_eq:NN
+ \l_@@_graph_prevheight_fp
+ \l_@@_graph_curheight_fp
+ \bool_if:NTF \l_@@_graph_decreasing_bool {
+ \fp_sub:Nn \l_@@_curtotal_fp { #2 }
+ }{
+ \fp_add:Nn \l_@@_curtotal_fp { #2 }
+ }
+ \fp_set:Nn \l_@@_graph_curheight_fp {
+ \l_@@_curtotal_fp
+ / \l_@@_graph_scale_fp
+ }
+ \@@_graph_update_minmaxval:NN \l_@@_range_min_fp \l_@@_range_max_fp
+ \@@_graph_update_maxheight:
+% \end{macrocode}
+%
+% Add points
+%
+% \begin{macrocode}
+ \int_incr:N \l_@@_currange_int
+ \@@_graph_addpoint:nnn { L }
+ { \l_@@_range_min_fp }
+ { \l_@@_graph_prevheight_fp }
+% \end{macrocode}
+%
+% If we don't want to show this segment, add an outlier so that the
+% line is not drawn.
+%
+% \begin{macrocode}
+ \@@_set_if_shown:N \l_tmpa_bool
+ \bool_if:NF \l_tmpa_bool { \@@_graph_outlier: }
+ \@@_graph_addpoint:nnn { R }
+ { \l_@@_range_max_fp }
+ { \l_@@_graph_curheight_fp }
+% \end{macrocode}
+%
+% TODO: Median and co
+%
+% \begin{macrocode}
+}
+% \end{macrocode}
+%
+% \subsection{Consolitate and sort values}
+%
+% \begin{macrocode}
+\clist_new:N \l_@@_compute_data_clist
+\int_new:N \l_@@_compute_count_int
+
+\fp_new:N \l_@@_compute_curvalue_fp
+\seq_new:N \l_@@_data_seq
+
+\NewDocumentCommand \StatsSortData { +O{} u{=} m +O{} } {
+ \group_begin:
+% \end{macrocode}
+%
+% Handle optional settings (there are none currently)
+% |\@@_setup:nn { rangedata } { #1, #5 }|
+% Get the data inline or from a variable
+%
+% \begin{macrocode}
+ \tl_if_single:nTF { #3 } {
+% \end{macrocode}
+%
+% Generate meaningful error by using the non-existent variable.
+%
+% \begin{macrocode}
+ \cs_if_exist:NF #3 { #3 }
+ \tl_set_eq:NN \l_@@_data_tl #3
+ }{
+ \tl_set:Nn \l_@@_data_tl { #3 }
+ }
+% \end{macrocode}
+%
+% Sort the data according to values.
+% We go through sequences because \cs{clist_sort:Nn} puts braces around the
+% elements which prevents \cs{keyval_parse:NNn} to detect the equal sign.
+%
+% \begin{macrocode}
+ \seq_set_from_clist:NN \l_@@_data_seq \l_@@_data_tl
+ \seq_sort:Nn \l_@@_data_seq {
+ \seq_set_split:Nnn \l_tmpa_seq {=} { ##1 }
+ \seq_set_split:Nnn \l_tmpb_seq {=} { ##2 }
+ \fp_compare:nNnTF
+ { \seq_item:Nn \l_tmpa_seq {1} } > { \seq_item:Nn \l_tmpb_seq {1} }
+ {
+ \sort_return_swapped:
+ }{
+ \sort_return_same:
+ }
+ }
+% \end{macrocode}
+%
+% Append a sentinel NaN to ensure the last value is not trimmed. This value is
+% particularly suitable because NaN is equal to no fp (even itself).
+%
+% \begin{macrocode}
+ \seq_put_right:Nn \l_@@_data_seq { nan = 0 }
+ \tl_set:Nx \l_@@_data_tl { \seq_use:Nn \l_@@_data_seq {,} }
+% \end{macrocode}
+%
+% Build the resulting clist while grouping equal values
+%
+% \begin{macrocode}
+ \clist_clear:N \l_@@_compute_data_clist
+ \int_zero:N \l_@@_compute_count_int
+ \fp_zero:N \l_@@_compute_curvalue_fp
+ \keyval_parse:NNV
+ \@@_accumulate:n
+ \@@_accumulate:nn
+ \l_@@_data_tl
+ \exp_args:NNNV
+ \group_end:
+ \clist_set:Nn #2 \l_@@_compute_data_clist
+}
+\cs_new_protected_nopar:Nn \@@_accumulate:n {
+ \@@_accumulate:nn { #1 } { 1 }
+}
+\cs_new_protected_nopar:Nn \@@_accumulate:nn {
+ \fp_compare:nNnTF { #1 } = { \l_@@_compute_curvalue_fp } {
+ \int_add:Nn \l_@@_compute_count_int { #2 }
+ }{
+ \int_compare:nNnT { \l_@@_compute_count_int } > { 0 } {
+ \clist_put_right:Nx \l_@@_compute_data_clist {
+ \fp_to_decimal:N \l_@@_compute_curvalue_fp
+ \exp_not:n { = }
+ \exp_not:V \l_@@_compute_count_int
+ }
+ }
+ \fp_set:Nn \l_@@_compute_curvalue_fp { #1 }
+ \int_set:Nn \l_@@_compute_count_int { #2 }
+ }
+}
+% \end{macrocode}
+%
+% \subsection{Count values in ranges to generate grouped counts}
+%
+% \begin{macrocode}
+\NewDocumentCommand \StatsRangeData { +O{} u{=} m +r() +O{} } {
+ \group_begin:
+% \end{macrocode}
+%
+% Handle optional settings (there are none currently)
+% |\@@_setup:nn { rangedata } { #1, #5 }|
+% Get the data inline or from a variable
+%
+% \begin{macrocode}
+ \tl_if_single:nTF { #3 } {
+% \end{macrocode}
+%
+% Generate meaningful error by using the non-existent variable.
+%
+% \begin{macrocode}
+ \cs_if_exist:NF #3 { #3 }
+ \tl_set_eq:NN \l_@@_data_tl #3
+ }{
+ \tl_set:Nn \l_@@_data_tl { #3 }
+ }
+% \end{macrocode}
+%
+% Loop through the ranges and count values into them
+%
+% \begin{macrocode}
+ \clist_clear:N \l_@@_compute_data_clist
+ \clist_map_inline:nn { #4 } {
+% \end{macrocode}
+%
+% If not a range, bail out
+%
+% \begin{macrocode}
+ \exp_args:Nx \tl_if_eq:nnF { \tl_head:n {##1} }{ \IN } {
+% \end{macrocode}
+%
+% TODO: error message
+%
+% \begin{macrocode}
+ \clist_map_break:
+ }
+% \end{macrocode}
+%
+% Extract interval data
+%
+% \begin{macrocode}
+ \@@_parse_range_full:w ##1 \q_stop
+% \end{macrocode}
+%
+% Loop through the point data and count matching values
+%
+% \begin{macrocode}
+ \int_zero:N \l_@@_compute_count_int
+ \keyval_parse:NNV
+ \@@_range_count:n
+ \@@_range_count:nn
+ \l_@@_data_tl
+ \clist_put_right:Nx \l_@@_compute_data_clist {
+ \exp_not:n { ##1 = }
+ \exp_not:V \l_@@_compute_count_int
+ }
+ }
+ \exp_args:NNNV
+ \group_end:
+ \clist_set:Nn #2 \l_@@_compute_data_clist
+}
+\cs_new_protected_nopar:Nn \@@_range_count:n {
+ \@@_range_count:nn { #1 } { 1 }
+}
+\cs_new_protected_nopar:Nn \@@_range_count:nn {
+ \@@_if_in_range:nT { #1 } {
+ \int_add:Nn \l_@@_compute_count_int { #2 }
+ }
+}
+%</package>
+% \end{macrocode}
+%
+% \end{implementation}
diff --git a/Master/texmf-dist/source/latex/statistics/statistics.ins b/Master/texmf-dist/source/latex/statistics/statistics.ins
new file mode 100644
index 00000000000..fb958db3231
--- /dev/null
+++ b/Master/texmf-dist/source/latex/statistics/statistics.ins
@@ -0,0 +1,24 @@
+\iffalse meta-comment
+
+File statistics.ins (C) Copyright 2014-2018 RIVAUD Julien
+
+It may be distributed and/or modified under the conditions of the
+General Public License (GPL), either version 3 of this
+license or (at your option) any later version.
+
+\fi
+
+\input l3docstrip.tex
+\askforoverwritefalse
+
+\preamble
+\endpreamble
+% stop docstrip adding \endinput
+\postamble
+\endpostamble
+
+\keepsilent
+
+\generate{\file{statistics.sty} {\from{statistics.dtx} {package}}}
+
+\endbatchfile
diff --git a/Master/texmf-dist/tex/latex/statistics/statistics.sty b/Master/texmf-dist/tex/latex/statistics/statistics.sty
new file mode 100644
index 00000000000..758157ed6f2
--- /dev/null
+++ b/Master/texmf-dist/tex/latex/statistics/statistics.sty
@@ -0,0 +1,1512 @@
+%%
+%% This is file `statistics.sty',
+%% generated with the docstrip utility.
+%%
+%% The original source files were:
+%%
+%% statistics.dtx (with options: `package')
+%%
+%% File: statistics.dtx (C) Copyright 2014-2018 RIVAUD Julien
+%%
+%% It may be distributed and/or modified under the conditions of the
+%% General Public License (GPL), either version 3 of this
+%% license or (at your option) any later version.
+\NeedsTeXFormat{LaTeX2e}[1995/12/01]
+\RequirePackage{expl3}[2016/01/19]
+\def\ExplFileName{statistics}
+\def\ExplFileDescription{Compute and typeset statistics table and graphics}
+\def\ExplFileDate{2018/07/21}
+\def\ExplFileVersion{2.0}
+\ProvidesExplPackage
+ {\ExplFileName}{\ExplFileDate}{\ExplFileVersion}{\ExplFileDescription}
+\RequirePackage{xparse}
+\RequirePackage{siunitx}
+\RequirePackage{tikz}
+\RequirePackage{etoolbox}
+
+\ExplSyntaxOff
+\usetikzlibrary{datavisualization, fit}
+\ExplSyntaxOn
+\tl_new:N \valuename
+\tl_new:N \countname
+\tl_new:N \freqname
+\tl_new:N \ccountname
+\tl_new:N \cfreqname
+\tl_new:N \iccname
+\tl_new:N \icfname
+\tl_new:N \dccname
+\tl_new:N \dcfname
+
+\tl_set:Nn \valuename { Values }
+\tl_set:Nn \countname { Count }
+\tl_set:Nn \ccountname { Cumulative~count }
+\tl_set:Nn \freqname { Frequency }
+\tl_set:Nn \cfreqname { Cumulative~frequency }
+\tl_set:Nn \iccname { ICC }
+\tl_set:Nn \icfname { ICF }
+\tl_set:Nn \dccname { DCC }
+\tl_set:Nn \dcfname { DCF }
+
+\AtEndPreamble {
+ \tl_if_exist:NT \captionsfrench {
+ \tl_put_right:Nn \captionsfrench {
+ \tl_set:Nn \valuename { Modalit\'e }
+ \tl_set:Nn \countname { Effectif }
+ \tl_set:Nn \ccountname { Effectif~cumul\'e }
+ \tl_set:Nn \freqname { Fr\'equence }
+ \tl_set:Nn \cfreqname { Fr\'equence~cumul\'ee }
+ \tl_set:Nn \iccname { ECC }
+ \tl_set:Nn \icfname { FCC }
+ \tl_set:Nn \dccname { ECD }
+ \tl_set:Nn \dcfname { FCD }
+ }
+ }
+}
+\cs_new_protected:Nn \__statistics_keys_define:nn {
+ \keys_define:nn { statistics / #1 } { #2 }
+}
+\cs_new_protected:Nn \__statistics_setup:nn {
+ \keys_set:nn { statistics / #1 } { #2 }
+}
+\NewDocumentCommand \statisticssetup { o +m } {
+ \IfNoValueTF { #1 } {
+ \keys_set:nn { statistics } { #2 }
+ }{
+ \keys_set:nn { statistics / #1 } { #2 }
+ }
+}
+
+\tl_new:N \l__statistics_data_tl
+\seq_new:N \l__statistics_show_seq
+
+\int_new:N \l__statistics_nbvals_int
+\int_new:N \l__statistics_currange_int
+
+\fp_new:N \l__statistics_total_fp
+\fp_new:N \l__statistics_curtotal_fp
+
+\fp_new:N \l__statistics_range_min_fp
+\fp_new:N \l__statistics_range_max_fp
+\tl_new:N \l__statistics_range_minrel_tl
+\tl_new:N \l__statistics_range_maxrel_tl
+\cs_new_protected_nopar:Npn
+ \__statistics_parse_range:w \IN#1#2;#3;#4#5\q_stop {
+ \fp_set:Nn \l__statistics_range_min_fp { #2 }
+ \fp_set:Nn \l__statistics_range_max_fp { #3 }
+}
+\cs_new_protected_nopar:Npn
+ \__statistics_parse_range_full:w \IN#1#2;#3;#4#5\q_stop {
+ \fp_set:Nn \l__statistics_range_min_fp { #2 }
+ \fp_set:Nn \l__statistics_range_max_fp { #3 }
+ \tl_if_eq:nnTF { #1 } { [ } {
+ \tl_set:Nn \l__statistics_range_minrel_tl { <=}
+ }{
+ \tl_set:Nn \l__statistics_range_minrel_tl { < }
+ }
+ \tl_if_eq:nnTF { #4 } { ] } {
+ \tl_set:Nn \l__statistics_range_maxrel_tl { <= }
+ }{
+ \tl_set:Nn \l__statistics_range_maxrel_tl { < }
+ }
+ \exp_args:NNnx
+ \prg_set_conditional:Nnn \__statistics_if_in_range:n { T } {
+ \exp_not:N \fp_compare:nTF {
+ \exp_not:N \l__statistics_range_min_fp
+ \exp_not:V \l__statistics_range_minrel_tl
+ \exp_not:n { ##1 }
+ \exp_not:V \l__statistics_range_maxrel_tl
+ \exp_not:N \l__statistics_range_max_fp }{
+ \exp_not:N \prg_return_true:
+ }{
+ \exp_not:N \prg_return_false:
+ }
+ }
+}
+\NewDocumentCommand \__statistics_IN:w { m u{;} u{;} m } {
+ \ensuremath{ \left#1 \num{#2} \mathbin{;} \num{#3} \right#4 }
+}
+
+\cs_new_protected:Nn \__statistics_setshow:n {
+ \seq_clear:N \l__statistics_show_seq
+ \clist_map_inline:nn {#1} {
+ \tl_if_in:nnTF {##1} {-} {
+ \__statistics_setshow_aux:w ##1 \q_stop
+ }{
+ \seq_put_right:Nn \l__statistics_show_seq {##1}
+ }
+ }
+}
+\cs_new_protected:Npn \__statistics_setshow_aux:w #1 - #2 \q_stop {
+ \int_step_inline:nnnn {#1} {1} {#2} {
+ \seq_put_right:Nn \l__statistics_show_seq {##1}
+ }
+}
+\cs_new_protected_nopar:Nn \__statistics_set_if_shown:N {
+ \seq_if_empty:NTF \l__statistics_show_seq {
+ \bool_set_true:N #1
+ }{
+ \seq_if_in:NVTF
+ \l__statistics_show_seq
+ \l__statistics_currange_int {
+ \bool_set_true:N #1
+ }{
+ \bool_set_false:N #1
+ }
+ }
+}
+
+\__statistics_keys_define:nn { table } {
+ showonly .value_required:n = true,
+ showonly .code:n = \__statistics_setshow:n{#1},
+
+ showonly/hidden .value_required:n = true,
+ showonly/hidden .code:n = {
+ \cs_set_protected:Nn
+ \__statistics_table_hidden_format:n
+ { #1 }
+ },
+ showonly/hidden .initial:n = ,
+
+ showonly/shown .value_required:n = true,
+ showonly/shown .code:n = {
+ \cs_set_protected:Nn
+ \__statistics_table_shown_format:n
+ { #1 }
+ },
+ showonly/shown .initial:n = #1,
+
+ maxcols .int_set:N = \l__statistics_table_maxcols_int,
+ maxcols .value_required:n = true,
+ maxcols .initial:n = 0,
+
+ tablesep .tl_set:N = \l__statistics_table_sep_tl,
+ tablesep .value_required:n = true,
+ tablesep .initial:n = \\,
+
+ valign .tl_set:N = \l__statistics_table_valign_tl,
+ valign .value_required:n = true,
+ valign .initial:n = t,
+
+ coltype .tl_set:N = \l__statistics_table_coltype_tl,
+ coltype .value_required:n = true,
+
+ headcoltype .tl_set:N = \l__statistics_table_headcoltype_tl,
+ headcoltype .value_required:n = true,
+
+ newline .tl_set:N = \l__statistics_table_newline_tl,
+ newline .value_required:n = true,
+
+ preline .tl_set:N = \l__statistics_table_preline_tl,
+ preline .value_required:n = true,
+
+ postline .tl_set:N = \l__statistics_table_postline_tl,
+ postline .value_required:n = true,
+
+ outline .meta:n = { preline={#1}, postline={#1} },
+ outline .value_required:n = true,
+
+ frame .choice:,
+ frame/full .meta:n = { preline=\firsthline, postline=\lasthline,
+ newline=\\\hline,
+ headcoltype=|l|, coltype=c| },
+ frame/full .value_forbidden:n = true,
+
+ frame/none .meta:n = { outline=, newline=\\,
+ headcoltype=l, coltype=c },
+ frame/none .value_forbidden:n = true,
+
+ frame/clean .meta:n = { preline=\firsthline, postline=\lasthline,
+ newline=\\,
+ headcoltype=l, coltype=c },
+ frame/clean .initial:n = ,
+ frame/clean .value_forbidden:n = true,
+
+ digits .int_set:N = \l__statistics_table_round_int,
+ digits .initial:n = 3,
+
+ allcounts/format .code:n = {
+ \cs_set_protected:Nn
+ \__statistics_table_allcounts_format:n
+ { #1 }
+ },
+ allcounts/format .value_required:n = true,
+ allcounts/format .initial:n = { \num{#1} },
+
+ allfreqs/format .code:n = {
+ \cs_set_protected:Nn
+ \__statistics_table_allfreqs_format:n
+ { #1 }
+ },
+ allfreqs/format .value_required:n = true,
+
+ allfreqs/format/real .meta:n = {
+ allfreqs/format = \num{##1}
+ },
+ allfreqs/format/real .value_forbidden:n = true,
+
+ allfreqs/format/percent .meta:n = {
+ allfreqs/format = \SI{\fp_eval:n{##1*100}}{\percent}
+ },
+ allfreqs/format/percent .initial:n = ,
+ allfreqs/format/percent .value_forbidden:n = true,
+
+ allfreqs/format/scaled .meta:n = {
+ allfreqs/format = \num{\fp_eval:n{##1*#1}}
+ },
+ allfreqs/format/scaled .value_required:n = true,
+}
+
+\cs_new:Nn \__statistics_define_row:nnn {
+ \tl_new:c { l__statistics_table_#1_name_tl }
+ \bool_new:c { l__statistics_table_#1_bool }
+ \__statistics_keys_define:nn { table } {
+ #1 .code:n = {
+ \bool_set_true:c { l__statistics_table_#1_bool }
+ \quark_if_no_value:nF { ##1 } {
+ \__statistics_setup:nn { table } {
+ #1/header = { ##1 }
+ }
+ }
+ },
+ #1 .default:n = \q_no_value,
+
+ no#1 .code:n =
+ \bool_set_false:c { l__statistics_table_#1_bool },
+ no#1 .value_forbidden:n = true,
+
+ #1/header .tl_set:c = { l__statistics_table_#1_name_tl },
+ #1/header .value_required:n = true,
+ #1/header .initial:n = { #3 },
+
+ #1/format .code:n = {
+ \cs_set_protected:cn
+ { __statistics_table_#1_format:n }
+ { ##1 }
+ },
+ #1/format .value_required:n = true,
+ #1/format .initial:n = { ##1 },
+ }
+ \bool_set:cn { l__statistics_table_#1_bool } { #2 }
+}
+
+\__statistics_define_row:nnn { values } \c_true_bool \valuename
+\__statistics_define_row:nnn { counts } \c_false_bool \countname
+\__statistics_define_row:nnn { frequencies } \c_false_bool \freqname
+\__statistics_define_row:nnn { icc } \c_false_bool \iccname
+\__statistics_define_row:nnn { icf } \c_false_bool \icfname
+\__statistics_define_row:nnn { dcc } \c_false_bool \dccname
+\__statistics_define_row:nnn { dcf } \c_false_bool \dcfname
+
+\__statistics_setup:nn { table } {
+ values/format = \ensuremath{#1},
+}
+
+\cs_undefine:N \__statistics_define_row:nnn
+
+\seq_new:N \l__statistics_table_contents_seq
+\tl_new:N \l__statistics_table_preamble_tl
+
+\tl_new:N \l__statistics_table_values_tl
+\tl_new:N \l__statistics_table_counts_tl
+\tl_new:N \l__statistics_table_frequencies_tl
+\tl_new:N \l__statistics_table_icc_tl
+\tl_new:N \l__statistics_table_icf_tl
+\tl_new:N \l__statistics_table_dcc_tl
+\tl_new:N \l__statistics_table_dcf_tl
+
+\fp_new:N \l__statistics_table_curICF_fp
+\fp_new:N \l__statistics_table_prevICF_fp
+
+\bool_new:N \l__statistics_table_firstrow_bool
+
+\cs_generate_variant:Nn \keyval_parse:NNn { NNV }
+\NewDocumentCommand \StatsTable { +O{} +m +O{} } {
+ \group_begin:
+ \cs_if_exist:NF \firsthline {
+ \cs_set_eq:NN \firsthline \hline
+ }
+ \cs_if_exist:NF \lasthline {
+ \cs_set_eq:NN \lasthline \hline
+ }
+ \cs_if_exist:NF \IN {
+ \cs_set_eq:NN \IN \__statistics_IN:w
+ }
+ \__statistics_setup:nn { table } { #1, #3 }
+ \tl_if_single:nTF { #2 } {
+ \cs_if_exist:NF #2 { #2 }
+ \tl_set_eq:NN \l__statistics_data_tl #2
+ }{
+ \tl_set:Nn \l__statistics_data_tl { #2 }
+ }
+ \fp_zero:N \l__statistics_total_fp
+ \keyval_parse:NNV
+ \__statistics_table_count:n
+ \__statistics_table_count:nn
+ \l__statistics_data_tl
+ \__statistics_table_start:
+ \fp_zero:N \l__statistics_table_prevICF_fp
+ \keyval_parse:NNV
+ \__statistics_table_make:n
+ \__statistics_table_make:nn
+ \l__statistics_data_tl
+ \__statistics_table_end:
+ \group_end:
+}
+\cs_new_protected_nopar:Nn \__statistics_table_start: {
+ \int_zero:N \l__statistics_nbvals_int
+ \clist_map_inline:nn { values, counts, frequencies, icc, icf, dcc, dcf } {
+ \tl_set:cx { l__statistics_table_##1_tl } {
+ \exp_not:N \ensuremath { \exp_not:N \hbox {
+ \exp_not:c { l__statistics_table_##1_name_tl }
+ } }
+ }
+ }
+}
+\cs_new_protected_nopar:Nn \__statistics_table_end: {
+ \tl_set:Nx \l__statistics_table_preamble_tl {
+ \exp_not:n { \begin{array}[ }
+ \exp_not:V \l__statistics_table_valign_tl
+ \exp_not:n { ] }
+ { \exp_not:V \l__statistics_table_headcoltype_tl
+ \prg_replicate:nn { \l__statistics_nbvals_int }
+ { \exp_not:V \l__statistics_table_coltype_tl } }
+ }
+ \seq_clear:N \l__statistics_table_contents_seq
+ \clist_map_inline:nn { values, counts, icc, dcc, frequencies, icf, dcf } {
+ \bool_if:cT { l__statistics_table_##1_bool } {
+ \seq_put_right:Nv
+ \l__statistics_table_contents_seq
+ { l__statistics_table_##1_tl }
+ }
+ }
+ $\tl_use:N \l__statistics_table_preamble_tl
+ \l__statistics_table_preline_tl
+ \seq_use:Nn
+ \l__statistics_table_contents_seq
+ { \l__statistics_table_newline_tl }
+ \\ \l__statistics_table_postline_tl
+ \end{array}$
+}
+\cs_new_protected_nopar:Nn \__statistics_table_count:n {
+ \__statistics_table_count:nn {} { 1 }
+}
+\cs_new_protected_nopar:Nn \__statistics_table_count:nn {
+ \fp_add:Nn \l__statistics_total_fp { #2 }
+}
+\cs_new_protected_nopar:Nn \__statistics_table_make:n {
+ \__statistics_table_make:nn { #1 } { 1 }
+}
+\cs_new_protected_nopar:Nn \__statistics_table_make:nn {
+ \int_compare:nT
+ { 0 < \l__statistics_table_maxcols_int
+ = \l__statistics_nbvals_int } {
+ \__statistics_table_end:
+ \tl_use:N \l__statistics_table_sep_tl
+ \__statistics_table_start:
+ }
+ \int_incr:N \l__statistics_nbvals_int
+ \int_incr:N \l__statistics_currange_int
+ \fp_add:Nn \l__statistics_curtotal_fp { #2 }
+ \__statistics_set_if_shown:N \l_tmpa_bool
+ \tl_set:Nx \l_tmpa_tl {
+ \exp_not:n { & \tl_set:Nn \currentcolumn } {
+ \int_use:N \l__statistics_currange_int
+ }
+ }
+ \bool_if:NTF \l_tmpa_bool {
+ \tl_put_right:Nn \l_tmpa_tl
+ {\__statistics_table_shown_format:n}
+ }{
+ \tl_put_right:Nn \l_tmpa_tl
+ {\__statistics_table_hidden_format:n}
+ }
+ \bool_if:NT \l__statistics_table_values_bool {
+ \tl_put_right:Nx \l__statistics_table_values_tl {
+ \exp_not:V \l_tmpa_tl {
+ \exp_not:n {
+ \__statistics_table_values_format:n { #1 }
+ }
+ }
+ }
+ }
+ \bool_if:NT \l__statistics_table_counts_bool {
+ \tl_put_right:Nx \l__statistics_table_counts_tl {
+ \exp_not:V \l_tmpa_tl {
+ \exp_not:n {
+ \__statistics_table_counts_format:n {
+ { \__statistics_table_allcounts_format:n { #2 } }
+ }
+ }
+ }
+ }
+ }
+ \bool_if:NT \l__statistics_table_icc_bool {
+ \tl_put_right:Nx \l__statistics_table_icc_tl {
+ \exp_not:V \l_tmpa_tl {
+ \exp_not:n { \__statistics_table_icc_format:n }
+ {
+ \exp_not:n{ \__statistics_table_allcounts_format:n }
+ { \fp_use:N \l__statistics_curtotal_fp }
+ }
+ }
+ }
+ }
+ \bool_if:NT \l__statistics_table_dcc_bool {
+ \tl_put_right:Nx \l__statistics_table_dcc_tl {
+ \exp_not:V \l_tmpa_tl {
+ \exp_not:n { \__statistics_table_dcc_format:n }
+ {
+ \exp_not:n{ \__statistics_table_allcounts_format:n }
+ {
+ \fp_eval:n {
+ \l__statistics_total_fp
+ - \l__statistics_curtotal_fp
+ + #2
+ }
+ }
+ }
+ }
+ }
+ }
+ \fp_set:Nn \l__statistics_table_curICF_fp {
+ round(\l__statistics_curtotal_fp
+ / \l__statistics_total_fp,
+ \l__statistics_table_round_int)
+ }
+ \bool_if:NT \l__statistics_table_frequencies_bool {
+ \tl_put_right:Nx \l__statistics_table_frequencies_tl {
+ \exp_not:V \l_tmpa_tl {
+ \exp_not:n { \__statistics_table_frequencies_format:n }
+ {
+ \exp_not:n{ \__statistics_table_allfreqs_format:n }
+ {
+ \fp_eval:n {
+ \l__statistics_table_curICF_fp
+ - \l__statistics_table_prevICF_fp
+ }
+ }
+ }
+ }
+ }
+ }
+ \bool_if:NT \l__statistics_table_icf_bool {
+ \tl_put_right:Nx \l__statistics_table_icf_tl {
+ \exp_not:V \l_tmpa_tl {
+ \exp_not:n { \__statistics_table_icf_format:n }
+ {
+ \exp_not:n{ \__statistics_table_allfreqs_format:n }
+ { \fp_to_decimal:N \l__statistics_table_curICF_fp }
+ }
+ }
+ }
+ }
+ \bool_if:NT \l__statistics_table_dcf_bool {
+ \tl_put_right:Nx \l__statistics_table_dcf_tl {
+ \exp_not:V \l_tmpa_tl {
+ \exp_not:n { \__statistics_table_dcf_format:n }
+ {
+ \exp_not:n{ \__statistics_table_allfreqs_format:n }
+ {
+ \fp_eval:n {
+ 1 - \l__statistics_table_prevICF_fp
+ }
+ }
+ }
+ }
+ }
+ }
+ \fp_set_eq:NN
+ \l__statistics_table_prevICF_fp
+ \l__statistics_table_curICF_fp
+}
+\cs_new_protected:Nn \__statistics_make_forwarded_key:nnnn {
+ \tl_clear:N \l_tmpa_tl
+ \clist_map_inline:nn {#3} {
+ \tl_put_right:Nx \l_tmpa_tl {
+ \exp_not:n {#1}
+ \tl_if_empty:nF {#1} { \tl_if_empty:nF {##1} {\exp_not:N /} }
+ \exp_not:n {##1}
+ \tl_if_empty:nF {#4} { \tl_if_empty:nF {##1} {\exp_not:N /} }
+ \exp_not:n {#4,}
+ }
+ }
+ \tl_set:Nx \l_tmpb_tl {
+ \exp_not:n {#1}
+ \tl_if_empty:nF {#1} { \tl_if_empty:nF {#2} {\exp_not:N /} }
+ \exp_not:n {#2}
+ \tl_if_empty:nF {#4} { \tl_if_empty:nF {#2} {\exp_not:N /} }
+ \exp_not:n {#4}
+ }
+ \use:x {
+ \exp_not:n { \__statistics_keys_define:nn { graph } }
+ {
+ \exp_not:V \l_tmpb_tl \exp_not:n { .default:n = \q_no_value, }
+ \exp_not:V \l_tmpb_tl
+ \exp_not:n { .code:n = \__statistics_forwarded_key:nn }
+ { \exp_not:V \l_tmpa_tl }
+ { \exp_not:n { ##1 } }
+ }
+ }
+}
+\cs_new_protected:Nn \__statistics_forwarded_key:nn {
+ \quark_if_no_value:nTF { #2 } {
+ \__statistics_setup:nn { graph } { #1 }
+ }{
+ \clist_set:Nn \l_tmpa_clist { #1,{} }
+ \use:x {
+ \exp_not:n { \__statistics_setup:nn { graph } } {
+ \clist_use:Nn \l_tmpa_clist { = {#2}, }
+ }
+ }
+ }
+}
+\cs_new_protected_nopar:Nn \__statistics_forward_keys:nn {
+ \clist_map_inline:nn {#2} {
+ \__statistics_make_forwarded_key:nnnn {} {} { #1 } { ##1 }
+ }
+}
+
+\cs_new:Nn \__statistics_create_append_reset:nn {
+ \tl_new:c { l__statistics_graph_#2_tl }
+ \__statistics_keys_define:nn { graph } {
+ #1 .value_required:n = true,
+ #1 .code:n = \tl_put_right:cn
+ { l__statistics_graph_#2_tl }
+ { ##1, },
+
+ #1/reset .value_forbidden:n = true,
+ #1/reset .code:n = \tl_clear:c
+ { l__statistics_graph_#2_tl },
+ }
+}
+
+\cs_new:Nn \__statistics_DO:nn { \__statistics_create_append_reset:nn {#1}{options_#2} }
+
+\cs_new:Nn \__statistics_define_unit:nn {
+ \__statistics_DO:nn { #2/#1/axis } { #2_#1axis }
+ \__statistics_keys_define:nn { graph } {
+ #2/#1 .code:n = {
+ \tl_set:cn {l__statistics_graph_#2_unit_tl} { #1 }
+ \quark_if_no_value:nF { ##1 } {
+ \__statistics_setup:nn { graph }{ #2/#1/label = { ##1 } }
+ }
+ },
+ #2/#1 .default:n = \q_no_value,
+
+ #2/#1/label .meta:n = { #2/#1/axis = { label = { ##1 } } },
+ #2/#1/label .value_required:n = true,
+
+ #2/#1/format .code:n = {
+ \cs_set_protected:cn
+ { __statistics_graph_#2_#1_format:n }
+ { ##1 }
+ },
+ #2/#1/format .value_required:n = true,
+
+ #2/#1/margin .tl_set:c = l__statistics_graph_#2_#1_vmargin_tl,
+ #2/#1/margin .value_required:n = true,
+ }
+}
+
+\__statistics_DO:nn { picture } { pic }
+\__statistics_DO:nn { axissystem } { system }
+
+\__statistics_DO:nn { histogram/areas/style } { areas }
+\__statistics_DO:nn { histogram/legend/options } { legend }
+
+\clist_map_inline:nn { histogram, cumulative, comb } {
+ \__statistics_define_unit:nn { counts } { #1 }
+ \__statistics_define_unit:nn { frequencies } { #1 }
+ \__statistics_DO:nn { #1/style } { #1 }
+ \__statistics_DO:nn { #1/values/axis } { #1_xaxis }
+ \__statistics_keys_define:nn { graph/#1 } {
+ values/margin .value_required:n = true,
+ values/margin .tl_set:c = l__statistics_graph_#1_hmargin_tl,
+
+ values/label .meta:n = { values/axis = { label = { ##1 } } },
+ values/label .value_required:n = true,
+
+ values/format .code:n = { \cs_set_protected:cn
+ {__statistics_graph_#1_values_format:n} { ##1 }
+ },
+ values/format .value_required:n = true,
+
+ frequencies/format/real .meta:n = {
+ frequencies/format = {
+ \num[round-mode=places,round-precision=##1]{####1}
+ }
+ },
+ frequencies/format/real .default:n = 1,
+
+ frequencies/format/percent .meta:n = {
+ frequencies/format = {
+ \SI[round-mode=places,round-precision=##1]{
+ \fp_eval:n{####1*100}
+ }{\percent}
+ }
+ },
+ frequencies/format/percent .default:n = 1,
+ }
+ \__statistics_make_forwarded_key:nnnn {#1/values}{}{label}{}
+ \clist_map_inline:nn { axis, axis/reset, label, margin, format } {
+ \__statistics_make_forwarded_key:nnnn {#1}{x}{values}{##1}
+ \__statistics_make_forwarded_key:nnnn {#1}{y}{counts, frequencies}{##1}
+ }
+}
+
+\cs_undefine:N \__statistics_DO:nn
+\cs_undefine:N \__statistics_define_unit:nnn
+
+\__statistics_forward_keys:nn { histogram, cumulative, comb } {
+ values, values/label, values/margin, values/format,
+ values/axis, values/axis/reset,
+ x/label, x/axis, x/axis/reset, x/margin, x/format,
+ counts, counts/label, counts/margin, counts/format,
+ counts/axis, counts/axis/reset,
+ frequencies, frequencies/label, frequencies/margin,
+ frequencies/format, frequencies/format/real, frequencies/format/percent,
+ frequencies/axis, frequencies/axis/reset,
+ y/label, y/axis, y/axis/reset, y/margin, y/format,
+ style, style/reset
+}
+
+\__statistics_create_append_reset:nn { tikzinfo' } { userpreinfo }
+\__statistics_create_append_reset:nn { tikzinfo } { userpostinfo }
+
+\cs_undefine:N \__statistics_forward_keys:nn
+\cs_undefine:N \__statistics_make_forwarded_key:nnnn
+\cs_undefine:N \__statistics_create_append_reset:nn
+
+\__statistics_keys_define:nn { graph } {
+ showonly .value_required:n = true,
+ showonly .code:n = \__statistics_setshow:n{#1},
+
+ height .value_required:n = true,
+ height .meta:n = { axissystem = { height = { #1 } } },
+
+ width .value_required:n = true,
+ width .meta:n = { axissystem = { width = { #1 } } },
+
+ cumulative .bool_set:N = \l__statistics_graph_cumulative_bool,
+ cumulative .default:n = true,
+
+ decreasing .bool_set:N = \l__statistics_graph_decreasing_bool,
+ decreasing .default:n = true,
+
+ histogram/areas .bool_set:N = \l__statistics_graph_areas_bool,
+ histogram/areas .default:n = true,
+
+ histogram/legend/label .value_required:n = true,
+ histogram/legend/label .meta:n = {
+ histogram/legend/options = {label={#1}} },
+
+ histogram/legend/area .value_required:n = true,
+ histogram/legend/area .meta:n = {
+ histogram/legend/h = (#1)/\width },
+
+ histogram/legend .value_required:n = true,
+ histogram/legend .code:n = {
+ \__statistics_setup:nn { graph / histogram/legend } {
+ #1
+ }
+ },
+
+ histogram/y/autostep .value_required:n = true,
+ histogram/y/autostep .meta:n = {
+ histogram/counts/autostep = {#1},
+ histogram/frequencies/autostep = {#1},
+ histogram/legend/area = {#1},
+ },
+}
+\tl_map_inline:nn {xywh} {
+ \__statistics_keys_define:nn { graph / histogram / legend } {
+ #1 .value_required:n = true,
+ #1 .tl_set:c = {l__statistics_graph_legend_#1_tl},
+ }
+}
+\clist_map_inline:nn { counts, frequencies } {
+ \__statistics_keys_define:nn { graph/histogram/#1 } {
+ autostep .default:n = 1,
+ autostep .meta:n = { axis = {
+ grid = { compute~step =
+ \group_begin:
+ \tl_set:Nx \total { \fp_to_decimal:N \l__statistics_total_fp }
+ \fp_gset:Nn \g_tmpa_fp { ##1 }
+ \group_end:
+ \tl_set:Nx \tikz@lib@dv@step {
+ \fp_eval:n {\g_tmpa_fp / \g__statistics_graph_xstep_fp }
+ }
+ }
+ }},
+ }
+}
+
+\__statistics_setup:nn { graph }{
+ width = 0.75\columnwidth,
+ cumulative = false,
+ decreasing = false,
+
+ values/axis = {
+ label = \valuename,
+ ticks~and~grid={many, integer~minor~steps}
+ },
+ values/margin = \xstep / 2,
+ values/format = \num{#1},
+
+ y/margin = \range/10,
+
+ counts/format = { \num{#1} },
+ counts/axis = { ticks~and~grid={
+ many, int~about~strategy, integer~minor~steps,
+ } },
+ comb/counts/label = \countname,
+ cumulative/counts/label = \ccountname,
+
+ frequencies/format/percent,
+ frequencies/axis = { ticks~and~grid=many },
+ comb/frequencies/label = \freqname,
+ cumulative/frequencies/label = \cfreqname,
+
+ histogram/y/axis/reset,
+ histogram/y/axis = {ticks = none},
+ histogram/y/autostep = 1,
+ histogram/legend = { x=, y=0, w=\xstep },
+ histogram/style = { semithick, black, fill=black, fill~opacity=0.1 },
+ histogram/areas,
+ histogram/areas/style = { auto, font=\small },
+
+ comb/style = { ultra~thick },
+
+ counts,
+
+ picture = {
+ baseline = (current~bounding~box.center),
+ label~position = right,
+ },
+}
+
+\tl_const:Nn \c__statistics_graph_savexstep_tl {
+ grid = { compute~step/.append = {
+ \cs_if_eq:NNF \tikz@lib@dv@step \relax {
+ \pgfkeysgetvalue
+ {/tikz/data~visualization/minor~steps~between~steps}
+ \l_tmpa_tl
+ \fp_gset:Nn \g__statistics_graph_xstep_fp {
+ \tikz@lib@dv@step
+ / (\fp_max:nn{0\l_tmpa_tl + 1}{1})
+ }
+ }
+ }}
+}
+\tl_new:N \l__statistics_graph_maxminor_tl
+\int_new:N \l__statistics_graph_minorsteps_int
+\fp_new:N \l__statistics_graph_ims_step_fp
+\fp_new:N \l__statistics_graph_ims_range_fp
+\fp_new:N \l__statistics_graph_ims_threshold_fp
+\tikzdatavisualizationset{
+integer~minor~steps/.style={
+ /utils/exec = \tl_set:Nn \l__statistics_graph_maxminor_tl {#1},
+ minor~steps~between~steps/.code=
+ \tl_clear:N \l__statistics_graph_maxminor_tl
+ \pgfkeyssetvalue
+ {/tikz/data~visualization/minor~steps~between~steps}
+ {##1} ,
+ compute~step/.append = {
+ \tl_set_eq:NN \l_tmpa_tl \tikz@lib@dv@step
+ \tl_if_empty:NT \l__statistics_graph_maxminor_tl {
+ \tl_set_eq:NN \l_tmpa_tl \relax
+ }
+ \tl_if_eq:NNF \l_tmpa_tl \relax {
+ \fp_set:Nn \l__statistics_graph_ims_step_fp { \l_tmpa_tl }
+ \tikz@lib@dv@mapper.get~in~range~interval()
+ \pgfdvinrangeinterval.get~min~and~max()
+ \pgfdvmathexitbyscientificformat \l_tmpa_tl \pgfdvmin
+ \pgfdvmathexitbyscientificformat \l_tmpb_tl \pgfdvmax
+ \fp_set:Nn \l__statistics_graph_ims_range_fp { \l_tmpb_tl - \l_tmpa_tl }
+ \fp_set:Nn \l__statistics_graph_ims_threshold_fp {
+ \fp_max:nn {
+ \l__statistics_graph_ims_step_fp * (\l__statistics_graph_maxminor_tl)
+ }{
+ \l__statistics_graph_ims_range_fp
+ }
+ }
+ \int_set:Nn \l__statistics_graph_minorsteps_int
+ { \fp_to_int:N \l__statistics_graph_ims_step_fp }
+ \bool_while_do:nn {
+ \fp_compare_p:n {
+ \l__statistics_graph_minorsteps_int * \l__statistics_graph_ims_range_fp
+ > \l__statistics_graph_ims_threshold_fp
+ }
+ }{
+ \tl_map_inline:nn {{2}{5}{10}} {
+ \fp_compare:nF {
+ \l__statistics_graph_minorsteps_int * \l__statistics_graph_ims_range_fp
+ > \l__statistics_graph_ims_threshold_fp * ##1
+ }{
+ \int_compare:nT {
+ \int_mod:nn{\l__statistics_graph_minorsteps_int}{##1} = 0
+ }{
+ \int_set:Nn
+ \l__statistics_graph_minorsteps_int
+ { \l__statistics_graph_minorsteps_int / ##1 }
+ \tl_map_break:
+ }
+ }
+ }
+ \fp_compare:nT {
+ \l__statistics_graph_minorsteps_int * \l__statistics_graph_ims_range_fp
+ > \l__statistics_graph_ims_threshold_fp
+ }{
+ \tl_map_inline:nn {{3}{2}{5}{\l__statistics_graph_minorsteps_int}} {
+ \int_compare:nT {
+ \int_mod:nn{\l__statistics_graph_minorsteps_int}{##1} = 0
+ }{
+ \int_set:Nn
+ \l__statistics_graph_minorsteps_int
+ { \l__statistics_graph_minorsteps_int / ##1 }
+ \tl_map_break:
+ }
+ }
+ }
+ }
+ \int_compare:nNnTF \l__statistics_graph_minorsteps_int > 1 {
+ \use:x { \exp_not:n {
+ \pgfkeyssetvalue
+ {/tikz/data~visualization/minor~steps~between~steps}
+ }
+ { \int_eval:n {\l__statistics_graph_minorsteps_int-1} }
+ }
+ }{
+ \pgfkeyssetvalue
+ {/tikz/data~visualization/minor~steps~between~steps}
+ {}
+ }
+ \tl_clear:N \l__statistics_graph_maxminor_tl
+ }
+ }
+},
+integer~minor~steps/.default=50,
+}
+\bool_new:N \l__statistics_graph_allranges_bool
+
+\fp_new:N \l__statistics_graph_curvalue_fp
+\fp_new:N \l__statistics_graph_curheight_fp
+\fp_new:N \l__statistics_graph_prevheight_fp
+\fp_new:N \l__statistics_graph_maxheight_fp
+\fp_new:N \l__statistics_graph_minvalue_fp
+\fp_new:N \l__statistics_graph_maxvalue_fp
+\fp_new:N \g__statistics_graph_xstep_fp
+\int_new:N \g__statistics_graph_last_int
+
+\tl_new:N \l__statistics_graph_tikzdata_tl
+\tl_new:N \l__statistics_graph_tikzinfo_tl
+\clist_new:N \l__statistics_graph_tikzincludex_clist
+\clist_new:N \l__statistics_graph_tikzincludey_clist
+\tl_new:N \l__statistics_graph_tikzpicture_tl
+\fp_new:N \l__statistics_graph_scale_fp
+\fp_new:N \l__statistics_graph_counts_scale_fp
+\fp_new:N \l__statistics_graph_frequencies_scale_fp
+\fp_set:Nn \l__statistics_graph_counts_scale_fp { 1 }
+
+\NewDocumentCommand \StatsGraph { +O{} +m +O{} } {
+ \group_begin:
+ \int_gincr:N \g__statistics_graph_last_int
+ \tl_set:Nx \l_tmpa_tl {
+ \exp_not:n { g__statistics_graph_xstep_ }
+ \int_use:N \g__statistics_graph_last_int
+ \exp_not:n { _tl }
+ }
+ \tl_if_exist:cTF { \l_tmpa_tl } {
+ \fp_gset:Nn \g__statistics_graph_xstep_fp
+ { \tl_use:c {\l_tmpa_tl} }
+ }{
+ \fp_gset:Nn \g__statistics_graph_xstep_fp { \c_one }
+ }
+ \__statistics_setup:nn { graph } { #1, #3 }
+ \tl_if_single:nTF { #2 } {
+ \cs_if_exist:NF #2 { #2 }
+ \tl_set_eq:NN \l__statistics_data_tl #2
+ }{
+ \tl_set:Nn \l__statistics_data_tl { #2 }
+ }
+ \fp_zero:N \l__statistics_graph_maxheight_fp
+ \fp_set:Nn \l__statistics_graph_minvalue_fp {inf}
+ \fp_set:Nn \l__statistics_graph_maxvalue_fp {-inf}
+ \fp_zero:N \l__statistics_total_fp
+ \int_zero:N \l__statistics_nbvals_int
+ \bool_set_true:N \l__statistics_graph_allranges_bool
+ \keyval_parse:NNV
+ \__statistics_graph_prepare:n
+ \__statistics_graph_prepare:nn
+ \l__statistics_data_tl
+ \tl_clear:N \l__statistics_graph_tikzdata_tl
+ \tl_clear:N \l__statistics_graph_tikzinfo_tl
+ \int_zero:N \l__statistics_currange_int
+ \bool_if:NTF \l__statistics_graph_allranges_bool {
+ \bool_if:NTF \l__statistics_graph_cumulative_bool {
+ \__statistics_graph_dopicture_cumulative:
+ }{
+ \__statistics_graph_dopicture_hist:
+ }
+ }{
+ \__statistics_graph_dopicture_comb:
+ }
+ \iow_now:Nx \@auxout {
+ \exp_not:n {
+ \ExplSyntaxOn
+ \tl_gset:cn
+ }
+ {
+ \exp_not:n {g__statistics_graph_xstep_}
+ \int_use:N \g__statistics_graph_last_int
+ \exp_not:n {_tl}
+ }
+ {
+ \fp_to_decimal:N \g__statistics_graph_xstep_fp
+ }
+ \exp_not:n {
+ \ExplSyntaxOff
+ }
+ }
+ \group_end:
+}
+\cs_new_protected_nopar:Nn \__statistics_graph_prepare:n {
+ \__statistics_graph_prepare:nn { #1 } { 1 }
+}
+\cs_new_protected_nopar:Nn \__statistics_graph_prepare:nn {
+ \int_incr:N \l__statistics_nbvals_int
+ \fp_add:Nn \l__statistics_total_fp { #2 }
+ \exp_args:Nx \tl_if_eq:nnF { \tl_head:n {#1} }{ \IN } {
+ \bool_set_false:N \l__statistics_graph_allranges_bool
+ }
+}
+\cs_new_protected_nopar:Nn \__statistics_graph_addpoint:nnn {
+ \tl_put_right:Nx \l__statistics_graph_tikzdata_tl {
+ \exp_not:N \pgfkeys {
+ \exp_not:n { /data~point/name = #1 }
+ \int_use:N \l__statistics_currange_int
+ \exp_not:n { ,/data~point/x = } \fp_eval:n { #2 }
+ \exp_not:n { ,/data~point/y = } \fp_eval:n { #3 }
+ }
+ \exp_not:n { \pgfdatapoint }
+ }
+}
+\cs_new_protected_nopar:Nn \__statistics_graph_outlier: {
+ \tl_put_right:Nn \l__statistics_graph_tikzdata_tl {
+ \pgfkeys{/data~point/outlier = true}
+ \pgfdatapoint
+ \pgfkeys{/data~point/outlier = }
+ }
+}
+\cs_new_protected_nopar:Nn \__statistics_graph_setup:n {
+ \fp_set_eq:Nc \l__statistics_graph_hmargin_tl {l__statistics_graph_#1_hmargin_tl}
+ \tl_set_eq:Nc \l__statistics_graph_unit_tl { l__statistics_graph_#1_unit_tl }
+ \tl_set_eq:Nc \l__statistics_graph_vmargin_tl
+ {l__statistics_graph_#1_ \l__statistics_graph_unit_tl _vmargin_tl}
+ \tl_set_eq:Nc
+ \l__statistics_graph_options_yaxis_tl
+ {l__statistics_graph_options_#1_ \l__statistics_graph_unit_tl axis_tl}
+ \cs_set_eq:Nc
+ \__statistics_graph_y_format:n
+ {__statistics_graph_#1_ \l__statistics_graph_unit_tl _format:n}
+ \cs_set_eq:Nc
+ \__statistics_graph_values_format:n
+ {__statistics_graph_#1_values_format:n}
+ \fp_set_eq:NN
+ \l__statistics_graph_frequencies_scale_fp
+ \l__statistics_total_fp
+ \fp_set_eq:Nc
+ \l__statistics_graph_scale_fp
+ {l__statistics_graph_ \l__statistics_graph_unit_tl _scale_fp}
+}
+\cs_new_protected_nopar:Nn \__statistics_graph_update_minmaxval:NN {
+ \fp_set:Nn \l__statistics_graph_minvalue_fp {
+ min( \l__statistics_graph_minvalue_fp, #1 )
+ }
+ \fp_set:Nn \l__statistics_graph_maxvalue_fp {
+ max( \l__statistics_graph_maxvalue_fp, #2 )
+ }
+}
+\cs_new_protected_nopar:Nn \__statistics_graph_update_maxheight: {
+ \fp_set:Nn \l__statistics_graph_maxheight_fp {
+ max( \l__statistics_graph_maxheight_fp , \l__statistics_graph_curheight_fp )
+ }
+}
+\cs_new_protected_nopar:Nn \__statistics_graph_handle_hmargin: {
+ \group_begin:
+ \tl_set:Nx \min { \fp_to_decimal:N \l__statistics_graph_minvalue_fp }
+ \tl_set:Nx \max { \fp_to_decimal:N \l__statistics_graph_maxvalue_fp }
+ \tl_set:Nx \range {
+ \fp_eval:n { \l__statistics_graph_maxvalue_fp - \l__statistics_graph_minvalue_fp }
+ }
+ \tl_set:Nx \xstep { \fp_to_decimal:N \g__statistics_graph_xstep_fp }
+ \exp_args:NNV \fp_gset:Nn \g_tmpa_fp \l__statistics_graph_hmargin_tl
+ \group_end:
+ \clist_put_right:Nx \l__statistics_graph_tikzincludex_clist {
+ \fp_eval:n { \l__statistics_graph_minvalue_fp - \g_tmpa_fp }
+ }
+ \clist_put_right:Nx \l__statistics_graph_tikzincludex_clist {
+ \fp_eval:n { \l__statistics_graph_maxvalue_fp + \g_tmpa_fp }
+ }
+}
+\cs_new_protected_nopar:Nn \__statistics_graph_handle_vmargin: {
+ \group_begin:
+ \tl_set:Nn \min { 0 }
+ \tl_set:Nx \max { \fp_to_decimal:N \l__statistics_graph_maxheight_fp }
+ \tl_set_eq:NN \range \max
+ \exp_args:NNV \fp_gset:Nn \g_tmpa_fp \l__statistics_graph_vmargin_tl
+ \group_end:
+ \clist_put_right:Nx \l__statistics_graph_tikzincludey_clist {
+ \fp_eval:n { \l__statistics_graph_maxheight_fp + \g_tmpa_fp }
+ }
+}
+\cs_new_protected_nopar:Nn \__statistics_graph_dopicture_hist: {
+ \__statistics_graph_setup:n {histogram}
+ \keyval_parse:NNV
+ \__statistics_graph_make_hist:n
+ \__statistics_graph_make_hist:nn
+ \l__statistics_data_tl
+ \tl_if_empty:NF \l__statistics_graph_legend_x_tl {
+ \group_begin:
+ \tl_set:Nx \min { \fp_to_decimal:N \l__statistics_graph_minvalue_fp }
+ \tl_set:Nx \max { \fp_to_decimal:N \l__statistics_graph_maxvalue_fp }
+ \tl_set:Nx \range {
+ \fp_eval:n { \l__statistics_graph_maxvalue_fp - \l__statistics_graph_minvalue_fp }
+ }
+ \tl_set:Nx \xstep { \fp_to_decimal:N \g__statistics_graph_xstep_fp }
+ \exp_args:NNV \fp_gset:Nn \g_tmpa_fp \l__statistics_graph_legend_x_tl
+ \exp_args:NNV \fp_gset:Nn \g_tmpb_fp \l__statistics_graph_legend_w_tl
+ \group_end:
+ \tl_set:Nx \l__statistics_graph_legend_x_tl { \fp_to_decimal:N \g_tmpa_fp }
+ \tl_set:Nx \l__statistics_graph_legend_w_tl { \fp_to_decimal:N \g_tmpb_fp }
+
+ \group_begin:
+ \tl_set:Nn \min { 0 }
+ \tl_set:Nx \max { \fp_to_decimal:N \l__statistics_graph_maxheight_fp }
+ \tl_set_eq:NN \range \max
+ \tl_set:Nx \xstep { \fp_to_decimal:N \g__statistics_graph_xstep_fp }
+ \tl_set_eq:NN \width \l__statistics_graph_legend_w_tl
+ \tl_set:Nx \total { \fp_to_decimal:N \l__statistics_total_fp }
+ \exp_args:NNV \fp_gset:Nn \g_tmpb_fp \l__statistics_graph_legend_h_tl
+ \tl_set:Nx \height { \fp_to_decimal:N \g_tmpb_fp }
+ \exp_args:NNV \fp_gset:Nn \g_tmpa_fp \l__statistics_graph_legend_y_tl
+ \group_end:
+
+ \tl_put_right:Nx \l__statistics_graph_tikzinfo_tl {
+ \exp_not:n { \path (visualization~cs }
+ \token_to_str:N : \exp_not:n { x= }
+ \exp_not:V \l__statistics_graph_legend_x_tl
+ \exp_not:n { ,y= }
+ \fp_to_decimal:N \g_tmpa_fp
+ \exp_not:n { ) coordinate (LSW) (visualization~cs }
+ \token_to_str:N : \exp_not:n { x= }
+ \fp_eval:n {
+ \l__statistics_graph_legend_x_tl +
+ \l__statistics_graph_legend_w_tl
+ }
+ \exp_not:n { ,y= }
+ \fp_eval:n { \g_tmpa_fp + \g_tmpb_fp }
+ \exp_not:n { ) coordinate (LNE);
+ \node[ fit=(LSW)~(LNE), draw, inner~sep=0pt,
+ }
+ \exp_not:V \l__statistics_graph_options_histogram_tl
+ \exp_not:N ,
+ \exp_not:V \l__statistics_graph_options_legend_tl
+ \exp_not:n { ] {}; }
+ }
+ }
+ \__statistics_graph_handle_hmargin:
+ \__statistics_graph_handle_vmargin:
+ \tl_set:Nx \l__statistics_graph_tikzpicture_tl {
+ \exp_not:n { \begin{tikzpicture}[ }
+ \exp_not:V \l__statistics_graph_options_pic_tl
+ \exp_not:n { ] \datavisualization
+ [scientific~axes = } {
+ \exp_not:V
+ \l__statistics_graph_options_system_tl
+ }
+ \exp_not:n { , x~axis = } {
+ \exp_not:n { include~value/.list = } {
+ \exp_not:V \l__statistics_graph_tikzincludex_clist
+ }
+ \exp_not:n { , ticks = { tick~typesetter/.code = {
+ $\__statistics_graph_values_format:n { \fp_eval:n{####1} }$ }}, }
+ \exp_not:V
+ \l__statistics_graph_options_histogram_xaxis_tl
+ \exp_not:n { , }
+ \exp_not:V
+ \c__statistics_graph_savexstep_tl
+ }
+ \exp_not:n { , y~axis = } {
+ \exp_not:n { include~value/.list = } {
+ \exp_not:V \l__statistics_graph_tikzincludey_clist
+ }
+ \exp_not:n { , }
+ \exp_not:V
+ \l__statistics_graph_options_yaxis_tl
+ }
+ \exp_not:n { , visualize~as~line = histogram,
+ histogram = } {
+ \exp_not:n { polygon, style = } {
+ \exp_not:n { every~path/.append~style = } {
+ \exp_not:V \l__statistics_graph_options_histogram_tl
+ } } }
+ \exp_not:n { ] data [set = histogram, format = TeX~code] } {
+ \exp_not:V \l__statistics_graph_tikzdata_tl
+ }
+ \exp_not:n { info' } {
+ \exp_not:V \l__statistics_graph_userpreinfo_tl
+ }
+ \exp_not:n { info } {
+ \exp_not:V \l__statistics_graph_tikzinfo_tl
+ \exp_not:V \l__statistics_graph_userpostinfo_tl
+ }
+ \exp_not:n { ; \end{tikzpicture} }
+ }
+ \tl_use:N \l__statistics_graph_tikzpicture_tl
+}
+\cs_new_protected_nopar:Nn \__statistics_graph_make_hist:n {
+ \__statistics_graph_make_hist:nn { #1 } { 1 }
+}
+\cs_new_protected_nopar:Nn \__statistics_graph_make_hist:nn {
+ \int_incr:N \l__statistics_currange_int
+ \__statistics_parse_range:w #1 \q_stop
+ \fp_set:Nn \l__statistics_graph_curheight_fp {
+ (#2) / ( \l__statistics_range_max_fp -
+ \l__statistics_range_min_fp)
+ }
+ \__statistics_graph_update_minmaxval:NN \l__statistics_range_min_fp \l__statistics_range_max_fp
+ \__statistics_graph_update_maxheight:
+ \__statistics_set_if_shown:N \l_tmpa_bool
+ \__statistics_graph_addpoint:nnn { SW }
+ { \l__statistics_range_min_fp }
+ { 0 }
+ \bool_if:NF \l_tmpa_bool {
+ \__statistics_graph_outlier:
+ }
+ \__statistics_graph_addpoint:nnn { NW }
+ { \l__statistics_range_min_fp }
+ { \l__statistics_graph_curheight_fp }
+ \bool_if:NF \l_tmpa_bool { \__statistics_graph_outlier: }
+ \__statistics_graph_addpoint:nnn { NE }
+ { \l__statistics_range_max_fp }
+ { \l__statistics_graph_curheight_fp }
+ \bool_if:NF \l_tmpa_bool { \__statistics_graph_outlier: }
+ \__statistics_graph_addpoint:nnn { SE }
+ { \l__statistics_range_max_fp }
+ { 0 }
+ \bool_if:NT \l_tmpa_bool {
+ \bool_if:NT \l__statistics_graph_areas_bool {
+ \__statistics_graph_addlabel:nn
+ \__statistics_graph_y_format:n
+ { \fp_eval:n {#2 / \l__statistics_graph_scale_fp} }
+ }
+ }
+ \__statistics_graph_outlier:
+}
+\cs_new_protected_nopar:Nn \__statistics_graph_addlabel:nn {
+ \tl_put_right:Nx \l__statistics_graph_tikzinfo_tl {
+ \exp_not:n { \path (NW }
+ \int_use:N \l__statistics_currange_int
+ \exp_not:n { ) -- node[ }
+ \exp_not:V \l__statistics_graph_options_areas_tl
+ \exp_not:N ] {
+ \exp_not:n { $ #1 } { #2 } \exp_not:N $
+ } \exp_not:n { (NE }
+ \int_use:N \l__statistics_currange_int
+ \exp_not:n { ); }
+ }
+}
+\cs_new_protected:Nn \__statistics_graph_dopicture_comb: {
+ \__statistics_graph_setup:n {comb}
+ \keyval_parse:NNV
+ \__statistics_graph_make_comb:n
+ \__statistics_graph_make_comb:nn
+ \l__statistics_data_tl
+ \__statistics_graph_handle_hmargin:
+ \__statistics_graph_handle_vmargin:
+ \tl_set:Nx \l__statistics_graph_tikzpicture_tl {
+ \exp_not:n { \begin{tikzpicture}[ }
+ \exp_not:V \l__statistics_graph_options_pic_tl
+ \exp_not:n { ] \datavisualization
+ [scientific~axes = } {
+ \exp_not:V
+ \l__statistics_graph_options_system_tl
+ }
+ \exp_not:n { , x~axis = } {
+ \exp_not:n { include~value/.list = } {
+ \exp_not:V \l__statistics_graph_tikzincludex_clist
+ }
+ \exp_not:n { , ticks = { tick~typesetter/.code = {
+ $\__statistics_graph_values_format:n { \fp_eval:n{####1} }$ }}, }
+ \exp_not:V
+ \l__statistics_graph_options_comb_xaxis_tl
+ \exp_not:n { , }
+ \exp_not:V
+ \c__statistics_graph_savexstep_tl
+ }
+ \exp_not:n { , y~axis = } {
+ \exp_not:n { include~value/.list = } {
+ \exp_not:V \l__statistics_graph_tikzincludey_clist
+ }
+ \exp_not:n { , }
+ \exp_not:n { , ticks = { tick~typesetter/.code = {
+ $\__statistics_graph_y_format:n { \fp_eval:n{####1} }$ }}, }
+ \exp_not:V
+ \l__statistics_graph_options_yaxis_tl
+ }
+ \exp_not:n { , visualize~as~line = bar~graph,
+ bar~graph = } {
+ \exp_not:n { style = } {
+ \exp_not:n { every~path/.append~style = } {
+ \exp_not:V \l__statistics_graph_options_comb_tl
+ } } }
+ \exp_not:n { ] data [set = bar~graph, format = TeX~code] } {
+ \exp_not:V \l__statistics_graph_tikzdata_tl
+ }
+ \exp_not:n { info' } {
+ \exp_not:V \l__statistics_graph_userpreinfo_tl
+ }
+ \exp_not:n { info } {
+ \exp_not:V \l__statistics_graph_tikzinfo_tl
+ \exp_not:V \l__statistics_graph_userpostinfo_tl
+ }
+ \exp_not:n { ; \end{tikzpicture} }
+ }
+ \tl_use:N \l__statistics_graph_tikzpicture_tl
+}
+\cs_new_protected_nopar:Nn \__statistics_graph_make_comb:n {
+ \__statistics_graph_make_comb:nn { #1 } { 1 }
+}
+\cs_new_protected_nopar:Nn \__statistics_graph_make_comb:nn {
+ \int_incr:N \l__statistics_currange_int
+ \fp_set:Nn \l__statistics_graph_curvalue_fp {
+ #1
+ }
+ \fp_set:Nn \l__statistics_graph_curheight_fp {
+ (#2) / \l__statistics_graph_scale_fp
+ }
+ \__statistics_graph_update_minmaxval:NN
+ \l__statistics_graph_curvalue_fp \l__statistics_graph_curvalue_fp
+ \__statistics_graph_update_maxheight:
+ \__statistics_set_if_shown:N \l_tmpa_bool
+ \__statistics_graph_addpoint:nnn { S }
+ { \l__statistics_graph_curvalue_fp }
+ { 0 }
+ \bool_if:NF \l_tmpa_bool {
+ \__statistics_graph_outlier:
+ }
+ \__statistics_graph_addpoint:nnn { N }
+ { \l__statistics_graph_curvalue_fp }
+ { \l__statistics_graph_curheight_fp }
+ \__statistics_graph_outlier:
+}
+\cs_new_protected_nopar:Nn \__statistics_graph_dopicture_cumulative: {
+ \__statistics_graph_setup:n {cumulative}
+ \bool_if:NTF \l__statistics_graph_decreasing_bool {
+ \fp_set_eq:NN \l__statistics_curtotal_fp
+ \l__statistics_total_fp
+ }{
+ \fp_zero:N \l__statistics_curtotal_fp
+ }
+ \fp_set:Nn \l__statistics_graph_curheight_fp {
+ \l__statistics_curtotal_fp
+ / \l__statistics_graph_scale_fp
+ }
+ \__statistics_graph_update_maxheight:
+ \keyval_parse:NNV
+ \__statistics_graph_make_cumulative:n
+ \__statistics_graph_make_cumulative:nn
+ \l__statistics_data_tl
+ \__statistics_graph_handle_hmargin:
+ \int_incr:N \l__statistics_currange_int
+ \__statistics_set_if_shown:N \l_tmpa_bool
+ \bool_if:NF \l_tmpa_bool { \__statistics_graph_outlier: }
+ \__statistics_graph_addpoint:nnn { E }
+ { \l__statistics_graph_maxvalue_fp + \g_tmpa_fp }
+ { \l__statistics_graph_curheight_fp }
+ \tl_set_eq:NN \l_tmpa_tl \l__statistics_graph_tikzdata_tl
+ \tl_clear:N \l__statistics_graph_tikzdata_tl
+ \int_zero:N \l__statistics_currange_int
+ \__statistics_graph_addpoint:nnn { B }
+ { \l__statistics_graph_minvalue_fp - \g_tmpa_fp }
+ { \l__statistics_graph_maxheight_fp - \l__statistics_graph_curheight_fp }
+ \__statistics_set_if_shown:N \l_tmpa_bool
+ \bool_if:NF \l_tmpa_bool { \__statistics_graph_outlier: }
+ \tl_put_right:NV \l__statistics_graph_tikzdata_tl \l_tmpa_tl
+ \__statistics_graph_handle_vmargin:
+ \tl_set:Nx \l__statistics_graph_tikzpicture_tl {
+ \exp_not:n { \begin{tikzpicture}[ }
+ \exp_not:V \l__statistics_graph_options_pic_tl
+ \exp_not:n { ] \datavisualization
+ [scientific~axes = } {
+ \exp_not:V
+ \l__statistics_graph_options_system_tl
+ }
+ \exp_not:n { , x~axis = } {
+ \exp_not:n { include~value/.list = } {
+ \exp_not:V \l__statistics_graph_tikzincludex_clist
+ }
+ \exp_not:n { , ticks = { tick~typesetter/.code = {
+ $\__statistics_graph_values_format:n { \fp_eval:n{####1} }$ }}, }
+ \exp_not:V
+ \l__statistics_graph_options_cumulative_xaxis_tl
+ \exp_not:n { , }
+ \exp_not:V
+ \c__statistics_graph_savexstep_tl
+ }
+ \exp_not:n { , y~axis = } {
+ \exp_not:n { include~value/.list = } {
+ \exp_not:V \l__statistics_graph_tikzincludey_clist
+ }
+ \exp_not:n { , }
+ \exp_not:n { , ticks = { tick~typesetter/.code = {
+ $\__statistics_graph_y_format:n { \fp_eval:n{####1} }$ }}, }
+ \exp_not:V
+ \l__statistics_graph_options_yaxis_tl
+ }
+ \exp_not:n { , visualize~as~line = cumulative,
+ cumulative = } {
+ \exp_not:n { style = } {
+ \exp_not:n { every~path/.append~style = } {
+ \exp_not:V \l__statistics_graph_options_cumulative_tl
+ } } }
+ \exp_not:n { ] data [set = cumulative, format = TeX~code] } {
+ \exp_not:V \l__statistics_graph_tikzdata_tl
+ }
+ \exp_not:n { info' } {
+ \exp_not:V \l__statistics_graph_userpreinfo_tl
+ }
+ \exp_not:n { info } {
+ \exp_not:V \l__statistics_graph_tikzinfo_tl
+ \exp_not:V \l__statistics_graph_userpostinfo_tl
+ }
+ \exp_not:n { ; \end{tikzpicture} }
+ }
+ \tl_use:N \l__statistics_graph_tikzpicture_tl
+}
+\cs_new_protected_nopar:Nn \__statistics_graph_make_cumulative:n {
+ \__statistics_graph_make_hist:nn { #1 } { 1 }
+}
+\cs_new_protected_nopar:Nn \__statistics_graph_make_cumulative:nn {
+ \__statistics_parse_range:w #1 \q_stop
+ \fp_set_eq:NN
+ \l__statistics_graph_prevheight_fp
+ \l__statistics_graph_curheight_fp
+ \bool_if:NTF \l__statistics_graph_decreasing_bool {
+ \fp_sub:Nn \l__statistics_curtotal_fp { #2 }
+ }{
+ \fp_add:Nn \l__statistics_curtotal_fp { #2 }
+ }
+ \fp_set:Nn \l__statistics_graph_curheight_fp {
+ \l__statistics_curtotal_fp
+ / \l__statistics_graph_scale_fp
+ }
+ \__statistics_graph_update_minmaxval:NN \l__statistics_range_min_fp \l__statistics_range_max_fp
+ \__statistics_graph_update_maxheight:
+ \int_incr:N \l__statistics_currange_int
+ \__statistics_graph_addpoint:nnn { L }
+ { \l__statistics_range_min_fp }
+ { \l__statistics_graph_prevheight_fp }
+ \__statistics_set_if_shown:N \l_tmpa_bool
+ \bool_if:NF \l_tmpa_bool { \__statistics_graph_outlier: }
+ \__statistics_graph_addpoint:nnn { R }
+ { \l__statistics_range_max_fp }
+ { \l__statistics_graph_curheight_fp }
+}
+\clist_new:N \l__statistics_compute_data_clist
+\int_new:N \l__statistics_compute_count_int
+
+\fp_new:N \l__statistics_compute_curvalue_fp
+\seq_new:N \l__statistics_data_seq
+
+\NewDocumentCommand \StatsSortData { +O{} u{=} m +O{} } {
+ \group_begin:
+ \tl_if_single:nTF { #3 } {
+ \cs_if_exist:NF #3 { #3 }
+ \tl_set_eq:NN \l__statistics_data_tl #3
+ }{
+ \tl_set:Nn \l__statistics_data_tl { #3 }
+ }
+ \seq_set_from_clist:NN \l__statistics_data_seq \l__statistics_data_tl
+ \seq_sort:Nn \l__statistics_data_seq {
+ \seq_set_split:Nnn \l_tmpa_seq {=} { ##1 }
+ \seq_set_split:Nnn \l_tmpb_seq {=} { ##2 }
+ \fp_compare:nNnTF
+ { \seq_item:Nn \l_tmpa_seq {1} } > { \seq_item:Nn \l_tmpb_seq {1} }
+ {
+ \sort_return_swapped:
+ }{
+ \sort_return_same:
+ }
+ }
+ \seq_put_right:Nn \l__statistics_data_seq { nan = 0 }
+ \tl_set:Nx \l__statistics_data_tl { \seq_use:Nn \l__statistics_data_seq {,} }
+ \clist_clear:N \l__statistics_compute_data_clist
+ \int_zero:N \l__statistics_compute_count_int
+ \fp_zero:N \l__statistics_compute_curvalue_fp
+ \keyval_parse:NNV
+ \__statistics_accumulate:n
+ \__statistics_accumulate:nn
+ \l__statistics_data_tl
+ \exp_args:NNNV
+ \group_end:
+ \clist_set:Nn #2 \l__statistics_compute_data_clist
+}
+\cs_new_protected_nopar:Nn \__statistics_accumulate:n {
+ \__statistics_accumulate:nn { #1 } { 1 }
+}
+\cs_new_protected_nopar:Nn \__statistics_accumulate:nn {
+ \fp_compare:nNnTF { #1 } = { \l__statistics_compute_curvalue_fp } {
+ \int_add:Nn \l__statistics_compute_count_int { #2 }
+ }{
+ \int_compare:nNnT { \l__statistics_compute_count_int } > { 0 } {
+ \clist_put_right:Nx \l__statistics_compute_data_clist {
+ \fp_to_decimal:N \l__statistics_compute_curvalue_fp
+ \exp_not:n { = }
+ \exp_not:V \l__statistics_compute_count_int
+ }
+ }
+ \fp_set:Nn \l__statistics_compute_curvalue_fp { #1 }
+ \int_set:Nn \l__statistics_compute_count_int { #2 }
+ }
+}
+\NewDocumentCommand \StatsRangeData { +O{} u{=} m +r() +O{} } {
+ \group_begin:
+ \tl_if_single:nTF { #3 } {
+ \cs_if_exist:NF #3 { #3 }
+ \tl_set_eq:NN \l__statistics_data_tl #3
+ }{
+ \tl_set:Nn \l__statistics_data_tl { #3 }
+ }
+ \clist_clear:N \l__statistics_compute_data_clist
+ \clist_map_inline:nn { #4 } {
+ \exp_args:Nx \tl_if_eq:nnF { \tl_head:n {##1} }{ \IN } {
+ \clist_map_break:
+ }
+ \__statistics_parse_range_full:w ##1 \q_stop
+ \int_zero:N \l__statistics_compute_count_int
+ \keyval_parse:NNV
+ \__statistics_range_count:n
+ \__statistics_range_count:nn
+ \l__statistics_data_tl
+ \clist_put_right:Nx \l__statistics_compute_data_clist {
+ \exp_not:n { ##1 = }
+ \exp_not:V \l__statistics_compute_count_int
+ }
+ }
+ \exp_args:NNNV
+ \group_end:
+ \clist_set:Nn #2 \l__statistics_compute_data_clist
+}
+\cs_new_protected_nopar:Nn \__statistics_range_count:n {
+ \__statistics_range_count:nn { #1 } { 1 }
+}
+\cs_new_protected_nopar:Nn \__statistics_range_count:nn {
+ \__statistics_if_in_range:nT { #1 } {
+ \int_add:Nn \l__statistics_compute_count_int { #2 }
+ }
+}
+%%
+%%
+%% End of file `statistics.sty'.
diff --git a/Master/tlpkg/bin/tlpkg-ctan-check b/Master/tlpkg/bin/tlpkg-ctan-check
index e92a6658f3d..8d7dbc23520 100755
--- a/Master/tlpkg/bin/tlpkg-ctan-check
+++ b/Master/tlpkg/bin/tlpkg-ctan-check
@@ -597,7 +597,7 @@ my @TLP_working = qw(
spot spotcolor spreadtab spverbatim
sr-vorl srbook-mem srcltx srcredact sseq sslides
stack stackengine stage standalone stanli starfont startex
- statistik statex statex2 statmath staves
+ statex statex2 statistics statistik statmath staves
stdclsdv stdpage stealcaps steinmetz
stellenbosch stex
stickstoo stix stix2-otf stix2-type1 stmaryrd storebox storecmd
diff --git a/Master/tlpkg/tlpsrc/collection-latexextra.tlpsrc b/Master/tlpkg/tlpsrc/collection-latexextra.tlpsrc
index 433a438a739..504401c16ae 100644
--- a/Master/tlpkg/tlpsrc/collection-latexextra.tlpsrc
+++ b/Master/tlpkg/tlpsrc/collection-latexextra.tlpsrc
@@ -1007,7 +1007,6 @@ depend sslides
depend stack
depend stackengine
depend standalone
-depend statistik
depend stdclsdv
depend stealcaps
depend stdpage
diff --git a/Master/tlpkg/tlpsrc/collection-mathscience.tlpsrc b/Master/tlpkg/tlpsrc/collection-mathscience.tlpsrc
index 58e32684bf2..c9b4992b42f 100644
--- a/Master/tlpkg/tlpsrc/collection-mathscience.tlpsrc
+++ b/Master/tlpkg/tlpsrc/collection-mathscience.tlpsrc
@@ -53,8 +53,8 @@ depend conteq
depend correctmathalign
depend cryptocode
depend delim
-depend delimset
depend delimseasy
+depend delimset
depend diffcoeff
depend digiconfigs
depend dijkstra
@@ -101,9 +101,9 @@ depend lpform
depend lplfitch
depend lstbayes
depend mathcomp
+depend mathfixs
depend mathpartir
depend mathpunctspace
-depend mathfixs
depend matlab-prettifier
depend mattens
depend mgltex
@@ -149,6 +149,8 @@ depend spalign
depend stanli
depend statex
depend statex2
+depend statistics
+depend statistik
depend statmath
depend steinmetz
depend stmaryrd
diff --git a/Master/tlpkg/tlpsrc/statistics.tlpsrc b/Master/tlpkg/tlpsrc/statistics.tlpsrc
new file mode 100644
index 00000000000..e69de29bb2d
--- /dev/null
+++ b/Master/tlpkg/tlpsrc/statistics.tlpsrc