From f7095f5432c01c7c3cd1c4b2db128711b7055f20 Mon Sep 17 00:00:00 2001
From: Peter Occil Returns a big integer with the bits shifted to the left by a number of bits. A value of 1 doubles this value, a value of 2 multiplies it by 4, a value of 3 by 8, a value of 4 by 16, and so on. Returns a big integer with the bits shifted to the left by a number of bits. A value of 1 doubles this value, a value of 2 multiplies it by 4, a value of 3 × by, a value of 4 × by, and so on. Parameters:shiftLeft
int numberBits);
-Examples
using (var stream = new MemoryStream(byteArray)) {
// Read the CBOR object from the stream
var cbor = CBORObject.Read(stream);
- // The rest of the example follows the one given above.
+ // The rest of the example follows the one given earlier.
}
In other Java-based environments, the library can be referred to by its
-group ID (com.github.peteroupc
), artifact ID (encoding
), and version, as given above.
com.github.peteroupc
), artifact ID (encoding
), and version, as given earlier.
Parameters:
utf-8
, either “?B?” or “?Q?” (in upper or lower case), a series of bytes in the character encoding, further encoded using B or Q encoding, and finally “?=”. B encoding uses Base64, while in Q encoding, spaces are changed to “_”, equals are changed to “=3D”, and most bytes other than the basic digits 0 to 9 (0x30 to 0x39) and the basic letters A/a to Z/z (0x41 to 0x5a, 0x61 to 0x7a) are changed to “=” followed by their 2-digit hexadecimal form. An encoded word’s maximum length is 75 characters. See the third example.utf-8
, either “?B?” or “?Q?” (in upper or lower case), a series of bytes in the character encoding, further encoded using B or Q encoding, and finally “?=”. B encoding uses Base64, while in Q encoding, spaces are changed to “_”, equals are changed to “=3D”, and most bytes other than the basic digits 0 to 9 (0x30 to 0x39) and the basic letters A/a to Z/z (0x41 to 0x5a, 0x61 to 0x7a) are changed to “=” followed by their 2-digit hexadecimal form. An encoded word’s maximum length is 75 characters. See the third example..
diff --git a/MailLib/index.html b/MailLib/index.html index 45c4b6464..a0c60612f 100755 --- a/MailLib/index.html +++ b/MailLib/index.html @@ -42,7 +42,7 @@In other Java-based environments, the library can be referred to by its
-group ID (com.upokecenter
), artifact ID (maillib
), and version, as given above.
com.upokecenter
), artifact ID (maillib
), and version, as given earlier.
Source code is available in the project page.
diff --git a/Numbers/api/com.upokecenter.numbers.EInteger.html b/Numbers/api/com.upokecenter.numbers.EInteger.html index cc262117c..57562366f 100755 --- a/Numbers/api/com.upokecenter.numbers.EInteger.html +++ b/Numbers/api/com.upokecenter.numbers.EInteger.html @@ -2543,7 +2543,7 @@public EInteger ShiftLeft(EInteger eshift) Returns an arbitrary-precision integer with the bits shifted to the left by a number of bits given as an arbitrary-precision integer. A value of 1 doubles this value, a value of 2 multiplies it by 4, a value of 3 by 8, a value of 4 by 16, and so on. +-public EInteger ShiftLeft(EInteger eshift) Returns an arbitrary-precision integer with the bits shifted to the left by a number of bits given as an arbitrary-precision integer. A value of 1 doubles this value, a value of 2 multiplies it by 4, a value of 3 × by, a value of 4 × by, and so on.Parameters:
@@ -2566,7 +2566,7 @@ShiftLeft
ShiftLeft
-public EInteger ShiftLeft(int numberBits) Returns an arbitrary-precision integer with the bits shifted to the left by a number of bits. A value of 1 doubles this value, a value of 2 multiplies it by 4, a value of 3 by 8, a value of 4 by 16, and so on. +-public EInteger ShiftLeft(int numberBits) Returns an arbitrary-precision integer with the bits shifted to the left by a number of bits. A value of 1 doubles this value, a value of 2 multiplies it by 4, a value of 3 × by, a value of 4 × by, and so on.Parameters:
diff --git a/Numbers/docs/PeterO.Numbers.EInteger.html b/Numbers/docs/PeterO.Numbers.EInteger.html index 651b213cc..1e1b5584b 100755 --- a/Numbers/docs/PeterO.Numbers.EInteger.html +++ b/Numbers/docs/PeterO.Numbers.EInteger.html @@ -3312,7 +3312,7 @@Member Summary
int bitCount);Returns an arbitrary-precision integer with the bits shifted to the left by a number of bits. A value of 1 doubles this value, a value of 2 multiplies it by 4, a value of 3 by 8, a value of 4 by 16, and so on.
+Returns an arbitrary-precision integer with the bits shifted to the left by a number of bits. A value of 1 doubles this value, a value of 2 multiplies it by 4, a value of 3 × by, a value of 4 × by, and so on.
Parameters:
@@ -3978,7 +3978,7 @@Member Summary
int numberBits);
Returns an arbitrary-precision integer with the bits shifted to the left by a number of bits. A value of 1 doubles this value, a value of 2 multiplies it by 4, a value of 3 by 8, a value of 4 by 16, and so on.
+Returns an arbitrary-precision integer with the bits shifted to the left by a number of bits. A value of 1 doubles this value, a value of 2 multiplies it by 4, a value of 3 × by, a value of 4 × by, and so on.
Parameters:
@@ -3997,7 +3997,7 @@Returns an arbitrary-precision integer with the bits shifted to the left by a number of bits given as an arbitrary-precision integer. A value of 1 doubles this value, a value of 2 multiplies it by 4, a value of 3 by 8, a value of 4 by 16, and so on.
+Returns an arbitrary-precision integer with the bits shifted to the left by a number of bits given as an arbitrary-precision integer. A value of 1 doubles this value, a value of 2 multiplies it by 4, a value of 3 × by, a value of 4 × by, and so on.
Parameters:
diff --git a/bernapprox.html b/bernapprox.html index 4e3908703..1856e3276 100755 --- a/bernapprox.html +++ b/bernapprox.html @@ -1,4 +1,4 @@ - +For some of the polynomials given above, a degree $n$ can be found so that the degree-$n$ polynomial is within $\epsilon$ of $f$, if $f$ is continuous and meets other conditions. In general, to find the degree $n$, solve the error bound’s equation for $n$ and round the solution up to the nearest integer. See the table below, where:
+For some of the polynomials given earlier, a degree $n$ can be found so that the degree-$n$ polynomial is within $\epsilon$ of $f$, if $f$ is continuous and meets other conditions. In general, to find the degree $n$, solve the error bound’s equation for $n$ and round the solution up to the nearest integer. See the table below, where:
Then the $n$-th Taylor polynomial centered at 0, given below, is within $\epsilon$ of $f$:
+Then the $n$-th Taylor polynomial centered at 0, given later, is within $\epsilon$ of $f$:
\[P(\lambda) = a_0 \lambda^0 + a_1 \lambda^1 + ... + a_n \lambda^n,\] @@ -879,8 +879,8 @@But a polynomial admits a Bernoulli factory only if it can be written to have Bernstein coefficients that are each 0 or greater and less than 1, and a function admits a Bernoulli factory with a fixed number of coin flips only if it’s a polynomial of that kind (Goyal and Sigman 20127; Qian et al. 20118; see also Wästlund 1999, section 49).
-Goyal and Sigman give an algorithm for simulating these polynomials, which is given below.
+Goyal and Sigman give an algorithm for simulating these polynomials, which is given later.
As an example, if $C$ is a generalized power series described in the section “Certain Alternating Series”, above, then $C$ admits a Bernoulli factory algorithm, namely the general martingale algorithm.
+As an example, if $C$ is a generalized power series described in the section “Certain Alternating Series”, earlier, then $C$ admits a Bernoulli factory algorithm, namely the general martingale algorithm.
@@ -1338,7 +1338,7 @@If a, given above, sums to the base-2 logarithm of the probability rather than that probability, the following algorithm I developed returns 1 with that probability. For simplicity’s sake, even though logarithms for such probabilities are negative, all the a[i] must be 0 or greater (and thus are the negated values of the already negative logarithm approximations) and must form a nowhere decreasing sequence, and all the err[i] must be 0 or greater.
+If a, given earlier, sums to the base-2 logarithm of the probability rather than that probability, the following algorithm I developed returns 1 with that probability. For simplicity’s sake, even though logarithms for such probabilities are negative, all the a[i] must be 0 or greater (and thus are the negated values of the already negative logarithm approximations) and must form a nowhere decreasing sequence, and all the err[i] must be 0 or greater.
(Flajolet et al., 2010)1. It can be seen as a triple integral of the function 1/(1 + a * b * c), where a, b, and c are uniform random variates between 0 and 1. This algorithm is given below, but using the two-coin algorithm instead of the even-parity construction32. Here, ζ(x) is the Riemann zeta function.
+(Flajolet et al., 2010)1. It can be seen as a triple integral of the function 1/(1 + a * b * c), where a, b, and c are uniform random variates between 0 and 1. This algorithm is given later, but using the two-coin algorithm instead of the even-parity construction32. Here, ζ(x) is the Riemann zeta function.
\(f(\lambda) = \sin(\lambda \pi/2) = 1-g(1-\lambda),\) where—
-\(g(\mu) = 1-\sin((1-\mu) \pi/2)\) \(= \sum_{n\ge 0} \frac{(\mu\pi/2)^{4n+2}}{(4n+2)!} - \frac{(\mu\pi/2)^{4n+4}}{(4n+4)!}\) \(= \sum_{n\ge 0} w_n(\mu) = \sum_{n\ge 0} w_n(1) \frac{w_n(\mu)}{w_n(1)}.\) This is a convex combination of $w_n(1)$ and $\frac{w_n(\mu)}{w_n(1)}$ — to simulate $g(\mu)$, first an integer n is chosen with probability $w_n(1)$ and then a coin that shows heads with probability $\frac{w_n(\mu)}{w_n(1)}$ is flipped. Finally, to simulate $f(\lambda)$, the input coin is “inverted” ($\mu = 1-\lambda$), $g(\mu)$ is simulated using the “inverted” coin, and 1 minus the simulation result is returned.
As given above, each term $w_n(\mu)$ is a polynomial in $\mu$, and is strictly increasing and equals 1 or less everywhere on the closed unit interval, and $w_n(1)$ is a constant so that $\frac{w_n(\mu)}{w_n(1)}$ remains a polynomial. Each polynomial $\frac{w_n(\mu)}{w_n(1)}$ can be transformed into a polynomial that has the following Bernstein coefficients: \((0, 0, ..., 0, 8/(v-\pi^2), 8(4n+3)/(v-\pi^2), 1),\)
+
\(g(\mu) = 1-\sin((1-\mu) \pi/2)\) \(= \sum_{n\ge 0} \frac{(\mu\pi/2)^{4n+2}}{(4n+2)!} - \frac{(\mu\pi/2)^{4n+4}}{(4n+4)!}\) \(= \sum_{n\ge 0} w_n(\mu) = \sum_{n\ge 0} w_n(1) \frac{w_n(\mu)}{w_n(1)}.\) This is a convex combination of $w_n(1)$ and $\frac{w_n(\mu)}{w_n(1)}$ — to simulate $g(\mu)$, first an integer n is chosen with probability $w_n(1)$ and then a coin that shows heads with probability $\frac{w_n(\mu)}{w_n(1)}$ is flipped. Finally, to simulate $f(\lambda)$, the input coin is “inverted” ($\mu = 1-\lambda$), $g(\mu)$ is simulated using the “inverted” coin, and 1 minus the simulation result is returned.
As given earlier, each term $w_n(\mu)$ is a polynomial in $\mu$, and is strictly increasing and equals 1 or less everywhere on the closed unit interval, and $w_n(1)$ is a constant so that $\frac{w_n(\mu)}{w_n(1)}$ remains a polynomial. Each polynomial $\frac{w_n(\mu)}{w_n(1)}$ can be transformed into a polynomial that has the following Bernstein coefficients: \((0, 0, ..., 0, 8/(v-\pi^2), 8(4n+3)/(v-\pi^2), 1),\)
where the polynomial is of degree $4n+4$ and so has $4n+5$ Bernstein coefficients, and $v = \frac{((4n+4)!)\times 2^{4n+4}}{((4n+2)!)\times 2^{4n+2}} = 16 (n+1) (4n+3)$. These are the Bernstein coefficients used in steps 4 through 7 of the algorithm above.
>
> 2. sin(λ*π/2) = cos((1−λ)*π/2).
@@ -3925,7 +3925,7 @@
Then the polynomial can be turned into a homogeneous polynomial of degree n (all its terms have degree n) as follows. (Homogeneous polynomials are also known as polynomials in scaled Bernstein form (Farouki and Rajan 1988)18.)
diff --git a/bernoulli.md b/bernoulli.md index 3417b8328..2adecd8be 100755 --- a/bernoulli.md +++ b/bernoulli.md @@ -276,7 +276,7 @@ where _n_ is the polynomial's _degree_ and _a_[0], _a_[1], ..., _a_\[_n_\] are i But a polynomial admits a Bernoulli factory only if it can be written to have Bernstein coefficients that are each 0 or greater and less than 1, and a function admits a Bernoulli factory with a fixed number of coin flips only if it's a polynomial of that kind (Goyal and Sigman 2012[^7]; Qian et al. 2011[^8]; see also Wästlund 1999, section 4[^9]). -Goyal and Sigman give an algorithm for simulating these polynomials, which is given below. +Goyal and Sigman give an algorithm for simulating these polynomials, which is given later. 1. Flip the input coin _n_ times, and let _j_ be the number of times the coin returned 1 this way.[^10] 2. Return a number that is 1 with probability _a_\[_j_\], or 0 otherwise. @@ -459,7 +459,7 @@ Suppose the following for a generalized power series $f(\lambda)$: $$C(\lambda) = \sum_{i\ge m} a_i (g(\lambda))^i, A(\lambda) = f(\lambda) - C(\lambda).$$ - As an example, if $C$ is a generalized power series described in the section "Certain Alternating Series", above, then $C$ admits a Bernoulli factory algorithm, namely the **general martingale algorithm**. + As an example, if $C$ is a generalized power series described in the section "Certain Alternating Series", earlier, then $C$ admits a Bernoulli factory algorithm, namely the **general martingale algorithm**. In addition, the algorithm will be simpler if each power coefficient $a_i$ is a rational number. @@ -857,7 +857,7 @@ The algorithm follows. 8. Let _bound_ be _lam_+1/(2_k_). If _lamunq_+_ϵ_ ≤ _bound_, set _s_ to 0. Otherwise, if _lamunq_ > _bound_, set _s_ to 2. Otherwise, set _s_ to 1. 9. Generate 1 or 0 with equal probability. If 1 was generated this way, go to step 2. Otherwise, return a number that is 0 if _s_ is 0; otherwise, 1 if _s_ is 2; otherwise, either 1 or 0 with equal probability. -If _a_, given above, sums to the _base-2 logarithm_ of the probability rather than that probability, the following algorithm I developed returns 1 with that probability. For simplicity's sake, even though logarithms for such probabilities are negative, all the _a_\[_i_\] must be 0 or greater (and thus are the negated values of the already negative logarithm approximations) and must form a nowhere decreasing sequence, and all the _err_\[_i_\] must be 0 or greater. +If _a_, given earlier, sums to the _base-2 logarithm_ of the probability rather than that probability, the following algorithm I developed returns 1 with that probability. For simplicity's sake, even though logarithms for such probabilities are negative, all the _a_\[_i_\] must be 0 or greater (and thus are the negated values of the already negative logarithm approximations) and must form a nowhere decreasing sequence, and all the _err_\[_i_\] must be 0 or greater. 1. Set _intinf_ to floor(max(0, abs(_a_\[0\]))). (This is the absolute integer part of the first term in the series, or 0, whichever is greater.) 2. If _intinf_ is greater than 0, generate numbers that are each 1 or 0 with equal probability until the number zero or _intinf_ many numbers were generated this way, whichever comes first. If a zero was generated this way, return 0. @@ -1515,7 +1515,7 @@ This algorithm is a special case of the two-coin algorithm of (Gonçalves et al. This is a rational function (ratio of two polynomials) with variable _λ_, and this rational function admits the following algorithm. In this algorithm, _m_ must be an integer 0 or greater, and _λ_ is the unknown heads probability of a coin. 1. Let _d_ be the three-item list [1, 2, 1] \(for numerator 1). Let _e_ be the three-item list [1+m2, 2\*(1+m2+m), 1+m2+2\*m+1] \(for denominator). Find the highest number in _e_, then divide each item in _d_ and in _e_ by that number (using rational arithmetic). -2. Run the first algorithm for [**rational functions**](https://peteroupc.github.io/bernoulli.html#Certain_Rational_Functions) in "Bernoulli Factory Algorithms", with _n_ = 2, and with _d_ and _e_ given above. +2. Run the first algorithm for [**rational functions**](https://peteroupc.github.io/bernoulli.html#Certain_Rational_Functions) in "Bernoulli Factory Algorithms", with _n_ = 2, and with _d_ and _e_ given earlier. @@ -2219,7 +2219,7 @@ Involves the continued fraction expansion and Bernoulli Factory algorithm 3 for #### _ζ_(3) * 3 / 4 and Other Zeta-Related Constants -(Flajolet et al., 2010\)[^1]. It can be seen as a triple integral of the function 1/(1 + _a_ * _b_ * _c_), where _a_, _b_, and _c_ are uniform random variates between 0 and 1. This algorithm is given below, but using the two-coin algorithm instead of the even-parity construction[^32]. Here, _ζ_(_x_) is the Riemann zeta function. +(Flajolet et al., 2010\)[^1]. It can be seen as a triple integral of the function 1/(1 + _a_ * _b_ * _c_), where _a_, _b_, and _c_ are uniform random variates between 0 and 1. This algorithm is given later, but using the two-coin algorithm instead of the even-parity construction[^32]. Here, _ζ_(_x_) is the Riemann zeta function. 1. Generate three uniform random variates between 0 and 1. 2. Generate 1 or 0 with equal probability. If 1 was generated this way, return 1. @@ -2661,7 +2661,7 @@ The following algorithm returns 1 with probability sin(_λ_\*_π_/2) and $$f(\lambda) = \sin(\lambda \pi/2) = 1-g(1-\lambda),$$ where— -$$g(\mu) = 1-\sin((1-\mu) \pi/2)$$ $$= \sum_{n\ge 0} \frac{(\mu\pi/2)^{4n+2}}{(4n+2)!} - \frac{(\mu\pi/2)^{4n+4}}{(4n+4)!}$$ $$= \sum_{n\ge 0} w_n(\mu) = \sum_{n\ge 0} w_n(1) \frac{w_n(\mu)}{w_n(1)}.$$ This is a [**convex combination**](#Convex_Combinations) of $w_n(1)$ and $\frac{w_n(\mu)}{w_n(1)}$ — to simulate $g(\mu)$, first an integer _n_ is chosen with probability $w_n(1)$ and then a coin that shows heads with probability $\frac{w_n(\mu)}{w_n(1)}$ is flipped. Finally, to simulate $f(\lambda)$, the input coin is "inverted" ($\mu = 1-\lambda$), $g(\mu)$ is simulated using the "inverted" coin, and 1 minus the simulation result is returned.9f>K~{6MmJTAF-yu|EU3$(Uk^9GvLmfzF+MF{CErjO{AxEd3w&@(3_;H+tZZq((
z7cGhAa;UQg?BQc$vzGGhW~uaBQR_&v*gD6pvy<$vSg>r7jSxmv!@1!MfP}BP6@|RH
z-4RGF_?8CBT2{=s6W~VWNT^|ws(;&va39{DDG=U`Nhj!z9Y&1WSgdIC8p)vBcIFfd
z%LrpdOxp?0)oQiAk|MQzouJI#j2*RQ+1MO?9&M8cZ7~B&9$FS_1f!yz6xz`ox3OSr
z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