text:
Código fonte para qiskit.transpiler.passes.optimization.optimize_1q_decomposition

# This code is part of Qiskit.
#
# (C) Copyright IBM 2017, 2018.
#
# obtain a copy of this license in the LICENSE.txt file in the root directory
#
# Any modifications or derivative works of this code must retain this
# copyright notice, and modified files need to carry a notice indicating
# that they have been altered from the originals.

"""Optimize chains of single-qubit gates using Euler 1q decomposer"""

import copy
import logging
import warnings

import numpy as np

from qiskit.circuit.library.standard_gates import U3Gate
from qiskit.transpiler.basepasses import TransformationPass
from qiskit.quantum_info.synthesis import one_qubit_decompose
from qiskit.converters import circuit_to_dag

logger = logging.getLogger(__name__)

[documentos]class Optimize1qGatesDecomposition(TransformationPass):
"""Optimize chains of single-qubit gates by combining them into a single gate."""

[documentos]    def __init__(self, basis=None):
"""Optimize1qGatesDecomposition initializer.

Args:
basis (list[str]): Basis gates to consider, e.g. ['u3', 'cx']. For the effects
of this pass, the basis is the set intersection between the basis parameter
and the Euler basis.
"""
super().__init__()
self._target_basis = basis
self._decomposers = None
if basis:
self._decomposers = []
basis_set = set(basis)
euler_basis_gates = one_qubit_decompose.ONE_QUBIT_EULER_BASIS_GATES
for euler_basis_name, gates in euler_basis_gates.items():
if set(gates).issubset(basis_set):
basis_copy = copy.copy(self._decomposers)
for base in basis_copy:
# check if gates are a superset of another basis
# and if so, remove that basis
if set(euler_basis_gates[base.basis]).issubset(set(gates)):
self._decomposers.remove(base)
# check if the gates are a subset of another basis
elif set(gates).issubset(set(euler_basis_gates[base.basis])):
break
# if not a subset, add it to the list
else:
self._decomposers.append(
one_qubit_decompose.OneQubitEulerDecomposer(euler_basis_name)
)

[documentos]    def run(self, dag):
"""Run the Optimize1qGatesDecomposition pass on dag.

Args:
dag (DAGCircuit): the DAG to be optimized.

Returns:
DAGCircuit: the optimized DAG.
"""
if not self._decomposers:
logger.info("Skipping pass because no basis is set")
return dag
runs = dag.collect_1q_runs()
for run in runs:
# SPECIAL CASE: Don't bother to optimize single U3 gates which are in the basis set.
#     The U3 decomposer is only going to emit a sequence of length 1 anyhow.
if "u3" in self._target_basis and len(run) == 1 and isinstance(run[0].op, U3Gate):
# Toss U3 gates equivalent to the identity; there we get off easy.
if np.allclose(run[0].op.to_matrix(), np.eye(2), 1e-15, 0):
dag.remove_op_node(run[0])
continue
# We might rewrite into lower us if they're available.
if "u2" not in self._target_basis and "u1" not in self._target_basis:
continue

new_circs = []
operator = run[0].op.to_matrix()
for gate in run[1:]:
operator = gate.op.to_matrix().dot(operator)
for decomposer in self._decomposers:
new_circs.append(decomposer._decompose(operator))
if new_circs:
new_circ = min(new_circs, key=len)

# do we even have calibrations?
has_cals_p = dag.calibrations is not None and len(dag.calibrations) > 0
# is this run all in the target set and also uncalibrated?
rewriteable_and_in_basis_p = all(
g.name in self._target_basis
and (not has_cals_p or not dag.has_calibration_for(g))
for g in run
)
# does this run have uncalibrated gates?
uncalibrated_p = not has_cals_p or any(not dag.has_calibration_for(g) for g in run)
# does this run have gates not in the image of ._decomposers _and_ uncalibrated?
uncalibrated_and_not_basis_p = any(
g.name not in self._target_basis
and (not has_cals_p or not dag.has_calibration_for(g))
for g in run
)

if rewriteable_and_in_basis_p and len(run) < len(new_circ):
# NOTE: This is short-circuited on calibrated gates, which we're timid about
#       reducing.
warnings.warn(
f"Resynthesized {run} and got {new_circ}, "
f"but the original was native and the new value is longer.  This "
f"indicates an efficiency bug in synthesis.  Please report it by "
f"opening an issue here: "
f"https://github.com/Qiskit/qiskit-terra/issues/new/choose",
stacklevel=2,
)
# if we're outside of the basis set, we're obligated to logically decompose.
# if we're outside of the set of gates for which we have physical definitions,
#    then we _try_ to decompose, using the results if we see improvement.
# NOTE: Here we use circuit length as a weak proxy for "improvement"; in reality,
#       we care about something more like fidelity at runtime, which would mean,
#       e.g., a preference for RZGates over RXGates.  In fact, users sometimes
#       express a preference for a "canonical form" of a circuit, which may come in
#       the form of some parameter values, also not visible at the level of circuit
#       length.  Since we don't have a framework for the caller to programmatically
#       express what they want here, we include some special casing for particular
#       gates which we've promised to normalize --- but this is fragile and should
#       ultimately be done away with.
if (
uncalibrated_and_not_basis_p
or (uncalibrated_p and len(run) > len(new_circ))
or isinstance(run[0].op, U3Gate)
):
new_dag = circuit_to_dag(new_circ)
dag.substitute_node_with_dag(run[0], new_dag)
# Delete the other nodes in the run
for current_node in run[1:]:
dag.remove_op_node(current_node)
return dag


text:
Preprint D38/2007
Growth of the number of geodesics between points and insecurity for Riemannian manifolds
Eugene Gutkin | Burns, Keith
Keywords: riemannian manifold | security | geodesics | entropy
A Riemannian manifold is said to be uniformly secure if there is a finite number $s$ such that all geodesics connecting an arbitrary pair of points in the manifold can be blocked by $s$ point obstacles. We prove that the number of geodesics with length $\leq T$ between every pair of points in a uniformly secure manifold grows polynomially as $T \to \infty$. We derive from this that a compact Riemannian manifold with no conjugate points whose geodesic flow has positive topological entropy is totally insecure: the geodesics between any pair of points cannot be blocked by a finite number of point obstacles.

format: plain


text:
# PhD topic at the Belgian Nuclear Research Centre (SCK-CEN) – Promoter Valérie Cappuyns

## Influence of redox conditions and organic matter on the partitioning and mobility of naturally occurring radionuclides (NOR‘s) in geothermal systems

### Short project description

Deep geothermal energy is currently being investigated in many European countries, including Belgium, as a promising renewable energy source for the future. Geothermal energy plants rely on pumping up large amounts of deep hot groundwaters and transferring these groundwaters through above-ground facilities (such as heat exchangers, turbines or pumps) before reinjecting them back to the geological layer from which they were extracted (closed-loop configuration).

Previous and recent chemical and radiological analysis of these groundwaters have however shown that, in order to guarantee long service life without adversely affecting humans and the environment, such installations need to be assessed both chemically and radiologically. Indeed, from a chemical point of view, large quantities of dissolved salts, more specifically mainly NaCl, have been found in many of these groundwaters with total dissolved solids (TDS) ranging between ~100 to 270 g/L (Vandenberghe et al., 2000; Regenspurg et al., 2010; Sanjuan et al., 2010). Radiologically, these groundwaters are characterised by the presence of various naturally occurring radionuclides (NOR’s) of the 238U, 232Th and 235U decay series. While radium (226Ra, 228Ra, 224Ra, 223Ra), radon (222Rn), and lead (210Pb, 212Pb) isotopes are rather soluble in geothermal brines, the isotopes of uranium (238U, 234U, 235U), thorium (232Th, 228Th, 230Th), polonium (210Po), and actinium (227Ac, 228Ac) are characterized by low solubilities and are thus mostly immobile (Kölbel et al., 2020). Relatively elevated concentrations of 226Ra (up to 120 Bq/L) and 228Ra (up to 10 Bq/L) have been described in waters produced from different geothermal reservoirs (Vandenberghe et al., 2000; Vasile et al., 2016; Degering and Köhler, 2015; Kölbel et al., 2020). During their flow from the reservoir rocks up through the production well and surface installation, scale formation has been observed due to the changing pressure and temperature, as well as redox conditions. The observed scales comprise metal sulfides, iron (oxi)hydroxides, sulphates (e.g. baryte, celestite), carbonates (e.g. siderite, dolomite, calcite), and amorphous silca to name the predominant ones. The co-existence of the previously mentioned phases and association with different NOR’s clearly reflects that besides solubility, also the redox conditions play an important role in the precipitation of the scales and most likely also in the partitioning of the NOR’s. In this context, it should be mentioned that also organic material has been described in different geothermal systems being part of the scaling material or clogging deposits (Pauwels et al., 2020; Andritsos et al., 2014; Gallup et al., 2005; Finster et al., 2015; Sanjuan et al., 2010). The origin of organics present in the geothermal waters may be of natural origin, i.e. released from the reservoir/formation rocks and/or represents components or degradation products of scale and corrosion inhibitors.

With respect to the characterization of scales formed in geothermal installations, the focus until now has been mainly on the radioactivity related to Ra-isotopes, as well as 210Pb and less to 210Po (Degering and Köhler, 2015). Process understanding, to date, was mainly focused on these radionuclides and less on 210Po. Lately, high amounts of 210Po were also described to be present in scales of the Reykjanes geothermal system in SW-Iceland (Borgeir, 2015), as well as in scales of the Balmatt system (Pauwels et al., 2020). However, no information is available yet to explain its fractionation and preferential accumulation/co-precipitation in scales compared to its parent (226Ra). Also the role of organics playing in NOR precipitation and fractionation is still poorly known.

