Difference between revisions of "Template:ProbMacro"

From Maths
Jump to: navigation, search
m (Trimmed white space due to alignment problems.)
(Added optional argument for primes, some examples.)
 
(4 intermediate revisions by the same user not shown)
Line 1: Line 1:
<div style="font-size:0px;">{{m|1=\newcommand{\P}[1]{\mathbb{P}\left[{#1}\right]} <!--
+
<div style="font-size:0px;">{{m|1=\newcommand{\P}[2][]{\mathbb{P}#1{\left[{#2}\right]} } <!--
--> \newcommand{\Plcond}[2]{\mathbb{P}\left.\left[{#1}\right\vert{#2}\right]}<!--
+
--> \newcommand{\Pcond}[3][]{\mathbb{P}#1{\left[{#2}\!\ \middle\vert\!\ {#3}\right]} } <!--
--> \newcommand{\Prcond}[2]{\mathbb{P}\left[{#1}\left\vert{#2}\right.\right]}<!--  
+
--> \newcommand{\Plcond}[3][]{\Pcond[#1]{#2}{#3} }<!--
 +
--> \newcommand{\Prcond}[3][]{\Pcond[#1]{#2}{#3} }<!--  
 
-->}}</div><noinclude>
 
-->}}</div><noinclude>
 
==Description==
 
==Description==
 +
* {{Strike|4th of November 2017 - scrapping prototype, using {{C|\middle}} and {{C|\!}} for spacing issue}}
 +
** I can use {{C|{ } }} around the terms instead of {{M|\!}}, removing pspace too
 +
* Added {{C|\!\ }} before and after the {{M|\vert}} in conditional probability. [[User:Alec|Alec]] ([[User talk:Alec|talk]]) 22:39, 11 November 2017 (UTC)
 +
===Original===
 
* Prototype created: 3rd Nov 2017
 
* Prototype created: 3rd Nov 2017
 
* Purpose: to be included and uniformly provide a short cut to typing {{C|\mathbb{P}\left[''(whatever)''\right]}} every time
 
* Purpose: to be included and uniformly provide a short cut to typing {{C|\mathbb{P}\left[''(whatever)''\right]}} every time
 
* No spaces are provided either side of the {{M|\vert}} in conditional versions.
 
* No spaces are provided either side of the {{M|\vert}} in conditional versions.
 +
==Caveats==
 +
''(None)''
 +
===SOLVED====
 +
* {{C|<nowiki><sup></nowiki>}} can be messed up by the {{C|\!}} at the end (after the {{C|\right]}})
 +
** as in:
 +
*** {{M|\P{A} }}<sup>test</sup>
 +
** We can add a space:
 +
**# {{M|\P{A} }} <sup>test</sup> - macro
 +
**# {{M|\mathbb{P}[A]}} <sup>test</sup> - manual
 +
**#* Notice that this now has too much space!
 +
** '''FIX'''
 +
*** Added {{C|\Pspace}} - which can be set to nothing if/when this is fixed - '''added '''{{C|\pspace}}''' to for ease of typing'''
 +
*** Results:
 +
***# {{M|\P{A}\pspace}}<sup>test</sup> - macro (no space between m tag and sup)
 +
***# {{M|\mathbb{P}[A]}}<sup>test</sup> - manual ""
 +
** Workings:
 +
*** Trials:
 +
**** {{M|\mathbb{P}[A]}}<sup>test</sup> - '''original, no spaces'''
 +
**** {{M|\P{A} }}<sup>test</sup> - macro, just {{C|\P}}, no spaces
 +
**** {{M|\mathbb{P}[A]}}<sup>test</sup> - '''original, no spaces'''
 +
**** {{M|\P{A}\!\ }}<sup>test</sup> - macro, followed by {{C|\!\ }} in TeX, then no spaces between math tag and sup
 +
***** Not quite perfect, but bloody close, will use this for {{C|\pspace}}
 +
** Sig: [[User:Alec|Alec]] ([[User talk:Alec|talk]]) 22:21, 4 November 2017 (UTC)
 +
 
==Tasks==
 
==Tasks==
 +
===For 4th Nov 2017 update===
 +
* Make {{C|\Pcond}} use {{C|\P}} rather than being it's own thing
 +
===For original===
 
{{Todo|Remove this when there are none left}}
 
{{Todo|Remove this when there are none left}}
 
* Support variations, for example to underbrace things without the brackets becoming huge
 
* Support variations, for example to underbrace things without the brackets becoming huge
Line 13: Line 45:
 
* If Plcond and Prcond always work the same, introduce Pcond alone. I have no solution right now. Examples of why below
 
* If Plcond and Prcond always work the same, introduce Pcond alone. I have no solution right now. Examples of why below
 
** They are named so that the left one is sized by the first argument, the right one is sized by the second (due to the {{C|\vert}} in the middle)
 
** They are named so that the left one is sized by the first argument, the right one is sized by the second (due to the {{C|\vert}} in the middle)
 +
==Compare==
 +
{{C|\P}}
 +
* {{M|\P{A}\oplus }} - macro
 +
* {{M|\mathbb{P}[A]\oplus}} - orig
 +
{{C|\Pcond}}
 +
* {{M|\Pcond{A}{B}\oplus }} - macro
 +
* {{M|\mathbb{P}[A\vert B]\oplus}} - orig
 +
Followed by a {{C|<nowiki><sup></nowiki>}}
 +
* {{M|\P{A}\pspace}}<sup>test</sup> - macro - with {{C|\pspace}}
 +
* {{M|\mathbb{P}[A]}}<sup>test</sup> - orig
 +
* {{M|\P{A} }}<sup>test</sup> - macro - no space macro
 
==Tests==
 
==Tests==
 
* {{M|\P{A} }}, {{M|\Prcond{A}{B} }}
 
* {{M|\P{A} }}, {{M|\Prcond{A}{B} }}
Line 21: Line 64:
 
*** {{MM|\Prcond{\sum^n_{k\eq 1} }{\text{small} } }}
 
*** {{MM|\Prcond{\sum^n_{k\eq 1} }{\text{small} } }}
 
*** {{MM|\Prcond{\text{small} }{\sum^n_{k\eq 1} } }}
 
*** {{MM|\Prcond{\text{small} }{\sum^n_{k\eq 1} } }}
 +
* With primes
 +
** lcond:
 +
*** {{MM|\Plcond[']{\sum^n_{k\eq 1} }{\text{small} } }}
 +
*** {{MM|\Plcond[']{\text{small} }{\sum^n_{k\eq 1} } }}
 +
** rcond:
 +
*** {{MM|\Prcond[']{\sum^n_{k\eq 1} }{\text{small} } }}
 +
*** {{MM|\Prcond[']{\text{small} }{\sum^n_{k\eq 1} } }}
 +
* With subscripts
 +
** lcond:
 +
*** {{MM|\Plcond[_k]{\sum^n_{k\eq 1} }{\text{small} } }}
 +
*** {{MM|\Plcond[_k]{\text{small} }{\sum^n_{k\eq 1} } }}
 +
** rcond:
 +
*** {{MM|\Prcond[_k]{\sum^n_{k\eq 1} }{\text{small} } }}
 +
*** {{MM|\Prcond[_k]{\text{small} }{\sum^n_{k\eq 1} } }}
 
Pay careful condition to the {{M|\vert}} heights as much as the {{M|[}} and {{M|]}}
 
Pay careful condition to the {{M|\vert}} heights as much as the {{M|[}} and {{M|]}}
 
</noinclude>
 
</noinclude>

Latest revision as of 01:20, 7 December 2017

[ilmath]\newcommand{\P}[2][]{\mathbb{P}#1{\left[{#2}\right]} } \newcommand{\Pcond}[3][]{\mathbb{P}#1{\left[{#2}\!\ \middle\vert\!\ {#3}\right]} } \newcommand{\Plcond}[3][]{\Pcond[#1]{#2}{#3} } \newcommand{\Prcond}[3][]{\Pcond[#1]{#2}{#3} }[/ilmath]

Description

  • 4th of November 2017 - scrapping prototype, using \middle and \! for spacing issue
    • I can use { } around the terms instead of [ilmath]\![/ilmath], removing pspace too
  • Added \!\ before and after the [ilmath]\vert[/ilmath] in conditional probability. Alec (talk) 22:39, 11 November 2017 (UTC)

Original

  • Prototype created: 3rd Nov 2017
  • Purpose: to be included and uniformly provide a short cut to typing \mathbb{P}\left[(whatever)\right] every time
  • No spaces are provided either side of the [ilmath]\vert[/ilmath] in conditional versions.

Caveats

(None)

SOLVED=

  • <sup> can be messed up by the \! at the end (after the \right])
    • as in:
      • [ilmath]\P{A} [/ilmath]test
    • We can add a space:
      1. [ilmath]\P{A} [/ilmath] test - macro
      2. [ilmath]\mathbb{P}[A][/ilmath] test - manual
        • Notice that this now has too much space!
    • FIX
      • Added \Pspace - which can be set to nothing if/when this is fixed - added \pspace to for ease of typing
      • Results:
        1. [ilmath]\P{A}\pspace[/ilmath]test - macro (no space between m tag and sup)
        2. [ilmath]\mathbb{P}[A][/ilmath]test - manual ""
    • Workings:
      • Trials:
        • [ilmath]\mathbb{P}[A][/ilmath]test - original, no spaces
        • [ilmath]\P{A} [/ilmath]test - macro, just \P, no spaces
        • [ilmath]\mathbb{P}[A][/ilmath]test - original, no spaces
        • [ilmath]\P{A}\!\ [/ilmath]test - macro, followed by \!\ in TeX, then no spaces between math tag and sup
          • Not quite perfect, but bloody close, will use this for \pspace
    • Sig: Alec (talk) 22:21, 4 November 2017 (UTC)

Tasks

For 4th Nov 2017 update

  • Make \Pcond use \P rather than being it's own thing

For original


TODO: Remove this when there are none left


  • Support variations, for example to underbrace things without the brackets becoming huge
  • Support things like [ilmath]\mathbb{P}'[A][/ilmath] or [ilmath]\overline{\mathbb{P} }[A][/ilmath]
  • If Plcond and Prcond always work the same, introduce Pcond alone. I have no solution right now. Examples of why below
    • They are named so that the left one is sized by the first argument, the right one is sized by the second (due to the \vert in the middle)

Compare

\P

  • [ilmath]\P{A}\oplus [/ilmath] - macro
  • [ilmath]\mathbb{P}[A]\oplus[/ilmath] - orig

\Pcond

  • [ilmath]\Pcond{A}{B}\oplus [/ilmath] - macro
  • [ilmath]\mathbb{P}[A\vert B]\oplus[/ilmath] - orig

Followed by a <sup>

  • [ilmath]\P{A}\pspace[/ilmath]test - macro - with \pspace
  • [ilmath]\mathbb{P}[A][/ilmath]test - orig
  • [ilmath]\P{A} [/ilmath]test - macro - no space macro

Tests

  • [ilmath]\P{A} [/ilmath], [ilmath]\Prcond{A}{B} [/ilmath]
    • lcond:
      • [math]\Plcond{\sum^n_{k\eq 1} }{\text{small} } [/math]
      • [math]\Plcond{\text{small} }{\sum^n_{k\eq 1} } [/math]
    • rcond:
      • [math]\Prcond{\sum^n_{k\eq 1} }{\text{small} } [/math]
      • [math]\Prcond{\text{small} }{\sum^n_{k\eq 1} } [/math]
  • With primes
    • lcond:
      • [math]\Plcond[']{\sum^n_{k\eq 1} }{\text{small} } [/math]
      • [math]\Plcond[']{\text{small} }{\sum^n_{k\eq 1} } [/math]
    • rcond:
      • [math]\Prcond[']{\sum^n_{k\eq 1} }{\text{small} } [/math]
      • [math]\Prcond[']{\text{small} }{\sum^n_{k\eq 1} } [/math]
  • With subscripts
    • lcond:
      • [math]\Plcond[_k]{\sum^n_{k\eq 1} }{\text{small} } [/math]
      • [math]\Plcond[_k]{\text{small} }{\sum^n_{k\eq 1} } [/math]
    • rcond:
      • [math]\Prcond[_k]{\sum^n_{k\eq 1} }{\text{small} } [/math]
      • [math]\Prcond[_k]{\text{small} }{\sum^n_{k\eq 1} } [/math]

Pay careful condition to the [ilmath]\vert[/ilmath] heights as much as the [ilmath][[/ilmath] and [ilmath]][/ilmath]