Thus, in order to better understand the mobility of NOR’s in geothermal systems and their partitioning during scale formation, the PhD project aims at answering the following main research questions:

1. What is the influence of the redox conditions on the partitioning of the radionuclides in scales formed in geothermal installations (focus on 210Pb and 210Po) ?

2. To which extent may organic matter of natural and/or artificial origin contribute to the accumulation and partitioning of NOR’s ? And if it plays a role, is this also a redox related process ?

### The minimum diploma level of the candidate needs to be

Master of sciences

### The candidate needs to have a background in

Chemistry , Geology

### Estimated duration

4 years
Before applying, please consult the guidelines for application for PhD.
Scroll to Top


text:
# Definite Integral Misunderstood

1. Sep 18, 2007

Okay, so I went a little ahead in my text and I am having alittle trouble deciphering something. To make it easy, I will provide an example/question.

If I see the following problem: $$\int_2^42xdx$$, does it mean

a.) Evaluate the line y=2x between 2 and 4 to get area=4.

or

b.) Antidifferentiate and evaluate the curve $$x^2$$ from 2 to 4 to get area=12.

C.) Neither.

Thank you,
Casey

2. Sep 18, 2007

### Dick

If by a) you mean the area under the line y=2x between 2 and 4 then it means both. Except you got the answer to a) wrong. It's a trapezoid. The answer is also 12.

3. Sep 18, 2007

Okay....let me try this again in different words...I was trying to avoid an extremely wordy explanation, but here goes.

if you see this $$\int_a^b xdx$$ ....what do you do?

Casey

4. Sep 18, 2007

### Dick

I find an antiderivative to x, which is x^2/2 and hence conclude the answer is b^2/2-a^2/2. What do YOU do?

5. Sep 18, 2007

### dynamicsolo

The Fundamental Theorem of (Integral) Calculus says you would antidifferentiate x to get (1/2)(x^2) and then take the difference (1/2)(4^2) - (1/2)(2^2). It applies to any definite integral of f(x), *provided* the function is continuous on the interval between your integration limits. If the antiderivative (or integral) function of f(x) is F(x), then the definite integral from a to b is F(b)-F(a).

You'll learn somewhat later what to do if the function f(x) is *not* continuous...

6. Sep 18, 2007

The answer is 12 for both....okay...I see where my error was.

Is that coincidence or are a function and its 1st derivative's areas under the same bounds supposed to be equal?! I don't think they are.

i.e, x from [0,3} =3 and its antiderivative x^2/2 from [0,3] = 9/2

I am more confused now. Can someone answer post #3 for me

Thanks,
Casey

Edit: I am too slow! Thanks dynamicsolo.

SO is this correct to say:

$$\int_a^bxdx=(.5b^2)-(.5a^2)$$ =the area under the graph of y=x.<---or is it the area under .5x^2 from [a,b]? AHHH!!!

Edit again: I saw your post Dick. Thanks. I would stare at it for awhile and then go kick something...because the way I thought you did it was to evaluate .5x^2 from a to b ....however, my text appears to be doing something funny....maybe I am reading it wrong.

Last edited: Sep 18, 2007
7. Sep 18, 2007

### Dick

You are indeed royally confused. If F(x) is an antiderivative of f(x), then F(b)-F(a) is the area under the curve of f(x) between a and b. This is NOT equal to f(b)-f(a). And the area under F(x) is not equal to the area under f(x). It's only the first statement that is true. None of the others.

8. Sep 18, 2007

### dynamicsolo

$$\int_a^bxdx=(.5b^2)-(.5a^2)$$ =the area under the graph of y=x.

9. Sep 18, 2007

Okay. This is what I thought, so I was not confused by the Definite Integral, I must be confused by my textbook instructions.

Here is the problem exactly as stated.

Sketch the region whose signed area is represented by the definite integrand, and evaluate the inegral using an appropriate formula from geometry, where needed.

$$\int_0^3 xdx$$

Ohhh @#\$%.....I get it. I can draw y=x and use .5(bh) to find the area of the triangle=9/2.....OR.....evaluate the antiderivative .5x^2 from [0,3] to get the same answer.

Casey

10. Sep 18, 2007

### Dick

Yessssssssssssssssss.

11. Sep 18, 2007

NOoooooooooooo.

Just kidding. Yes.

12. Sep 18, 2007

### Dick

Don't scare me, I'm the sssssnake. I thought I was losing you again.


text:
# Documentation¶

Julia enables package developers and users to document functions, types and other objects easily via a built-in documentation system since Julia 0.4.

Tip

This documentation system can also be used in Julia 0.3 via the Docile.jl package; see the documentation for that package for more details.

The basic syntax is very simple: any string appearing at the top-level right before an object (function, macro, type or instance) will be interpreted as documenting it (these are called docstrings). Here is a very simple example:

"Tell whether there are too foo items in the array."
foo(xs::Array) = ...

Documentation is interpreted as Markdown, so you can use indentation and code fences to delimit code examples from text. Technically, any object can be associated with any other as metadata; Markdown happens to be the default, but one can construct other string macros and pass them to the @doc macro just as well.

Here is a more complex example, still using Markdown:

"""
bar(x[, y])

Compute the Bar index between x and y. If y is missing, compute
the Bar index between all pairs of columns of x.

# Examples
julia
julia> bar([1, 2], [1, 2])
1

"""
function bar(x, y) ...

As in the example above, we recommend following some simple conventions when writing documentation:

1. Always show the signature of a function at the top of the documentation, with a four-space indent so that it is printed as Julia code.

This can be identical to the signature present in the Julia code (like mean(x::AbstractArray)), or a simplified form. Optional arguments should be represented with their default values (i.e. f(x, y=1)) when possible, following the actual Julia syntax. Optional arguments which do not have a default value should be put in brackets (i.e. f(x[, y]) and f(x[, y[, z]])). An alternative solution is to use several lines: one without optional arguments, the other(s) with them. This solution can also be used to document several related methods of a given function. When a function accepts many keyword arguments, only include a <keyword arguments> placeholder in the signature (i.e. f(x; <keyword arguments>)), and give the complete list under an # Arguments section (see point 4 below).

2. Include a single one-line sentence describing what the function does or what the object represents after the simplified signature block. If needed, provide more details in a second paragraph, after a blank line.

The one-line sentence should use the imperative form (“Do this”, “Return that”) instead of the third person (do not write “Returns the length...”) when documenting functions. It should end with a period. If the meaning of a function cannot be summarized easily, splitting it into separate composable parts could be beneficial (this should not be taken as an absolute requirement for every single case though).

3. Do not repeat yourself.

Since the function name is given by the signature, there is no need to start the documentation with “The function bar...”: go straight to the point. Similarly, if the signature specifies the types of the arguments, mentioning them in the description is redundant.

4. Only provide an argument list when really necessary.

For simple functions, it is often clearer to mention the role of the arguments directly in the description of the function’s purpose. An argument list would only repeat information already provided elsewhere. However, providing an argument list can be a good idea for complex functions with many arguments (in particular keyword arguments). In that case, insert it after the general description of the function, under an # Arguments header, with one * bullet for each argument. The list should mention the types and default values (if any) of the arguments:

"""
...
# Arguments
* n::Integer: the number of elements to compute.
* dim::Integer=1: the dimensions along which to perform the computation.
...
"""

5. Include any code examples in an # Examples section.

Examples should, whenever possible, be written as doctests. A doctest is a fenced code block (see Code blocks) starting with jldoctest and contains any number of julia> prompts together with inputs and expected outputs that mimic the Julia REPL.

For example in the following docstring a variable a is defined and the expected result, as printed in a Julia REPL, appears afterwards:

"""
Some nice documentation here.

# Examples

jldoctest
julia> a = [1 2; 3 4]
2×2 Array{Int64,2}:
1  2
3  4

"""

Warning

Calling rand and other RNG-related functions should be avoided in doctests since they will not produce consistent outputs during different Julia sessions.

Operating system word size (Int32 or Int64) as well as path separator differences (/ or \) will also effect the reproducibility of some doctests.

Note that whitespace in your doctest is significant! The doctest will fail if you misalign the output of pretty-printing an array, for example.

You can then run make -C doc doctest to run all the doctests in the Julia Manual, which will ensure that your example works.

Examples that are untestable should be written within fenced code blocks starting with julia so that they are highlighted correctly in the generated documentation.

Tip

Wherever possible examples should be self-contained and runnable so that readers are able to try them out without having to include any dependencies.

6. Use backticks to identify code and equations.

Julia identifiers and code excerpts should always appear between backticks  to enable highlighting. Equations in the LaTeX syntax can be inserted between double backticks . Use Unicode characters rather than their LaTeX escape sequence, i.e. α = 1 rather than \\alpha = 1.

7. Place the starting and ending """ characters on lines by themselves.

That is, write:

"""
...

...
"""
f(x, y) = ...

rather than:

"""...

..."""
f(x, y) = ...

This makes it more clear where docstrings start and end.

8. Respect the line length limit used in the surrounding code.

Docstrings are edited using the same tools as code. Therefore, the same conventions should apply. It it advised to add line breaks after 92 characters.

## Accessing Documentation¶

Documentation can be accessed at the REPL or in IJulia by typing ? followed by the name of a function or macro, and pressing Enter. For example,

?fft
?@time
?r""

will bring up docs for the relevant function, macro or string macro respectively. In Juno using Ctrl-J, Ctrl-D will bring up documentation for the object under the cursor.

## Functions & Methods¶

Functions in Julia may have multiple implementations, known as methods. While it’s good practice for generic functions to have a single purpose, Julia allows methods to be documented individually if necessary. In general, only the most generic method should be documented, or even the function itself (i.e. the object created without any methods by function bar end). Specific methods should only be documented if their behaviour differs from the more generic ones. In any case, they should not repeat the information provided elsewhere. For example:

"""
Multiplication operator. x*y*z*... calls this function with multiple
arguments, i.e. *(x,y,z...).
"""
function *(x, y)
# ... [implementation sold separately] ...
end

"When applied to strings, concatenates them."
function *(x::AbstractString, y::AbstractString)
# ... [insert secret sauce here] ...
end

help?>*
Multiplication operator. x*y*z*... calls this function with multiple
arguments, i.e. *(x,y,z...).

When applied to strings, concatenates them.

When retrieving documentation for a generic function, the metadata for each method is concatenated with the catdoc function, which can of course be overridden for custom types.

The @doc macro associates its first argument with its second in a per-module dictionary called META. By default, documentation is expected to be written in Markdown, and the doc"" string macro simply creates an object representing the Markdown content. In the future it is likely to do more advanced things such as allowing for relative image or link paths.

When used for retrieving documentation, the @doc macro (or equally, the doc function) will search all META dictionaries for metadata relevant to the given object and return it. The returned object (some Markdown content, for example) will by default display itself intelligently. This design also makes it easy to use the doc system in a programmatic way; for example, to re-use documentation between different versions of a function:

@doc "..." foo!
@doc (@doc foo!) foo

Or for use with Julia’s metaprogramming functionality:

for (f, op) in ((:add, :+), (:subtract, :-), (:multiply, :*), (:divide, :/))
@eval begin
$f(a,b) =$op(a,b)
end
end
@doc "add(a,b) adds a and b together" add
@doc "subtract(a,b) subtracts b from a" subtract

Documentation written in non-toplevel blocks, such as if, for, and let, are not automatically added to the documentation system. @doc must be used in these cases. For example:

if VERSION > v"0.4"
"..."
f(x) = x
end

will not add any documentation to f even when the condition is true and must instead be written as:

if VERSION > v"0.4"
@doc "..." ->
f(x) = x
end

## Syntax Guide¶

A comprehensive overview of all documentable Julia syntax.

In the following examples "..." is used to illustrate an arbitrary docstring which may be one of the follow four variants and contain arbitrary text:

"..."

doc"..."

"""
...
"""

doc"""
...
"""

@doc_str should only be used when the docstring contains $ or \ characters that should not be parsed by Julia such as LaTeX syntax or Julia source code examples containing interpolation. ### Functions and Methods¶ "..." function f end "..." f  Adds docstring "..." to Function f. The first version is the preferred syntax, however both are equivalent. "..." f(x) = x "..." function f(x) x end "..." f(x)  Adds docstring "..." to Method f(::Any). "..." f(x, y = 1) = x + y  Adds docstring "..." to two Methods, namely f(::Any) and f(::Any, ::Any). ### Macros¶ "..." macro m(x) end  Adds docstring "..." to the @m(::Any) macro definition. "..." :(@m)  Adds docstring "..." to the macro named @m. ### Types¶ "..." abstract T1 "..." type T2 ... end "..." immutable T3 ... end  Adds the docstring "..." to types T1, T2, and T3. "..." type T "x" x "y" y end  Adds docstring "..." to type T, "x" to field T.x and "y" to field T.y. Also applicable to immutable types. "..." typealias A T  Adds docstring "..." to the Binding A. Bindings are used to store a reference to a particular Symbol in a Module without storing the referenced value itself. ### Modules¶ "..." module M end module M "..." M end  Adds docstring "..." to the Module M. Adding the docstring above the Module is the preferred syntax, however both are equivalent. "..." baremodule M # ... end baremodule M import Base: @doc "..." f(x) = x end  Documenting a baremodule by placing a docstring above the expression automatically imports @doc into the module. These imports must be done manually when the module expression is not documented. Empty baremodules cannot be documented. ### Global Variables¶ "..." const a = 1 "..." b = 2 "..." global c = 3  Adds docstring "..." to the Bindings a, b, and c. Note When a const definition is only used to define an alias of another definition, such as is the case with the function div and its alias ÷ in Base, do not document the alias and instead document the actual function. If the alias is documented and not the real definition then the docsystem (? mode) will not return the docstring attached to the alias when the real definition is searched for. For example you should write "..." f(x) = x + 1 const alias = f  rather than f(x) = x + 1 "..." const alias = f  "..." sym  Adds docstring "..." to the value associated with sym. Users should prefer documenting sym at it’s definition. ### Multiple Objects¶ "..." a, b  Adds docstring "..." to a and b each of which should be a documentable expression. This syntax is equivalent to "..." a "..." b  Any number of expressions many be documented together in this way. This syntax can be useful when two functions are related, such as non-mutating and mutating versions f and f!. ### Macro-generated code¶ "..." @m expression  Adds docstring "..." to expression generated by expanding @m expression. This allows for expressions decorated with @inline, @noinline, @generated, or any other macro to be documented in the same way as undecorated expressions. Macro authors should take note that only macros that generate a single expression will automatically support docstrings. If a macro returns a block containing multiple subexpressions then the subexpression that should be documented must be marked using the @__doc__() macro. The @enum macro makes use of @__doc__ to allow for documenting Enums. Examining it’s definition should serve as an example of how to use @__doc__ correctly. @__doc__(ex) Low-level macro used to mark expressions returned by a macro that should be documented. If more than one expression is marked then the same docstring is applied to each expression. macro example(f) quote$(f)() = 0
@__doc__ $(f)(x) = 1$(f)(x, y) = 2
end |> esc
end

@__doc__ has no effect when a macro that uses it is not documented.

## Markdown syntax¶

The following markdown syntax is supported in Julia.

### Inline elements¶

Here “inline” refers to elements that can be found within blocks of text, i.e. paragraphs. These include the following elements.

#### Bold¶

Surround words with two asterisks, **, to display the enclosed text in boldface.

A paragraph containing a **bold** word.

#### Italics¶

Surround words with one asterisk, *, to display the enclosed text in italics.

A paragraph containing an *emphasised* word.

#### Literals¶

Surround text that should be displayed exactly as written with single backticks,  .

A paragraph containing a literal word.

Literals should be used when writing text that refers to names of variables, functions, or other parts of a Julia program.

Tip

To include a backtick character within literal text use three backticks rather than one to enclose the text.

A paragraph containing a  backtick character .

By extension any odd number of backticks may be used to enclose a lesser number of backticks.

#### $$\LaTeX$$¶

Surround text that should be displayed as mathematics using $$\LaTeX$$ syntax with double backticks,  .

A paragraph containing some \LaTeX markup.

Tip

As with literals in the previous section, if literal backticks need to be written within double backticks use an even number greater than two. Note that if a single literal backtick needs to be included within $$\LaTeX$$ markup then two enclosing backticks is sufficient.

#### Footnote references¶

Named and numbered footnote references can be written using the following syntax. A footnote name must be a single alphanumeric word containing no punctuation.

A paragraph containing a numbered footnote [^1] and a named one [^named].

Note

The text associated with a footnote can be written anywhere within the same page as the footnote reference. The syntax used to define the footnote text is discussed in the Footnotes section below.

### Toplevel elements¶

The following elements can be written either at the “toplevel” of a document or within another “toplevel” element.

#### Paragraphs¶

A paragraph is a block of plain text, possibly containing any number of inline elements defined in the Inline elements section above, with one or more blank lines above and below it.

This is a paragraph.

And this is *another* one containing some emphasised text.
A new line, but still part of the same paragraph.

A document can be split up into different sections using headers. Headers use the following syntax:

# Level One
## Level Two
### Level Three
#### Level Four
##### Level Five
###### Level Six

A header line can contain any inline syntax in the same way as a paragraph can.

Tip

Try to avoid using too many levels of header within a single document. A heavily nested document may be indicative of a need to restructure it or split it into several pages covering separate topics.

#### Code blocks¶

Source code can be displayed as a literal block using an indent of four spaces as shown in the following example.

This is a paragraph.

function func(x)
# ...
end

Another paragraph.

Additionally, code blocks can be enclosed using triple backticks with an optional “language” to specify how a block of code should be highlighted.

A code block without a "language":

function func(x)
# ...
end

and another one with the "language" specified as julia:

julia
function func(x)
# ...
end

Note

“Fenced” code blocks, as shown in the last example, should be prefered over indented code blocks since there is no way to specify what language an indented code block is written in.

#### Block quotes¶

Text from external sources, such as quotations from books or websites, can be quoted using > characters prepended to each line of the quote as follows.

Here's a quote:

> Julia is a high-level, high-performance dynamic programming language for
> technical computing, with syntax that is familiar to users of other
> technical computing environments.

Note that a single space must appear after the > character on each line. Quoted blocks may themselves contain other toplevel or inline elements.

#### Images¶

The syntax for images is similar to the link syntax mentioned above. Prepending a ! character to a link will display an image from the specified URL rather than a link to it.

![alternative text](link/to/image.png)

#### Lists¶

Unordered lists can be written by prepending each item in a list with either *, +, or -.

A list of items:

* item one
* item two
* item three

Note the two spaces before each * and the single space after each one.

Lists can contain other nested toplevel elements such as lists, code blocks, or quoteblocks. A blank line should be left between each list item when including any toplevel elements within a list.

Another list:

* item one

* item two

f(x) = x

* And a sublist:

+ sub-item one
+ sub-item two

Note

The contents of each item in the list must line up with the first line of the item. In the above example the fenced code block must be indented by four spaces to align with the i in item two.

Ordered lists are written by replacing the “bullet” character, either *, +, or -, with a positive integer followed by either . or ).

Two ordered lists:

1. item one
2. item two
3. item three

5) item five
6) item six
7) item seven

An ordered list may start from a number other than one, as in the second list of the above example, where it is numbered from five. As with unordered lists, ordered lists can contain nested toplevel elements.

#### Display equations¶

Large $$\LaTeX$$ equations that do not fit inline within a paragraph may be written as display equations using a fenced code block with the “language” math as in the example below.

math
f(a) = \frac{1}{2\pi}\int_{0}^{2\pi} (\alpha+R\cos(\theta))d\theta

#### Footnotes¶

This syntax is paired with the inline syntax for Footnote references. Make sure to read that section as well.

Footnote text is defined using the following syntax, which is similar to footnote reference syntax, aside from the : character that is appended to the footnote label.

[^1]: Numbered footnote text.

[^note]:

Named footnote text containing several toplevel elements.

* item one
* item two
* item three

julia
function func(x)
# ...
end

Note

No checks are done during parsing to make sure that all footnote references have matching footnotes.

#### Horizontal rules¶

The equivalent of an <hr> HTML tag can be written using the following syntax:

Text above the line.

---

And text below the line.

#### Tables¶

Basic tables can be written using the syntax described below. Note that markdown tables have limited features and cannot contain nested toplevel elements unlike other elements discussed above – only inline elements are allowed. Tables must always contain a header row with column names. Cells cannot span multiple rows or columns of the table.

| Column One | Column Two | Column Three |
|:---------- | ---------- |:------------:|
| Row 1    | Column 2 |              |
| *Row* 2    | **Row** 2  | Column 3 |

Note

As illustrated in the above example each column of | characters must be aligned vertically.

A : character on either end of a column’s header separator (the row containing - characters) specifies whether the row is left-aligned, right-aligned, or (when : appears on both ends) center-aligned. Providing no : characters will default to right-aligning the column.

Specially formatted blocks with titles such as “Notes”, “Warning”, or “Tips” are known as admonitions and are used when some part of a document needs special attention. They can be defined using the following !!! syntax:

!!! note

This is the content of the note.

!!! warning "Beware!"

And this is another one.

This warning admonition has a custom title: "Beware!".

Admonitions, like most other toplevel elements, can contain other toplevel elements. When no title text, specified after the admonition type in double quotes, is included then the title used will be the type of the block, i.e. "Note" in the case of the note admonition.

## Markdown Syntax Extensions¶

Julia’s markdown supports interpolation in a very similar way to basic string literals, with the difference that it will store the object itself in the Markdown tree (as opposed to converting it to a string). When the Markdown content is rendered the usual show methods will be called, and these can be overridden as usual. This design allows the Markdown to be extended with arbitrarily complex features (such as references) without cluttering the basic syntax.

In principle, the Markdown parser itself can also be arbitrarily extended by packages, or an entirely custom flavour of Markdown can be used, but this should generally be unnecessary.


text:
# Presentation Attack Detection in Voice Biometrics¶

This package is an extension of the bob.pad.base presentation attack detection (PAD) framework package for voice biometrics.

### Extractors¶

class bob.pad.voice.extractor.LBPs(features_processor, n_lbps=2, lbp_neighbors=16, lbp_to_average=False, lbp_uniform=False, lbp_radius=1, lbp_circular=True, lbp_elbp_type='regular', band_ratios=True, **kwargs)

Extractor that computes histograms of LBP features from a textogram, which, in turn, is computed by a cepstral or spectral extractor passed as an argument.

compute_lbps(data)[source]
get_features(input_data, annotations)[source]
class bob.pad.voice.extractor.Ratios(features_processor, n_bands=5, **kwargs)
compute_ratios(data)[source]
class bob.pad.voice.extractor.VectorsRatios(features_processor, n_bands=5, feature_vector_length=50, vectors_overlap=5, **kwargs)
compute_ratios(data)[source]
class bob.pad.voice.extractor.GLCMs(features_processor, n_glcms=1, offset_vector=[[0, 1], [1, 0]], properties=True, **kwargs)

Extractor that computes histograms of LBP features from a textogram, which, in turn, is computed by a cepstral or spectral extractor passed as an argument.

compute_glcms(data)[source]
get_features(input_data, annotations)[source]
class bob.pad.voice.extractor.SpectrogramExtended(win_length_ms=20.0, win_shift_ms=10.0, n_filters=40, f_min=0.0, f_max=4000, pre_emphasis_coef=1.0, mel_scale=True, rect_filter=False, inverse_filter=False, normalize_spectrum=False, log_filter=True, energy_filter=False, energy_bands=True, vad_filter='trim_silence', normalize_feature_vector=False, **kwargs)

Extract energy bands from spectrogram and VAD labels based on the modulation of the energy around 4 Hz

compute_spectrogram(rate, data)[source]
normalize_features(features)[source]
class bob.pad.voice.extractor.LBPHistograms(features_processor, n_lbp_histograms=2, lbp_neighbors=16, lbp_to_average=False, lbp_uniform=False, lbp_radius=1, lbp_circular=True, lbp_elbp_type='regular', histograms_for_rows=False, band_ratios=True, **kwargs)

Extractor that computes histograms of LBP features from a textogram, which, in turn, is computed by a cepstral or spectral extractor passed as an argument.

compute_histograms(lbp_wrapper, lbpimages)[source]
class bob.pad.voice.extractor.DummyTF(**kwargs)

This class can be used as a simple preprocessor (reads data only) and a dummy extractor (reads saved data)

class bob.pad.voice.extractor.AudioTFExtractor(feature_layer='fc1', **kwargs)

Parameters:

feature_layer: The layer to be used as features. Possible values are fc1 or ‘fc2’.

load(extractor_file)[source]

Loads the parameters required for feature extraction from the extractor file. This function usually is only useful in combination with the train() function. In this base class implementation, it does nothing.

Parameters:

extractor_filestr

The file to read the extractor from.

train(**kwargs)[source]

This function can be overwritten to train the feature extractor. If you do this, please also register the function by calling this base class constructor and enabling the training by requires_training = True.

Parameters:

training_data[object] or [[object]]

A list of preprocessed data that can be used for training the extractor. Data will be provided in a single list, if split_training_features_by_client = False was specified in the constructor, otherwise the data will be split into lists, each of which contains the data of a single (training-)client.

extractor_filestr

The file to write. This file should be readable with the load() function.

### Algorithms¶

class bob.pad.voice.algorithm.GMM(normalize_features=False, number_of_gaussians=512, kmeans_training_iterations=25, gmm_training_iterations=10, training_threshold=0.0005, variance_threshold=0.0005, update_weights=True, update_means=True, update_variances=True, responsibility_threshold=0, INIT_SEED=2015, requires_projector_training=False, **kwargs)

Trains Logistical Regression classifier and projects testing dat on it.

load_projector(projector_file)[source]

Loads the parameters required for feature projection from file. This function usually is useful in combination with the train_projector() function. In this base class implementation, it does nothing.

Please register performs_projection = True in the constructor to enable this function.

Parameters:

projector_filestr

The file to read the projector from.

project(feature) → projected[source]

Projects the given feature into GMM space.

Parameters:

feature

The 1D feature to be projected.

Returns:

projected

The feature projected into GMM space.

project_feature(feature)[source]
read_gmm_stats(gmm_stats_file)[source]

save_gmms(projector_file)[source]

Save projector to file

score(toscore)[source]

Returns the difference between log likelihoods of being real or attack

score_for_multiple_projections(toscore)[source]

Returns the difference between log likelihoods of being real or attack

train_gmm(array)[source]
train_projector(training_features, projector_file)[source]

This function can be overwritten to train the feature projector. If you do this, please also register the function by calling this base class constructor and enabling the training by requires_projector_training = True.

Parameters:

training_features[object] or [[object]]

A list of extracted features that can be used for training the projector. Features will be provided in a single list

projector_filestr

The file to write. This file should be readable with the load_projector() function.

class bob.pad.voice.algorithm.LogRegr(use_PCA_training=False, normalize_features=False, **kwargs)

Trains Logistical Regression classifier and projects testing dat on it.

enroll(enroll_features)[source]

We do no enrollment here

load_projector(projector_file)[source]

Loads the parameters required for feature projection from file. This function usually is useful in combination with the train_projector() function. In this base class implementation, it does nothing.

Please register performs_projection = True in the constructor to enable this function.

Parameters:

projector_filestr

The file to read the projector from.

project(feature) → projected[source]

Projects the given feature into Fisher space.

Parameters:

feature

The 1D feature to be projected.

Returns:

projected

The feature projected into Fisher space.

project_feature(feature)[source]
score(toscore)[source]

Returns the output of a classifier

score_for_multiple_projections(toscore)[source]

scorescore_for_multiple_projections(toscore) -> score

This function will compute the score for a list of objects in toscore. It must be overwritten by derived classes.

Parameters:

toscore[object]

A list of objects to compute the score for.

Returns:

scorefloat

A score value for the object toscore.

train_projector(training_features, projector_file)[source]

This function can be overwritten to train the feature projector. If you do this, please also register the function by calling this base class constructor and enabling the training by requires_projector_training = True.

Parameters:

training_features[object] or [[object]]

A list of extracted features that can be used for training the projector. Features will be provided in a single list

projector_filestr

The file to write. This file should be readable with the load_projector() function.

class bob.pad.voice.algorithm.TensorflowEval(architecture_name='mlp', input_shape=[200, 81], network_size=60, normalization_file=None, **kwargs)

This class is for evaluating data stored in tensorflow tfrecord format using a pre-trained LSTM model.

load_projector(projector_file)[source]

Loads the parameters required for feature projection from file. This function usually is useful in combination with the train_projector() function. In this base class implementation, it does nothing.

Please register performs_projection = True in the constructor to enable this function.

Parameters:

projector_filestr

The file to read the projector from.

normalize_data(features)[source]
project(feature) → projected[source]

This function will project the given feature. It is assured that the load_projector() was called once before the project function is executed.

Parameters:

featureobject

The feature to be projected.

Returns:

projectedobject

The projected features. Must be writable with the write_feature() function and readable with the read_feature() function.

project_feature(feature)[source]
restore_trained_model(projector_file)[source]
score(toscore)[source]

Returns the evarage value of the probe

score_for_multiple_projections(toscore)[source]

scorescore_for_multiple_projections(toscore) -> score

Returns:

scorefloat

A score value for the object toscore.

### Databases¶

class bob.pad.voice.database.PadVoiceFile(client_id, path, attack_type=None, file_id=None)

A simple base class that defines basic properties of File object for the use in PAD experiments

load(directory=None, extension='.wav')[source]

Loads the data at the specified location and using the given extension. Override it if you need to load differently.

Parameters
• directory (str, optional) – If not empty or None, this directory is prefixed to the final file destination

• extension (str, optional) – If not empty or None, this extension is suffixed to the final file destination

Returns

The loaded data (normally numpy.ndarray).

Return type

object

bob.pad.voice.database.VoicePadFile
class bob.pad.voice.database.ASVspoofPadDatabase(protocol='CM', **kwargs)

Implements verification API for querying ASVspoof database.

objects(groups=None, protocol=None, purposes=None, model_ids=None, **kwargs)[source]

Returns a set of Files for the specific query by the user.

Keyword Parameters:

groups

One of the groups (‘dev’, ‘eval’, ‘train’) or a tuple with several of them. If ‘None’ is given (this is the default), it is considered the same as a tuple with all possible values.

protocol

The protocol for which the clients should be retrieved. The protocol is dependent on your database. If you do not have protocols defined, just ignore this field.

purposes

The purposes can be either ‘real’ or ‘attack’.

model_ids

This parameter is not supported in this implementation.

Returns: A set of Files with the specified properties.

class bob.pad.voice.database.ASVspoof2017PadDatabase(protocol='competition', **kwargs)

Implements verification API for querying ASVspoof2017 database.

convert_purposes(names, low_level_names, high_level_names)[source]

Converts purposes names from a low level to high level API

objects(groups=None, protocol=None, purposes=None, model_ids=None, **kwargs)[source]

Returns a set of Files for the specific query by the user.

Keyword Parameters:

groups

One of the groups (‘dev’, ‘eval’, ‘train’) or a tuple with several of them. If ‘None’ is given (this is the default), it is considered the same as a tuple with all possible values.

protocol

The protocol for which the clients should be retrieved. The protocol is dependent on your database. If you do not have protocols defined, just ignore this field.

purposes

The purposes can be either ‘real’ or ‘attack’.

model_ids

This parameter is not supported in this implementation.

Returns: A set of Files with the specified properties.

class bob.pad.voice.database.AVspoofPadDatabase(protocol='grandtest', **kwargs)

Implements verification API for querying AVspoof database.

annotations(file)[source]

Returns the annotations for the given File object, if available. You need to override this method in your high-level implementation. If your database does not have annotations, it should return None.

Parameters:

filebob.pad.base.database.PadFile

The file for which annotations should be returned.

Returns:

annotsdict or None

The annotations for the file, if available.

objects(groups=None, protocol=None, purposes=None, model_ids=None, **kwargs)[source]

Returns a set of Files for the specific query by the user.

Keyword Parameters:

groups

One of the groups (‘dev’, ‘eval’, ‘train’) or a tuple with several of them. If ‘None’ is given (this is the default), it is considered the same as a tuple with all possible values.

protocol

The protocol for which the clients should be retrieved. The protocol is dependent on your database. If you do not have protocols defined, just ignore this field.

purposes

The purposes can be either ‘real’ or ‘attack’.

model_ids

This parameter is not supported in this implementation.

Returns: A set of Files with the specified properties.

class bob.pad.voice.database.VoicePAPadDatabase(protocol='grandtest', **kwargs)

Implements verification API for querying voicePA database.

objects(groups=None, protocol=None, purposes=None, model_ids=None, **kwargs)[source]

Returns a set of Files for the specific query by the user.

Keyword Parameters:

groups

One of the groups (‘train’, ‘dev’, ‘eval’) or a tuple with several of them. If ‘None’ is given (this is the default), it is considered the same as a tuple with all possible values.

protocol

The protocol for which the clients should be retrieved. The protocol is dependent on your database. If you do not have protocols defined, just ignore this field.

purposes

The purposes can be either ‘real’ or ‘attack’.

model_ids

This parameter is not supported in this implementation.

Returns: A set of Files with the specified properties.


text:
# What basic knowledge is required to understand SIKE?

I'm interested in learning about Supersingular Isogeny based Key Encapsulation mechanism. Currently, I only know all the basic knowledge about how standard Elliptic Curve Cryptography, works, using Weierstrass equations. This includes the the mathematical group structure on how the Elliptic curve points are defined, and operations like point doubling and addition. I also learned how to implement it in C , with parameters of cryptographic size.

Since, SIKE is dependent on Elliptic curves, and mapping between curves, I'm guessing that my basic knowledge of how Classical Elliptic Curve Crypto works, would provide me (a beginner) some vantage point to begin understand how SIKE takes off from the ground up.

I realise, that the security of SIKE is not dependent on the classical Discrete Logarithm problem.

I cannot find online material, that presents SIKE and the mathematical basis required for it for a beginner. Even, if that's not the case, I'm willing to learn the math required from the ground up.

Every, help will be greatly appreciated! Thankyou, everyone in advance!


text:
# Efficient Explicit Formulae for Genus 2 Hyperelliptic Curves over Prime Fields and Their Implementations

### Abstract

We analyze all the cases and propose the corresponding explicit formulae for computing $2D_1 + D_2$ in one step from given divisor classes $D_1$ and $D_2$ on genus 2 hyperelliptic curves defined over prime fields. Compared with naive method, the improved formula can save two field multiplications and one field squaring each time when the arithmetic is performed in the most frequent case. Furthermore, we present a variant which trades one field inversion for fourteen field multiplications and two field squarings by using Montgomery’s trick to combine the two inversions. Experimental results show that our algorithms can save up to 13% of the time to perform a scalar multiplication on a general genus 2 hyperelliptic curve over a prime field, when compared with the best known general methods.

Publication
The 14th Annual Workshop on Selected Areas in Cryptography (SAC 2007)
##### Xinxin Fan
###### Head of Cryptography

Cryptographer | Entrepreneur | Speaker | Practitioner


text:
SERVING THE QUANTITATIVE FINANCE COMMUNITY

outrun
Topic Author
Posts: 4573
Joined: April 29th, 2016, 1:40 pm

### Is there a name for this transform method?

I ran into this algorithm and want to know more about it's mathematical properties.

It's an algorithm that allows you to do highly complex transforms of multivariate systems using arbitrary functions...but the transform is always invertible! A possible use case is e.g. to learn a function that maps complex empirical distributions into easy to sample distributions (gaussian, uniform), the inverse of which can be used to generate new samples from the empirical distribution.

Below you see an example of the forward and back transform. There is a conceptual link with copula's, but can copula's do things like this?

It goes like this: we have a D dimensional variable, $\overline{x} = \{x_1, x_2, ... x_D\}$, select a subset of coordinates that don't change, i.e. $y_1 = x_1, y_2 = x_2,.. y_d = x_d$, the remainder coordinates you can transform using any type of function depending on the unchanged coordinates, in particular you can use non-invertible ones, e.g. like f(a) = sin(a^2)

Forward transform
\begin{align} y_1 &= x_1 \\ y_2 &= x_2 \\ &... \\ y_d &= x_d \\ y_{d+1} &= x_{d+1} + f(x_1, x_2,.. x_d) \\ y_{d+2} &= x_{d+2} + g(x_1, x_2,.. x_d) \\ &... \end{align}

The tricks are now it that
1) you can back transform like this
\begin{align} x_1 &= y_1 \\ x_2 &= y_2 \\ &... \\ x_d &= y_d \\ x_{d+1} &= y_{d+1} - f(y_1, y_2,.. y_d) \\ x_{d+2} &= y_{d+2} - g(y_1, y_2,.. y_d) \\ &... \end{align}

2) and you can repeatedly select subset of coordinates and stack transforms on transform to create highly complicated transforms on all coordinates.

Is there a name for this? What limitations does this have if you compare it to general invertible mappings (are there some invertible mapping it can't do)?

Posts: 23951
Joined: September 20th, 2002, 8:30 pm

### Re: Is there a name for this transform method?

Cool! If this has a name, I'd think it would come from topology.

On curious issue is that if this algorithm operates on empirical data, then the transform outside the convex hull of the data should be undefined unless there are known properties of the data generating process to support extrapolation.

Alan
Posts: 10270
Joined: December 19th, 2001, 4:01 am
Location: California
Contact:

### Re: Is there a name for this transform method?

Interesting. A similar transformation can be used to remove the correlation in bivariate stochastic volatility models. See my comment in this thread

I don't know a name for it, though.

outrun
Topic Author
Posts: 4573
Joined: April 29th, 2016, 1:40 pm

### Re: Is there a name for this transform method?

Thanks both!
T4A, yes extrapolation is always an issue, but I think it can be prevented by mapping to a distribution with finite support like the uniform^d distribution, and then take good care of the border?

Alan, cool. I had read that thread at the time but didn't get it, but now I understand more!: that's indeed the same thing, and also invertible. Nice.

frolloos
Posts: 1621
Joined: September 27th, 2007, 5:29 pm
Location: Netherlands

### Re: Is there a name for this transform method?

Alan, cool. I had read that thread at the time but didn't get it, but now I understand more!: that's indeed the same thing, and also invertible. Nice.
Sorry for the late reply Alan, but like Outrun I didn't get it, however I still don't get it
The transformation, in this thread, or the other thread, is it like a Gram-Schmidt orthogonalization? Maybe to take a concrete example of the SABR model with beta = 1, how would it work? I don't want to hijack this thread so probably should re-post this in the other thread.

outrun
Topic Author
Posts: 4573
Joined: April 29th, 2016, 1:40 pm

### Re: Is there a name for this transform method?

Alan, cool. I had read that thread at the time but didn't get it, but now I understand more!: that's indeed the same thing, and also invertible. Nice.
Sorry for the late reply Alan, but like Outrun I didn't get it, however I still don't get it
The transformation, in this thread, or the other thread, is it like a Gram-Schmidt orthogonalization? Maybe to take a concrete example of the SABR model with beta = 1, how would it work? I don't want to hijack this thread so probably should re-post this in the other thread.
Hi frolloos, I see this as a brainstorm type of thread, so feel free to post here (and also feel tree to somewhere else if you think that better).

In my case I'm mostly interested in non-linear transforms that are invertible, not necessarily to orthogonalize things with analytical transforms in mind, however, the 'transform' bit / trick is the same.  If you have multivariate data you can split the dimensions into two sets, x,y and define a transform like this
\begin{align} x^\prime &\leftarrow f(x)\\ y^\prime &\leftarrow h(y | g(x)) \end{align}

For this to be invertible you only need f() and h() to invertible, but not g()! The reason is that you can do this
\begin{align} x &\leftarrow f^{-1}(x^\prime)\\ y &\leftarrow h^{-1}(y^\prime | g(x)) \end{align}
note that you first reconstruct $x$ so that you can then compute $g(x)$ which is needed in the second line.

the notation is a bit weird for the inverse of $h$ because its a function of both a variable $y$ and a 'conditioning' set of parameters that don't depend of $y$. I mean to say that this holds:
$y = h^{-1}(h(y | \Theta) | \Theta)$

In my application I'm using simple functions for f() and h(), and a highly non-linear and non-invertible functions for g() (a neural network), the goal is to decompose an empirical distribution as a function of independent simple distributions (blue step in the plot above), and also be able to back-transform so that I can use it as a MC distribution sampler (red step in the plot above).

Posts: 23951
Joined: September 20th, 2002, 8:30 pm

### Re: Is there a name for this transform method?

Interesting!

How stable are your functions under bootstrap or jackknife type resamplings of the data?

outrun
Topic Author
Posts: 4573
Joined: April 29th, 2016, 1:40 pm

### Re: Is there a name for this transform method?

I'm still trying to get the paper (from the plots above) working! The paper is getting good reviews from the community, it seems to solve issues I was running into with other methods I tried earlier (GAN which is 'likelihood free', VAE which didn't converge -even when I extended it with a random forest type of frank-brain-module ).

Maybe 1-2 day? I'll keep posting progress.

outrun
Topic Author
Posts: 4573
Joined: April 29th, 2016, 1:40 pm

### Re: Is there a name for this transform method?

It works! really Cool.

In this example I'm feeding it the (S&P500, NASDAQ) joint return distribution (top left). It then learns a mapping/decomposition into a 2D Gaussian latent representation (top right). The bottom row shows that you can use the invertibility property to generate samples.

Here is a video of the training phase of the Neural Network. I really like how it's learning fat tails in the bottom left at the end of the video!

mtsm
Posts: 352
Joined: July 28th, 2010, 1:40 pm

### Re: Is there a name for this transform method?

What are you trying to do? Learn the distribution through a generative model to then sample risk scenarios?

outrun
Topic Author
Posts: 4573
Joined: April 29th, 2016, 1:40 pm

### Re: Is there a name for this transform method?

What are you trying to do? Learn the distribution through a generative model to then sample risk scenarios?
Yes, a generative model for generating samples from high dimensional distributions that capture complex details of that distribution. Also have a simple latent (and maybe low dimensional) representation which can be used to model the latent evolution in time. Application would be simulate and forecast scenarios of stocks, curves and (vol) surface.
In general I'm working on empirical deep learning method for popular mathematical modelling elements used in QF: modelling dynamics, modelling densities, simulation, dimension reduction, outlier detection, inpainting missing data.

Do you know this real NPV method?
I think it's way more useful that GANs and VAEs. E.g. when trying the Wasserstein GAN training was very unstable, -and worse-, it always ended in mode collapse. It's maybe because I experiment with low dimensional problems compared to the image datasets people benchmark against?

Posts: 23951
Joined: September 20th, 2002, 8:30 pm

### Re: Is there a name for this transform method?

A few observations:
1) In both the first example ("double U") and second example ("index vs index"), the forward map seems to create an strangely lumpy scatter plot for the latent Gaussian. There too many tight clusters and open holes in the would be gaussian. I wonder if the map construction process anomalously amplifies natural stochastic variations in point density in some way. In wonder what the map construction process does to the distribution of point neighborhoods (e.g., the Delaunay triangles or Voronoi polygons)?

2) In theory, the maps should be rotation invariant, right? The latent Gaussian can be spun about the origin. But are they?

outrun
Topic Author
Posts: 4573
Joined: April 29th, 2016, 1:40 pm

### Re: Is there a name for this transform method?

For those who don't know the details of GANs, a "GAN" is a "generative adversarial networks". It's a neural network that learns to convert D dimensional iid random variates into samples from a complex higher dimensional density. The "learning" of the complex density is done by providing a set of examples from that distribution.
A typical demo it to generate randomly faces of people like this:

Since there exist no parametric distribution of "pictures of human faces" (a 64x64 rgb image can be viewed as a point in a  64*64*3 =12.000 dimension space) you can't use likelihood based methods to fit the distribution to data. Instead a 2nd neural network gets trained in parallel to look at the generated images, and real images and tries to tell them apart. E.g. the the first network might generate random faces with just 1 eye and the second network will as some point figure that out. The two network are battling: one tries to fool the other, the second tries to find flaws. It's very much like the game between art forgery and art expert. The main benefit it that you can learn to model and sample from very complex densities without requiring a likelihood function.
The "model collapse" problem is when the first neural network decides to copy one of the high probability examples in high detail over and over again, and nothing else.  Like only paining the Mona Lisa's over and over again. The second network wont be able to tell it apart from all the other painting examples, and the game converges, but we don't end up with a good distribution sampler that converts random numbers into unique realistic paintings.
Last edited by outrun on May 17th, 2017, 7:30 pm, edited 2 times in total.

outrun
Topic Author
Posts: 4573
Joined: April 29th, 2016, 1:40 pm

### Re: Is there a name for this transform method?

2) In theory, the maps should be rotation invariant, right?  The latent Gaussian can be spun about the origin.  But are they?
thanks for the ideas.
Yes the samples can be spun, or resampled, in the video I draw a new set of samples every frame.
About the lumps: these are very early results, I only got it working this morning and wanted to post it before I had to spend the whole afternoon doing other stuff. I'm glad it's converging and not diverging like it did yesterday (due to a bug in my code).
I'll try to experiment with other topologies of the neural network (more layers, less layers, different layers).  i.e. stir the pot! It would also be good to benchmark the data likelihood against other density models fitted to this data: a simple bivariate gaussian fit, a gaussian mixture fit, a kernel density.
Things will get more interesting when I move on to more complicated densities, like the joint "volume, returns" density for a bunch of stocks, or high frequency data I have.

Posts: 23951
Joined: September 20th, 2002, 8:30 pm

### Re: Is there a name for this transform method?

What's strange is that the lumps and holes are also in the first example which you presumably copied from the paper or someone else's implementation so its not a bug in your code. Moreover, the "double U" example has a second very strange artifact: the forward map creates anomalous density below the origin and the reverse map makes the upper U more dense than the lower U.


text:
# 'Observing the observer' models

#1

Hello!

I’d like to use an ‘observe the observer’ model, in which a subject has an internal model of how stimuli might be generated (the perceptual model), which they invert; then based on the resulting posterior(latent variables| perceptual data) they respond according to a response model.
From the experimenter’s perspective, given the stimuli, subject responses and candidate models for the perceptual and response models that the subject is using (with their perceptual and response parameters), I want to get the posterior on the subject’s perceptual and response parameters.

Does STAN have a way of specifying this nested inversion? Or do I need to provide an analytical formula for the subject’s posteriors(latent| perceived stimuli)?

Thank you!
Elena

#2

I am not familiar with this kind of models, but it should IMHO be possible in Stan. In general, as long as you would be able to write a simulator that generates synthetic data according to your model you should be able to write the model down in Stan. The only exception is when you have discrete parameters (unobserved variables), which Stan cannot handle directly (but there are tricks to get around this).

#3

Not sure if I understood completely, but I think it is not possible in Stan unless you have an explicit formula for the posterior distribution of the inner model (since the inner model’s normalizing constant would probably depend on the parameters).

I understood the problem to be something like this (since this is probably wrong, you might get better answers if you explicate your model in equations):

Inner model:
p(\text{latent variables} \mid \text{perceptual data}, \text{parameters}) \\ \propto p(\text{perceptual data} \mid \text{latent variables}, \text{parameters}) p(\text{latent variables})

Outer model (contains the inner model as nested):
p( \text{parameters}, \text{latent variables} \mid \text{response}, \text{perceptual data}) \\ \propto p( \text{parameters}) p(\text{response} \mid \text{latent variables}, \text{parameters}) \\ \;\;\times p( \text{latent variables} \mid \text{perceptual data}, \text{parameters})

Stan requires you to be able to write down the unnormalized log probability of the outer model explicitly (where the unknown normalizing constant cannot depend on any of the parameters to be inferred).

I’m not sure if there is any robust probabilistic programming language that can handle this well (Anglican and Church might be able to do some… I haven’t tried). This might be a useful reference:
Tom Rainforth, Nesting Probabilistic Programs, UAI2018, http://auai.org/uai2018/proceedings/papers/92.pdf


text:
# Beware of cliff edge in Libor fallbacks

## Derivatives users may see a sudden change in the value of payoffs when Libor ends, Coremont analysts write

Everyone knows it’s happening, but nobody knows exactly when – or how.

The Libor benchmark is going away, but the precise date and timing of its discontinuation is still uncertain. Best guesses are that the rate will cease publishing at the end of 2021 or in early 2022.

Once Libor ends, financial contracts referencing the rate will rely on any fallback clauses they contain. Most derivatives will use fallback language developed by the International Swaps and Derivatives Association. The clauses will be inserted into legacy Libor contracts covered by Isda agreements via a voluntary protocol, which is expected to be published in July with an effective date of November.

The Isda fallback works by replacing the forward-looking Libor term rate with a compounded overnight risk-free rate (RFR) over the same term, plus a fixed spread to account for the difference between the two.

The adjustment spread will be a single static number for each Libor currency and tenor calculated at the point of discontinuation using historic fixing data. It is calculated by taking the five-year historical median of the basis between each Libor currency and tenor and its compounded RFR – for instance, three-month US dollar Libor and three-month compounded SOFR.

Clearing houses have signalled they will adopt the Isda protocol uniformly, meaning all cleared trades will have the fallback language when Libor ceases. Counterparties to bilateral Isda covered trades will need to adopt the protocol on a case-by-case basis.

But adopting the protocol does not solve all the problems associated with the switch. While the adjustment spread is designed to reduce the likelihood – and the size – of any value transfer between parties, it can’t eliminate this risk altogether.

At the time that Libor ceases, there is a good chance the fallback spread will be relatively close to the historic median. However, there is also a possibility that the spread will be significantly above, or even below, the historic median. This year, the three-month USD Libor/SOFR spread has climbed to around 140 basis points, 115bp above the historic spread. The current fallback methodology exposes users to the possibility of a large arbitrary jump in the value of Libor-indexed payoffs around the discontinuation date.

Short of completely closing all Libor exposure, this risk is unhedgeable.

The adjustment spread is calculated as the median of every Libor/compounded RFR spread within a historic window of five years. This means the fallback rate for a given Libor fixing cannot be determined until the end of its underlying period.

For example, to calculate the USD three-month Libor fallback as of today, we must wait for the risk-free rate, SOFR, to fix over the next three months. At the end of that period the three months’ worth of SOFR fixings are compounded up and the historic spread applied. In the case of a six-month Libor level, we must wait six months to know the level a trade fixes at, and a year for a 12-month fixing.

To enable users to know the spread at discontinuation, Isda has introduced a time lag to make sure all the RFR data is available. The lag is different for each tenor, meaning that the historic spreads will reference different historical periods of Libor fixings (figure 2).

The decision to lag the Libor window results in an inconsistency in the Libor dates being included across different tenors – assuming all Libors are discontinued simultaneously. A period of elevated Libor/RFR spread in the year prior to discontinuation would increase the historic spread disproportionately for short-dated tenors.

Given the historic window length is five years it is unlikely that the above will have a significant impact. Any impact is further muted by the decision to calculate the historic spreads using a median average, which limits the effect of outliers in a dataset compared to using a mean average.

### Distribution of the historical spread

Using a median average, though, has the effect of placing an upper and lower bound on the historic spread once half of the history is known. Assuming a discontinuation date of January 2022, the upper and lower bound for the USD three-month historic spread would be around 35bp and 19bp, respectively.

Figure 3 shows the USD three-month Libor/compounded SOFR spread since the start of 2015. The current spread (blue) is frequently outside the highlighted (orange) upper and lower bounds of the historic spread – about 60% of the time. In other words, the spread is relatively insensitive to the next 18 months of fixings – the spread could fix at +500bp from now until 2022 and the historic spread would only be 35bp.

Similarly, figure 4 shows the distribution of USD three-month Libor/compounded SOFR spread over the past one year and five years. The distribution is wide and the spread can be very high, particularly in times of stressed markets. The historic median is approximately 25bp.

As part of the consultation on Libor fallbacks, Isda proposed a one-year transition period. This would have transitioned the applied spread linearly from the final published Libor/RFR spread to the historic spread over a one-year period. The transition period would have eliminated the cliff-edge problem described above. However, the proposal was not adopted due to concerns over its complexity.

### Implications for the market

We show the possible effect of a transition period on market behaviour leading up to Libor discontinuation. This scenario assumes that the market expects Libor to cease at some point in the first quarter of 2022 but does not know the exact date. It also assumes that the stressed funding market conditions of March 2020 apply as we approach discontinuation. So, three-month USD Libor is at 1.4% and compounded three-month SOFR at around 0.0%. The spread of 140bp compares to a long-term historic spread of 25bp. For convenience, we use USD three-month Libor and assume the underlying RFR curve is completely flat at 0%.

In this scenario, the market knows that at some point in the first quarter of 2022 the value of Libor-indexed payoffs will fall from 1.4% to 0.25%. It does not know exactly when this will happen so will naturally price a probability-weighted average of the different possible times.

Figure 5 below shows how we would expect the Libor forward curve to look, with and without a transition period.

The orange graphic depicts a no-transition scenario. The dashed paths are the potential overnight jumps from prevailing real-world Libor levels to the fallback. The solid line is the sum of these assuming all are equally probable.

The blue graphic depicts a transition scenario. The dashed paths slope due to the one-year linear transition to the fallback level. This means they are more similar to the probability-weighted solid line.

As soon as the discontinuation date is announced, all probability will shift to one of the dashed lines. In figure 6, we assume that discontinuation is announced to happen on March 9, 2022.

In a no-transition scenario (orange), the solid line snaps to the new certain dashed line. This causes the implied fixings to jump up or down depending on their date relative to discontinuation.

For an imperfectly hedged swap with a small date mismatch, the fixing jumps up by around 80bp one day before discontinuation, and jumps down by around 35bp one day after discontinuation.

In a transition scenario (blue), there is little impact as the solid curve snaps to the discontinuation curve. Even in this relatively extreme example, consecutive fixings are only moving by a few basis points.

These scenarios show the risk of large and sudden jumps in the value of consecutive Libor indexed payoffs in the absence of a transition period.

If significant Libor risk still exists in the market at this time, there is the potential for very large arbitrary value transfers between market participants. The value of these transfers would be highly sensitive to the exact choice of discontinuation date – changing it by even a day could make a huge difference.

This undesirable effect is mitigated by a transition period.

An early announcement of a Libor discontinuation date would give participants more opportunity and time to mitigate the risk of mismatched swaps while the implied forward Libor/RFR spread levels are near the historical spread levels, but it would not eliminate the possibility of a cliff-edge change when discontinuation happens.

Edmund Allen and Christopher Willis are part of the quantitative analysis group at Coremont LLP, an FCA-regulated financial services firm that provides web-based portfolio management tools and outsourcing services across investment management functions, including risk analysis, treasury and operations

Only users who have a paid subscription or are part of a corporate subscription are able to print or copy content.

To access these options, along with all other subscription benefits, please contact [email protected] or view our subscription options here: http://subscriptions.risk.net/subscribe


text:
3 years ago

# Gravastars in $f(\mathcal{G},T)$ Gravity.

This work proposes a stellar model under Gauss-Bonnet $f(\mathcal{G}, T)$ gravity with the conjecture theorized by Mazur and Mottola, well known as the gravastars. By taking into account the $f(\mathcal{G},T)$ stellar model, the structure of the gravastar with its exclusive division of three different regions namely, (i) the core interior region (ii) the junction region (shell), and (iii) the exterior region, has been investigated with reference to the existence of energy density, pressure, ultra-relativistic plasma, and repulsive forces. The different physical features like, the equation of the state parameter, length of the shell, entropy, energy-thickness relation of the gravastar shell model have been discussed. Also, some other physically valid aspects have been presented with the connection to non-singular and event-horizon free gravastar solutions, which in contrast to a black hole solution, might be stable without containing any information paradox.

Publisher URL: http://arxiv.org/abs/1801.03428

DOI: arXiv:1801.03428v1

You might also like
Never Miss Important Research

Researcher is an app designed by academics, for academics. Create a personalised feed in two minutes.
Choose from over 15,000 academics journals covering ten research areas then let Researcher deliver you papers tailored to your interests each day.

Researcher displays publicly available abstracts and doesn’t host any full article content. If the content is open access, we will direct clicks from the abstracts to the publisher website and display the PDF copy on our platform. Clicks to view the full text will be directed to the publisher website, where only users with subscriptions or access through their institution are able to view the full article.


text:
# Economical Caching

Abstract : We study the management of buffers and storages in environments with unpredictably varying prices in a competitive analysis. In the economical caching problem, there is a storage with a certain capacity. For each time step, an online algorithm is given a price from the interval $[1,\alpha]$, a consumption, and possibly a buying limit. The online algorithm has to decide the amount to purchase from some commodity, knowing the parameter $\alpha$ but without knowing how the price evolves in the future. The algorithm can purchase at most the buying limit. If it purchases more than the current consumption, then the excess is stored in the storage; otherwise, the gap between consumption and purchase must be taken from the storage. The goal is to minimize the total cost. Interesting applications are, for example, stream caching on mobile devices with different classes of service, battery management in micro hybrid cars, and the efficient purchase of resources. First we consider the simple but natural class of algorithms that can informally be described as memoryless. We show that these algorithms cannot achieve a competitive ratio below $\sqrt{\alpha}$. Then we present a more sophisticated deterministic algorithm achieving a competitive ratio of $\textstyle \frac{1}{\LambertW\left(\frac{1-\alpha}{e\alpha}\right)+1} \in \left[\frac{\sqrt{\alpha}}{\sqrt{2}}, \frac{\sqrt{\alpha}+1}{\sqrt{2}} \right] \enspace,$ where $W$ denotes the Lambert~W function. We prove that this algorithm is optimal and that not even randomized online algorithms can achieve a better competitive ratio. On the other hand, we show how to achieve a constant competitive ratio if the storage capacity of the online algorithm exceeds the storage capacity of an optimal offline algorithm by a factor of $\log \alpha$.
Keywords :
Document type :
Conference papers
Domain :

Cited literature [6 references]

https://hal.inria.fr/inria-00359792
Contributor : Publications Loria <>
Submitted on : Tuesday, February 10, 2009 - 5:05:52 PM
Last modification on : Thursday, February 8, 2018 - 4:20:02 PM
Long-term archiving on: : Tuesday, June 8, 2010 - 10:06:45 PM

### File

32-englert.pdf
Files produced by the author(s)

### Identifiers

• HAL Id : inria-00359792, version 1

### Citation

Matthias Englert, Heiko Röglin, Jacob Spönemann, Berthold Vöcking. Economical Caching. 26th International Symposium on Theoretical Aspects of Computer Science STACS 2009, Feb 2009, Freiburg, Germany. pp.385-396. ⟨inria-00359792⟩

Record views


text:
# What atomic number of an element "X" would have to become so that the 4th orbit around X would fit inside the 1st Bohr orbit of H-atom?

Aug 17, 2017

Well, the radial distance from the nucleus of a hydrogen-like atom is given by

$r = {n}^{2} \left({a}_{0} / Z\right)$.

Interestingly enough, one often sees the substitution

$\sigma = \frac{Z r}{{a}_{0}}$

in hydrogen atom wave functions. I derive this result below. Upon solving this you should get $Z = 16$.

We are asking, what would the atomic number $Z$ have to be such that the distance to the nucleus from $n = 4$ in a hydrogen-like atom (of the appropriate positive charge) is ${a}_{0}$, the Bohr radius. This is more of a numerical exercise than anything realistic...

For a given Bohr orbit, the wavelength is given by

$2 \pi r = n {\lambda}_{e}$ $\text{ } \boldsymbol{\left(1\right)}$

where $r$ is the radial distance from the nucleus, $n$ is the principal quantum number, and ${\lambda}_{e}$ is the electron wavelength.

Since electrons have rest mass ${m}_{e}$, we can invoke the de Broglie relation:

${\lambda}_{e} = \frac{h}{{m}_{e} v}$ $\text{ } \boldsymbol{\left(2\right)}$

where $v$ is its velocity and $h = 6.626 \times {10}^{- 34} \text{J"cdot"s}$ is Planck's constant.

We can thus rewrite $\left(1\right)$ as:

$2 \pi r = n \left(\frac{h}{{m}_{e} v}\right)$

=> vr = (nℏ)/m_e, $\text{ } \boldsymbol{\left(3\right)}$

where ℏ = h//2pi is the reduced Planck's constant.

Next, the coulomb force for a hydrogen-like atom is given by the derivative of the potential $V = - \frac{Z {e}^{2}}{4 \pi {\epsilon}_{0} r}$ with respect to the radial distance.

$- \frac{\partial V}{\partial r} = - \frac{\partial}{\partial r} \left[- \frac{Z {e}^{2}}{4 \pi {\epsilon}_{0} r}\right]$

$= - \frac{Z {e}^{2}}{4 \pi {\epsilon}_{0} {r}^{2}}$ $\text{ } \boldsymbol{\left(4\right)}$,

where ${\epsilon}_{0} = 8.854 \times {10}^{- 12} \text{F/m}$ is the vacuum permittivity and $e = 1.602 \times {10}^{- 19} \text{C}$ is the elementary charge.

From uniform circular motion in physics, the centripetal force (in the Bohr picture) brought about by the coulomb force (with inwards, or attraction, being negative) is given by

${F}_{c} = - \frac{{m}_{e} {v}^{2}}{r}$. $\text{ } \boldsymbol{\left(5\right)}$

Equating $\left(4\right)$ and $\left(5\right)$ (in the Bohr picture):

$\frac{{m}_{e} {v}^{2}}{r} = \frac{Z {e}^{2}}{4 \pi {\epsilon}_{0} {r}^{2}}$

$\implies \frac{Z {e}^{2}}{4 \pi {\epsilon}_{0} {m}_{e}} = {v}^{2} r$ $\text{ } \boldsymbol{\left(6\right)}$

Comparing ${\left(3\right)}^{2}$ above with $\left(6\right)$:

v^2r^2 = ((nℏ)/m_e)^2 = (Ze^2)/(4pi epsilon_0m_e) cdot r

Now if we solve this for $r$, we get...

r = ((nℏ)/m_e)^2 cdot (4pi epsilon_0m_e)/(Ze^2)

= n^2 ((4pi epsilon_0 ℏ^2)/(m_e e^2)) cdot 1/Z

By comparison with Wikipedia, we use the definition of the Bohr radius, ${a}_{0}$, to get:

$\textcolor{b l u e}{\overline{\underline{| \stackrel{\text{ ")(" "r = n^2 (a_0/Z)" }}{|}}}}$

So for a hydrogen-like atom, if we want $r = {a}_{0}$, we must have:

$Z = \frac{{n}^{2} \cdot {a}_{0}}{r}$

$= {n}^{2} \cdot {\cancel{{a}_{0} / {a}_{0}}}^{1}$

For the fourth Bohr orbit, we have $n = 4$, so $\textcolor{b l u e}{Z = 16}$. Thus we are looking at the sulfur cation, ${\text{S}}^{15 +}$, which is ridiculous to accomplish in real life!


text:
Interpreting results from Sobol sensitivity analysis in R

I'm trying to use the sobol2007 model in the R sensitivity package. I'm doing runs on a model with 26 parameters, and using 2 sets of 500 monte-carlo samples to seed the analysis, and nboot=500. This results in 14k runs

When I generate the sensitivity results, I'm expecting numbers in 0..1, but I get both * negative numbers * very high numbers (e.g. 10)

When I plot the model, I can see that the confidence intervals are gigantic:

It feels like 14k runs should be reasonable to estimate this number of parameters, but maybe I'm being overly optimistic.

• am I totally unrealistic, and/or how many runs should I be using?
• can I read anything from these outputs, or are they essentially so noisy as to be worthless?
• how should I be selecting nboot - there's no guidance in the docs?
-

Sobol sensitivity indices do not require zero mean function but estimation formulae are not robust at all. To avoid this kind of problem, a new formula has just been coded in the version 1.6 of the sensitivity package: soboljansen()

-

It looks like the sobol sensitivity model requires zero-mean data to function:

X1 <- data.frame(matrix(runif(8 * n), nrow = n))
X2 <- data.frame(matrix(runif(8 * n), nrow = n)) #Random samples
x <- sobol(model = NULL, X1 = X1, X2 = X2, order = 1, nboot = 100) #Create model, first order only
r <- as.matrix(x\$X,ncol=8) %*% c(1,2,3,4,5,6,7,8); #Response is proportional to factor number
tell( x, (r-mean(r))/sd(r) ); plot(x) #Standardised

tell( x, r-mean(r) ); plot(x) #Zero mean

tell( x, r ); plot(x) #Unprocessed

tell( x, r*1000 ); plot(x) #Scaled

tell( x, r+40 ); plot(x) #Offset

So altogether it looks like scaling doesn't make much difference, but a non-zero mean throws it off completely.

-