text:
# Upgrading to Meteor 1.3 on Ubuntu 14.04

In a recent post, Install Meteor on Ubuntu 14.04, I documented the install process for Meteor – at that time the current version was 1.2.1. Well, the new version – 1.3 – is out and I will briefly document the upgrade process and provide some links to new guides and tutorials that the MDG (Meteor Development Group) has released.

## New Install

If you are installing Meteor for the first time, the process has not changed:

$curl https://install.meteor.com/ | sh  You can check Meteor install instructions for the latest. As you’d expect, checking the version now gets you $ meteor --version
Meteor 1.3

## Upgrading from 1.2.1 to 1.3

The upgrade is even easier than the install! Amazingly, a simple (do this in a directory that is not a Meteor project):

$meteor update  That’s it – you don’t even have to use curl! If you already running version 1.3 (and didn’t know it) you’ll be told you’re running the latest version. So, no worries about running the update command. If you have already been working with Meteor, old projects can be updated by running meteor update in the project directory; something like this: $ cd project-directory
$meteor update  I have not tried this yet and do not know what types of changes happen when you update a project – so, be careful! I would suggest a backup of the project – as always – before trying! ## Changes in version 1.3 This new version has quite a few changes in the way Meteor projects work – I won’t attempt to describe them here – check out the Metero 1.3 announcement for more details. Briefly, for beginner Meteor developers like myself, the changes are quite dramatic and will take some getting used to. For example, the start project setup is more complex – this change makes sense to me because the directory structure is similar to the one would create as a project developed. To see this, create a test-project: $ meteor create test-project
Created a new Meteor app in 'test-project'.

To run your new app:
cd test-project
meteor

If you are new to Meteor, try some of the learning resources here:
https://www.meteor.com/learn

This is the same as before. However, looking at the files created, we see the following:

$cd test-project/$ tree .
.
├── client
│   ├── main.css
│   ├── main.html
│   └── main.js
├── package.json
└── server
└── main.js

2 directories, 5 files

The project structure already has client and server directories – things that were previously created by the developer. In addition, there is also a package.json file, reflecting the much tight integration with npm. Finally, for this post, if we look at the one of the files – server/main.js in this case – we see more modern, ES2015 code:

import { Meteor } from 'meteor/meteor';

Meteor.startup(() => {
// code to run on server at startup
});

In particular, notice the explicit import of Meteor and the use of an arrow function.

Further information on this version of Meteor is pretty limited at this point. Resources like the Discover Meteor book and the Coursera Meteor specialization will be referencing the previous version of Meteor – however, that might change quickly! For now, check out the nice tutorials (choose blaze-, angular- or react-flavored):

If you don’t know the difference I’d suggest starting with default Blaze templates, as they are pretty straightforward. Also, the Official Meteor Guide has been expanded and looks really useful; you should check it out.

Okay, that’s it. As always, comments and corrections are welcome – just be nice.


text:
Relief Valve

Relief valve with opening area linearly dependent on pressure difference

 Description The Relief Valve component models a hydraulic relief valve as a sharp-edge orifice with the orifice area dependent on the pressure across the valve. The area varies linearly from ${A}_{\mathrm{closed}}$ to ${A}_{\mathrm{open}}$ as the pressure varies from ${p}_{\mathrm{closed}}$ to ${p}_{\mathrm{open}}$, and remains at the endpoints for pressures outside this range. Based on the orifice area, the pressure vs flow rate relationships are derived by the formulation used in the Orifice component.
 Optional Volumes The boolean parameters Use volume A and Use volume B, when true, add optional volumes ${V}_{A}$  and ${V}_{B}$ to ports A and B, respectively. See Port Volumes for details. If two orfices or valves are connected, enabling a volume at the common port reduces the the stiffness of the system and improves the solvability.

Connections

 Name Description Modelica ID $\mathrm{portA}$ Upstream hydraulic port portA $\mathrm{portB}$ Downstream hydraulic port portB

Parameters

General Parameters

 Name Default Units Description Modelica ID ${C}_{d}$ $\frac{7}{10}$ Flow-discharge coefficient Cd ${\mathrm{\Re }}_{\mathrm{Cr}}$ $12$ Reynolds number at critical flow ReCr ${p}_{\mathrm{closed}}$ $1.9·{10}^{7}$ $\mathrm{Pa}$ Pressure at which valve is fully closed ($A={A}_{\mathrm{closed}}$) pclosed ${p}_{\mathrm{open}}$ $2.05·{10}^{7}$ $\mathrm{Pa}$ Pressure at which valve is fully open (A = A_open) popen ${A}_{\mathrm{open}}$ $1·{10}^{-5}$ ${m}^{2}$ Valve area when fully open Aopen ${A}_{\mathrm{closed}}$ $1·{10}^{-12}$ ${m}^{2}$ Valve area when closed (leakage) Aclosed

Volume Parameters

 Name Default Units Description Modelica ID Use volume A $\mathrm{false}$ When true a hydraulic volume chamber is added to portA useVolumeA ${V}_{A}$ $1·{10}^{-6}$ ${m}^{3}$ Volume of chamber A Va Use volume B $\mathrm{false}$ When true a hydraulic volume chamber is added to portB useVolumeB ${V}_{B}$ $1·{10}^{-6}$ ${m}^{3}$ Volume of chamber B Vb

format: plain


text:
## The Annals of Statistics

### Laplace approximations for hypergeometric functions with matrix argument

#### Abstract

In this paper we present Laplace approximations for two functions of matrix argument: the Type I confluent hypergeometric function and the Gauss hypergeometric function. Both of these functions play an important role in distribution theory in multivariate analysis, but from a practical point of view they have proved challenging, and they have acquired a reputation for being difficult to approximate. Appealing features of the approximations we present are: (i) they are fully explicit (and simple to evaluate in practice); and (ii) typically, they have excellent numerical accuracy. The excellent numerical accuracy is demonstrated in the calculation of noncentral moments of Wilks' $\Lambda$ and the likelihood ratio statistic for testing block independence, and in the calculation of the CDF of the noncentral distribution of Wilks' $\Lambda$ via a sequential saddlepoint approximation. Relative error properties of these approximations are also studied, and it is noted that the approximations have uniformly bounded relative errors in important cases.

#### Article information

Source
Ann. Statist., Volume 30, Number 4 (2002), 1155-1177.

Dates
First available in Project Euclid: 10 September 2002

Permanent link to this document
https://projecteuclid.org/euclid.aos/1031689021

Digital Object Identifier
doi:10.1214/aos/1031689021

Mathematical Reviews number (MathSciNet)
MR1926172

Zentralblatt MATH identifier
1029.62047

Subjects
Primary: 62H10: Distribution of statistics
Secondary: 62E17: Approximations to distributions (nonasymptotic)

#### Citation

Butler, Roland W.; Wood, Andrew T. A. Laplace approximations for hypergeometric functions with matrix argument. Ann. Statist. 30 (2002), no. 4, 1155--1177. doi:10.1214/aos/1031689021. https://projecteuclid.org/euclid.aos/1031689021

#### References

• ABRAMOWITZ, M. and STEGUN, I. A. (1972). Handbook of Mathematical Functions, 9th ed. Dover, New York.
• BAGCHI, P. and KADANE, J. B. (1991). Laplace approximations to posterior moments and marginal distributions on circles, spheres, and cy linders. Canad. J. Statist. 19 67-77.
• BARNDORFF-NIELSEN, O. E. and WOOD, A. T. A. (1998). On large deviations and choice of ancillary for p and r. Bernoulli 4 35-63.
• BINGHAM, C., CHANG, T. and RICHARDS, D. (1992). Approximating the matrix Fisher and Bingham distributions: applications to spherical regression and Procrustes analysis. J. Multivariate Anal. 41 314-337.
• BLEISTEIN, N. and HANDELSMAN, R. A. (1975). Asy mptotic Expansions of Integrals. Dover, New York.
• BOOTH, J. G., BUTLER, R. W., HUZURBAZAR, S. and WOOD, A. T. A. (1995). Saddlepoint approximations for p-values of some tests of covariance matrices. J. Statist. Comput. Simulation 53 165-180.
• BUTLER, R. W., HUZURBAZAR, S. and BOOTH, J. G. (1992). Saddlepoint approximations for the Bartlett-Nanda-Pillai trace statistic in multivariate analysis. Biometrika 79 705-715.
• BUTLER, R. W. and WOOD, A. T. A. (2000). Laplace approximations for hy pergeometric functions of matrix argument. Technical Report 00-05, Div. Statistics, Univ. Nottingham. Available at www.maths.nottingham.ac.uk/statsdiv/research/reports.html.
• CHIKUSE, Y. (1998). Density estimation on the Stiefel manifold. J. Multivariate Anal. 66 188-206.
• CONSTANTINE, A. G. (1963). Some noncentral distribution problems in multivariate analysis. Ann. Math. Statist. 34 1270-1285.
• CONSTANTINE, A. G. and MUIRHEAD, R. J. (1976). Asy mptotic expansions for distributions of latent roots in multivariate analysis. J. Multivariate Anal. 6 369-391.
• EFSTATHIOU, M., GUTIÉRREZ-PEÑA, E. and SMITH, A. F. M. (1998). Laplace approximations for natural exponential families with cuts. Scand. J. Statist. 25 77-92.
• FISHER, R. A. (1990). Statistical Methods, Experimental Design, and Scientific Inference. Oxford Univ. Press.
• FRASER, D. A. S., REID, N. and WONG, A. (1991). Exponential linear models: a two-pass procedure for saddlepoint approximation. J. Roy. Statist. Soc. Ser. B 53 483-492.
• GLy NN, W. J. and MUIRHEAD, R. J. (1978). Inference in canonical correlation analysis. J. Multivariate Anal. 8 468-478.
• GUPTA, R. D. and RICHARDS, D. ST. P. (1985). Hy pergeometric functions of scalar matrix argument are expressible in terms of classical hy pergeometric functions. SIAM J. Math. Anal. 16 852-858.
• HERZ, C. S. (1955). Bessel functions of matrix argument. Ann. Math. 61 474-523.
• JAMES, A. T. (1964). Distributions of matrix variates and latent roots derived from normal samples. Ann. Math. Statist. 35 475-501.
• JENSEN, J. L. (1995). Saddlepoint Approximations. Oxford Univ. Press.
• JOHNSON, N. L. and KOTZ, S. (1972). Distributions in Statistics: Continuous Multivariate Distributions. Wiley, New York.
• LUGANNANI, R. and RICE, S. O. (1980). Saddlepoint approximations for the distribution of the sum of independent random variables. Adv. Appl. Probab. 12 475-490.
• MAGNUS, J. R. and NEUDECKER, H. (1988). Matrix Differential Calculus with Applications in Statistics and Econometrics. Wiley, New York.
• MATHAI, A. M. (1993). A Handbook of Generalized Special Functions for Statistical and physical Sciences. Clarendon Press, Oxford.
• MUIRHEAD, R. J. (1975). Expressions for some hy pergeometric functions of matrix argument with applications. J. Multivariate Anal. 5 283-293.
• MUIRHEAD, R. J. (1978). Latent roots and matrix variates: a review of some asy mptotic results. Ann. Statist. 6 5-33.
• MUIRHEAD, R. J. (1982). Aspects of Multivariate Statistical Theory. Wiley, New York.
• OLVER, F. W. J. (1991). Uniform, exponentially improved, asy mptotic expansions for the confluent hy pergeometric function and other integral transforms. SIAM J. Math. Anal. 22 1475- 1489.
• OLVER, F. W. J. (1993). Exponentially-improved asy mptotic solutions of ordinary differential equations. I. The confluent hy pergeometric function. SIAM J. Math. Anal. 24 756-767.
• PARIS, R. B. (1992). Smoothing of the Stokes phenomenon using Mellin-Barnes integrals. Asy mptotic methods in analysis and combinatorics. J. Comput. Appl. Math. 41 117-133.
• PHILLIPS, P. C. B. (1983). Exact small sample theory in the simultaneous equations model. In Handbook of Econometrics 1 (Z. Griliches, and M. D. Intriligator, eds.) Chapter 8. North-Holland, Amsterdam.
• ROY, S. N. (1939). p-statistics, or some generalizations in analysis of variance appropriate to multivariate problems. Sankhy¯a 4 381-396.
• SRIVASTAVA, M. S. and CARTER, E. M. (1980). Asy mptotic expansions for hy pergeometric functions. In Multivariate Analy sis V (P. Krishnaiah, ed.) 337-347. North-Holland, Amsterdam.
• SUGIURA, N. (1969). Asy mptotic non-null distributions of the likelihood ratio criteria for covariance matrix under local alternatives. Mimeo Ser. 609, Inst. Statistics, Univ. North Carolina, Chapel Hill.
• SUGIURA, N. (1973). Further asy mptotic formulas for the non-null distributions of three statistics for multivariate linear hy pothesis. Ann. Inst. Statist. Math. 25 153-163.
• SUGIURA, N. and FUJIKOSHI, Y. (1969). Asy mptotic expansions of the non-null distributions of the likelihood ratio criteria for multivariate linear hy pothesis and independence. Ann. Math. Statist. 40 942-952.
• SUGIy AMA, T. (1967). On the distribution of the largest latent root of the covariance matrix. Ann. Math. Statist. 38 1148-1151.
• FORT COLLINS, COLORADO 80523 E-MAIL: walrus@stat.colostate.edu SCHOOL OF MATHEMATICAL SCIENCES UNIVERSITY OF NOTTINGHAM NOTTINGHAM NG7 2RD UNITED KINGDOM E-MAIL: atw@maths.nott.ac.uk


text:
1
JEE Main 2021 (Online) 25th February Morning Slot
MCQ (Single Correct Answer)
+4
-1
$$\mathop {\lim }\limits_{n \to \infty } {\left( {1 + {{1 + {1 \over 2} + ........ + {1 \over n}} \over {{n^2}}}} \right)^n}$$ is equal to :
A
$${{1 \over 2}}$$
B
1
C
0
D
$${{1 \over e}}$$
2
JEE Main 2021 (Online) 24th February Morning Slot
MCQ (Single Correct Answer)
+4
-1
If f : R $$\to$$ R is a function defined by f(x)= [x - 1] $$\cos \left( {{{2x - 1} \over 2}} \right)\pi$$, where [.] denotes the greatest integer function, then f is :
A
continuous for every real x
B
discontinuous at all integral values of x except at x = 1
C
discontinuous only at x = 1
D
continuous only at x = 1
3
JEE Main 2020 (Online) 6th September Evening Slot
MCQ (Single Correct Answer)
+4
-1
Let f : R $$\to$$ R be a function defined by
f(x) = max {x, x2}. Let S denote the set of all points in R, where f is not differentiable. Then :
A
{0, 1}
B
{0}
C
$$\phi$$(an empty set)
D
{1}
4
JEE Main 2020 (Online) 6th September Evening Slot
MCQ (Single Correct Answer)
+4
-1
For all twice differentiable functions f : R $$\to$$ R,
with f(0) = f(1) = f'(0) = 0
A
f''(x) $$\ne$$ 0, at every point x $$\in$$ (0, 1)
B
f''(x) = 0, for some x $$\in$$ (0, 1)
C
f''(0) = 0
D
f''(x) = 0, at every point x $$\in$$ (0, 1)
JEE Main Subjects
Physics
Mechanics
Electricity
Optics
Modern Physics
Chemistry
Physical Chemistry
Inorganic Chemistry
Organic Chemistry
Mathematics
Algebra
Trigonometry
Coordinate Geometry
Calculus
EXAM MAP
Joint Entrance Examination
JEE MainJEE AdvancedWB JEE
Graduate Aptitude Test in Engineering
GATE CSEGATE ECEGATE EEGATE MEGATE CEGATE PIGATE IN
Medical
NEET
© ExamGOAL 2023


text:
# The diameter of a sphere is decreased by 25%. By what per cent does its curved surface area decrease?

Let the diameter of a sphere be d.

After decreasing, diameter of the sphere
= d – $$\frac{25}{100}$$ x d
= d –$$\frac{1}{4} d = \frac{3}{4} d$$

Since, surface area of a sphere
= $$4\pi r^2$$
= $$\pi (2r)^2$$
= $$\pi d^2$$

Surface area of a sphere, when diameter of the sphere is

= $$\pi (\frac{3}{4} d)^2$$
= $$\pi \frac{9}{16} d^2$$

Now, decrease percentage in curved surface area
= $$\frac{\pi d^2 - \pi \frac{9}{16} d^2 }{\pi d^2} × 100$$
= $$\frac{16-9}{16} × 100$$
= $$\frac{7}{16} × 100$$
= 43.75%


text:
Kostenloses Online Meetup: Generative AI mit Adalab (28. März) Mehr erfahren
Artificial Intelligence

Transfer Learning for Text Classification with Siamese Networks

Autor:in
Lesezeit
14 min

Text classification is a field in natural language processing (NLP), which assigns text to given classes. With applications in sentiment analysis, spam detection or information retrieval, text classification has been widely researched. In this blogpost, I want to present my master’s thesis, which focused on transfer learning for text classification.

Thereby, one shot learning is a classification method aiming at learning from one or few samples per class. I was inspired by this paper from Koch et al., where one shot learning was applied on image classification. Similar to this approach, I want to use the architecture of the Siamese network for text classification. This network architecture can be found in the classification of images (Koch et al., 2015) and signature verification (Bromely et al., 1994) but was barely used in the field of NLP. In this blogpost, I want to give an overview of transfer learning with Siamese networks.

Transfer Learning

Recently, neural networks have been established as a popular approach in the field of NLP, requiring a large amount of labeled data. With the expansion of the online world, user comments are increasing daily and thus offer a versatile source to analyze; they just have to be labeled. Unfortunately, this process is often manual and therefore time consuming. Thus, one could assume that there is not enough data available for the task of aspect extraction. We want to overcome this problem by using transfer learning, an approach which learns with a small amount of data.

An extreme case of transfer learning is one shot learning, a classification method that learns from one or only a few samples per class. It addresses the real problem of often not having many data points available. The idea is based on the fact that the model tries to predict classes from which only one or a few samples exist in the evaluation set (Fei-Fei et al., 2006). In the field of image classification, one shot learning has been researched widely (e.g. Koch et al, 2015 or Fei Fei et al. 2016), but we want to integrate one shot learning for text classification.

Use case

The increasing popularity of online platforms encourages users to pose their opinions in various fields, such as products, movies and food. These opinions are often biased, with emotions being a valuable source to analyze. Opinion mining is a task in NLP, which deals with the analysis of text towards an emotion. Question-answering forums and social media platforms are its main sources. In opinion mining, the aspect-based sentiment analysis (ABSA) plays an important role. It deals with the aspect, or topic, extraction and sentiment classification of a text block. In this way, ABSA helps finding out what the text block thematizes and with with emotion it encompasses specific topics. In this use case, transfer learning can be used by learning on text similarity and applying on aspect extraction, the first step of ABSA. This blogpost will focus on the application of aspect extraction, although the task can be easily applied to several other use cases.

Problem description

The main goal is to extract an aspect, or label, from a text block, which can be a sentence or an entire comment. In the following, we use sentences for simplification. In the experiments, we compare a test sentence to other sentences whose labels are known. These sentences form a support set. For the label prediction of a test sentence, we assign the label of the most similar sentence in the support set to the test set. In addition to the transfer learning approach, we combine this with one shot learning. The method selects one sentence from each label class in order to compare it to the test sentence. If we select $$k$$ sentences from each label class, we call this setting few shot learning. Formally, the problem is defined as follows: Let $$L$$ be the number of label classes. Given a test sentence $$s$$ and few samples $${s_l}^L_{l=1}$$ with $$i \in { 1,..,L }$$ from a support set, compare $$s$$ to $$s_l$$ and assign $$s$$ the aspect of the most similar sentence to it (Koch et al., 2015):

$$L^∗ =\arg \max p^{(l)}$$,

with $$p^{(l)}$$ representing the similarity.

Siamese Networks

Named after the Siamese twins (or conjoined twins), the network architecture consists of two input objects and one output that ideally indicates the similarity between the two input objects (Bromley et al., 1994). The objects are pushed into the network which consists of two distinct sub-networks sharing their weights such that similar input objects are mapped in a similar way. These networks create a common representation of the input objects which are merged with a layer. That layer can employ a distance function and the output is mainly a probability value ranging between 0 and 1. In this blogpost, the Siamese network takes two text blocks as input and outputs their similarity. Below, we show the abstract building blocks of the network.

In the first step, the network takes the sentence in a raw text format as input. Afterwards, it computes the sentence embedding of dimension 512 with the help of the Google Universal Sentence Encoder (USE) (Cer et al., 2018). This embedding is then pushed through a neural network, which maps the USE sentence embedding to a smaller dimension. The neural network consists of one to two dense layers. The other input sentence is similarly processed through the exact same network, while the neural networks share their weights. In this way, it is guaranteed that similar sentences pushed through different neural networks do not have completely different sentence embeddings. The final sentence representations are compared to each other using the absolute distance. This distance is pushed through another dense layer which is our output layer and produces the probability $$p \in [0,1]$$, which denotes the similarity score between the two inputs.

The training proceeds as follows in that we sample equally similar and dissimilar sentence pairs per batch. The similarity is based on the grouping of the dataset. Take the use case of ABSA as an example. In this case, two sentences might be similar when they are labeled with the same aspect. The training for dissimilarity follows in the same way. We performed the training on a dataset which contains roughly 10.000 sentences about organic food crawled from question-answering forums. In total, we can generate $$\frac{n \cdot (n-1)}{2}$$ sentence pairs. Thus, the training can already be performed on a small dataset.

Learning approaches

One Shot Learning

In real life settings, we might only have a few sentences per class. Often, the dataset is unbalanced so that some classes have many sentences and some only have one. We reproduce this setting by selecting exactly one sentence per aspect class at random. The idea behind this setting is that the selected sentence acts as a representative for this class. In this experiment, we would like to find out if the Siamese network is able to detect text similarity based on one shot per class.

Few Shot Learning

Text is random in nature and when crawled from social media platforms it might be grammatically wrong or contain words in non-standard spelling. We want to guarantee a reliable representation for an entire class because one sentence might not be sufficient when picked at random. Since we do not want to influence the sampling with domain knowledge, we extend the idea of one shot learning by sampling not only one but $$k \in N$$ sentences from a class. This setting is referred to as few shot learning. In this way, we hope to make the classes more representative during the evaluation. Additionally, we were interested in how well the model performs when we do not sample the sentences but simply compare $$s$$ to all sentences from all classes in the evaluation set. This implies that the classes are not treated fairly since some have less sentences than others. Nevertheless, the experiment adapts to realistic settings and acts as a reference to the experiments with a fixed $$k$$.

Text classification

Let us now have a look at the results of the text classification. We select the following exemplary sentences from the topic organic food in order to demonstrate the aspect prediction:

Genetically Modified Organisms (GMO)

• Genetically modified food might taste better but is unhealthy!
• GMO turned out to trigger allergic reactions.

Environment

• The popularity of organic food has increased since it turned out to be good for the environment.
• Producing organically excludes the use of pesticides and chemicals.

Social Factors

• Food produced organically is too expensive and definitely not affordable for everyone.
• The geographic distance between farmer and consumer can lead to higher prices.

Health

• It is proven that organic has certain health benefits.
• Organic food is healthy.

When classifying the sentences, we declare one sentence as test sentence and compare it with several other sentences. Since the setting is one shot learning, we sample exactly one sentence per class and compare these to the test sentence. An exemplary comparison is visualized in the figure below. On the left, we see the test sentence, on the right the support set with the sentences whose labels are known. Since the second comparison delivers the highest similarity score, we conclude that these sentences are the most similar to each other. Thus, we assign the aspect Social to the test sentence. When we have a look at the definitions above, this classification is correct.

In addition, the experiment was processed for several other sentences whose results are listed in the table below. In the one shot learning approach, we can see that the last sentence pair is classified correctly to Social factors according to our definitions. Unfortunately, the first and the second classification did not match according to our definitions. In the first classification, the sentence It is proven that organic has certain health benefits. was categorized into the aspect class health, while the second sentence The popularity of organic food has increased since it turned out to be good for the environment. belongs to the class environment.

In the second classification, the sentence Producing organically excludes the use of pesticides and chemicals. was defined to be from the category environment, while the sentence GMO turned out to trigger allergic reactions. was categorized into GMO. Since both sentences thematize modified food, the classification is not completely wrong, but just does not fit our definitions. Contrary, the few shot learning approach improves the classification by far. In average, this learning approach categorizes the sentences more often correctly, which can be seen in the three classifications below. The only classification which did not fit our definitions is the second sentence pair, which is equivalent to the second sentence pair in the one shot learning approach.

Learning approach Sentence pairs Similarity score
One shot learning
• It is proven that organic has certain health benefits. (Health)
• The popularity of organic food has increased since it turned out to be good for the environment. (Environment)
0.4989
• Producing organically excludes the use of pesticides and chemicals. (Environment)
• GMO turned out to trigger allergic reactions. (GMO)
0.5039
• Food produced organically is too expensive and definitely not affordable for everyone. (Social factors)
• The geographic distance between farmer and consumer can lead to higher prices. (Social factors)
0.532
Few shot learning
• It is proven that organic has certain health benefits. (Health)
• Organic food is healthy. (Health)
0.5149
• Producing organically excludes the use of pesticides and chemicals. (Environment)
• GMO turned out to trigger allergic reactions. (GMO)
0.5083
• Food produced organically is too expensive and definitely not affordable for everyone. (Social factors)
• The geographic distance between farmer and consumer can lead to higher prices. (Social factors)
0.5262

Conclusion

In this blogpost, we investigated how transfer learning can be used for text classification, computing text similarity with the architecture of a Siamese networks. We saw that text similarity can be learned and applied to the task of aspect extraction. In this setting, we introduced one shot learning and few shot learning. One shot learning turned out to be difficult for text classification, while few shot learning can achieve significantly better results, increasing the constant $$k$$. Lastly, the experiments showed that the prediction highly depends on the dataset and its class definitions.

Ähnliche Artikel

Deep CSG: Extraction of Geometric Objects from 3D Point Clouds Using Deep Learning

Recent research in the fields of Computer Vision and Computer Graphics often addresses the extraction of geometric

MEHR ERFAHREN

ELK Stack Deployment mit Vagrant

Der Elasticsearch Logstash Kibana (ELK) Stack ist eine Sammlung von aufeinander abgestimmten Applikationen für das Sammeln, Verarbeiten und Visualisieren von

MEHR ERFAHREN

Mein Einstieg als Data Engineer Business Intelligence

Als Data Engineer im Bereich Business Intelligence unterstütze ich unsere Kunden tagtäglich dabei, Prozesse zu implementieren, die

MEHR ERFAHREN


text:
## Elementary Geometry for College Students (6th Edition)

Ray BF is the angle bisector and $\angle$ ABC.
To create ray BF: Step 1: Place the compass point on vertex B. Step 2: Adjust the compass to a width that is a little shorter than both sides AB and BC. The setting of the compass does not need to be exact. Step 3: Draw an arc across both sides of the triangle (across sides AB and BC). Label the intersection of the arc and AB as point D. Label the intersection of the arc and BC as point E. Step 4: Without changing the compass setting, place the compass point on D and draw an arc in the interior of $\angle$ ABC. Step 5: Without changing the compass setting, place the compass point on E and draw an arc in the interior of $\angle$ ABC. The two arcs created in step 4 and step 5 should intersect. Label the intersection point F. Step 6: Use a straightedge to draw a line from vertex B through point F, creating a ray. Sep 7: Ray BF is the angle bisector of $\angle$ ABC.


text:
Next Meeting: June 2: Social gathering Next Installfest: TBD Latest News: May. 19: LUGOD special elections Page last updated: 2002 Apr 23 22:55
Re: [vox-tech] breakinguplongwordsinlatex

# Re: [vox-tech] breakinguplongwordsinlatex

begin Shawn P. Neugebauer <spn@ucdavis.edu>
> On Tuesday 23 April 2002 05:28 pm, you wrote:
> > begin nbs <nbs@sonic.net>
> > > On Tue, Apr 23, 2002 at 05:10:13PM -0700, Peter Jay Salzman wrote:
> > > <snip>
> > > > \linebreak[0]: if it's convenient, please consider line breaking here.
> > > > \linebreak[1]: please line break here.
> > > > \linebreak[2]: line break here.
> > > > \linebreak[3]: you better line break here or there's hell to pay
> > > > \linebreak[4]: hello latex, this is god speaking. thou shalt line
> > > > break.
> > >
> > > Hmm.. this doesn't do much for me.  I'm not in control of the data
> > > being sent.  (In this case, if the people making the data would need
> > > to go through the trouble of inserting a "\linebreak" command, they
> > > may as well just stick a space in there instead, since it will Do The
> > > Right Thing, anyway.  -  I'm thinking this is what I'm going to have to
> > > have them do.)
> >
> > ok, i think i understand a bit more.   can you make a parbox of a
> > certain width?   i think sticking everything in the parbox should give
> > you the desired result.
>
> (fyi--would have been helpful to know up front that you didn't want
> to modify the data).
>
> the parbox trick, which is usually so useful in controlling tables, does
> not work here.  it does not force a word to break, rather, it causes
> an overfull \hbox situation.  try it out.

wow -- cool, another latex user.  you must be a grad student or postdoc
in one of the sciences.  what department are you in?

i'd have to agree -- it can be done.  but it's way beyond the abilities
of any latex user i know.

suggestion:
1. use shawn's suggestion.  preprocess the data.
2. post to comp.text.tex.  the people there will know the answer.

pete
_______________________________________________
vox-tech mailing list
vox-tech@lists.lugod.org
http://lists.lugod.org/mailman/listinfo/vox-tech


text:
Welcome Forums General PowerShell Q&A List AD Groups, members, count of AD membership per person of specific AD Groups

• Author
Posts
• #222216
Participant
Topics: 1
Replies: 2
Points: -4
Rank: Member

Dear PowerShell.org community

This is my first post, so hopefully I have not missed anything.

I have hit brick wall on the next step to troubleshoot.

In a nut shell what I am trying to achieve is to list Active Directory Group Name that starts with the prefix of AXCH (as an example) list the username\members in these Active Directory Groups and finally the count of many AD Group membership per person\user for AD groups starting with the prefix of AXCH.   (AXCH is a made up example)

Some of the script is working, and getting the result I need it is just the final part, of getting the count command to work to count how many AD groups per individual user is a member of any AD group starting with the name of AXCH.

Below is the script

$adgroups = Get-ADGroup -Filter {name -like "*AXCH*"}$data = foreach ($adgroup in$adgroups) {
$members =$adgroup | get-adgroupmember -Recursive
foreach ($member in$members) {
[PSCustomObject]@{
Group = $adgroup.name NumberofMembersinADGroup = ($members.DistinguishedName).count
Members = $member.name NumberofGroupsUserMemberOf = ($member.DistinguishedName).count
}
}
}

$data  So what this script s doing is from the top, find AD group that match\begin with the name of AXCH (made up name), then using the variable of$adgroups use a “for each” command to find nested ad groups and members.

The script is working up to a point and I can export to the screen or into a CSV file.  The problem I am facing if the line highlighted in RED also pasted below

NumberofGroupsUserMemberOf = ($member.DistinguishedName).count  Basically I thought by using the command, would count how many AD groups per individual user is a member of any AD group starting with the name of AXCH. Instead the command returns the count value of 1. Which I guess when I think about makes sense as it is counting the member name of the AD groups starting with AXCH and you can only have one AD account with the same name in one group. Which is perhaps I am thinking I need to do a different command, hence why I am making my first post in here. So to clarify for example made up username called “Joe blogs” exist in several AD groups that have the prefix of AXCH (again made up AD group name) so he is a member of AXCH-1 \ AXCH-2 \ AXCH-3 & AXCH-4 what I would like is for a command to count those 4 AD groups and give me a return value of 4 against his user name, as he is a member of 4 AD groups. At the moment my scripts returns the value of 1 even though he is a member of multiple AD groups. If anyone could help with a command I could add to my script, or if I have to create a new script all together just so I can create a report that list the AD Group, the individual member\username, and then count value of how many AD Groups membership per member for AD groups starting with the prefix of AXCH Many Thanks for taking the time to read this post. Best Paul • #222282 Participant Topics: 4 Replies: 2249 Points: 5,494 Rank: Community MVP Paul, welcome to Powershell.org. If I got it right it might be better/easier to run 2 separate queries to get the info you’re after. $Pattern = '*AXCH*'
$ADGroupList = Get-ADGroup -Filter "name -like '$Pattern'"

$GroupStatistics = foreach ($ADGroup in $ADGroupList) {$MemberList = Get-ADGroupMember -Identity $ADGroup.sAMAccountName -Recursive | Where-Object {$_.objectClass -eq 'user'}
[PSCustomObject]@{
ADGroup                      = $ADGroup.name ADGroupMemberCount = ($MemberList.DistinguishedName).count
ADGroupMemmberList = $MemberList.sAMAccountName -join ',' } }$GroupStatistics | Format-Table -AutoSize # -Wrap

$UniqueMemberList =$GroupStatistics.ADGroupMemmberList | foreach-object { $_ -split ',' } | Sort-Object -Unique$GroupMemberStatistics =
foreach ($Member in$UniqueMemberList) {
$ADUser = Get-ADUser -Identity$Member -Properties MemberOf
[PSCustomObject]@{
ADUser = $ADUser.name ADGouprCount = ($ADUser.MemberOf | Where-Object { $_ -match$Pattern }).count
}
}
$GroupMemberStatistics | Format-Table -AutoSize • #222399 Participant Topics: 1 Replies: 2 Points: -4 Rank: Member Hi Olaf Firstly thank you very much for taking the time to read and reply to my post, it is much appreciated, I am definitely further then I was, and enjoyed understanding how you would script something. Hit a problem with the final part of the script for the line ADGouprCount = ($ADUser.MemberOf | Where-Object { $_ -match$Pattern }).count

It gives the following error message when the script run as a whole

 parsing "*EXCH*" - Quantifier {x,y} following nothing.
At line:23 char:59
+ ... Count = ($ADuser.MemberOf | Where-Object {$_ -match $Pattern }).coun ... + ~~~~~~~~~~~~~~~~~~ + CategoryInfo : OperationStopped: (:) [], ArgumentException + FullyQualifiedErrorId : System.ArgumentException  So EXCH is the filter I am using for the variable for$Pattern to find AD Groups that begin with EXCH. All the other parts of the scripts work fine and gets the results needed.

From the trouble shooting I have done so far is if I change the command below to just use .count I get further and it actually count each user ad group members but for All AD groups not just ones that start with EXCH.

ADGouprCount = $ADuser.MemberOf.Count  It seems to not like the variable of$Pattern if I change the command to use the below command, it run without error but I get no AD group Count.

 ADGouprCount = ($ADUser.MemberOf | Where-Object {$_ -match $ADGroupList }).count  I find it a bit odd as the first section of the script runs for the$GroupStatistics section, which uses that variable of \$Pattern so it is unclear why it fails to use this variable for the second part of the script.

So to re-iterate the only part that is failing in the script is getting the ADGroupCount for specific groups that start with EXCH

Is there anything you can suggest \ troubleshooting steps \ alternative command.

Many thanks

Paul

• #222402
Participant
Topics: 4
Replies: 2249
Points: 5,494
Rank: Community MVP

Paul, … sorry .. stupid me.

Of course I tested the code but of course with another pattern. One that could provide results in my environment. Then I copied the code here and just changed it to fit your need by just taking your pattern. When you use the operator -match then you’re using regular expressions and for regular expressions the asterisk (*) is a special charachter. And you your case we actually do not need it at all. So try to change your pattern to be ‘EXCH’ instead of ‘*EXCH*’ and it should work (I hope).

• #222408
Participant
Topics: 4
Replies: 2249
Points: 5,494
Rank: Community MVP

I’m afraid to edit my already existing post because they often get blocked when editted again. So here an additional explanation.

As I mentioned the asterisk (*) is a special charachter when it comes to regular expressions. In particular it means “whatever comes before the asterisk should appear 0 or more times”. So it’s shorthand for the quantifier “{0,}

In your case there is nothing before the asterisk. That’s why the error “… Quantifier {x,y} following nothing.” raises.

If you like to read more about regular expressions – here is a good place to start: https://www.regular-expressions.info

• #222465
Participant
Topics: 1
Replies: 2
Points: -4
Rank: Member

Hi Olaf

Many Thanks for your reply, that did the trick able to produce the report I needed.

Also thank you for the providing documentation on regular expressions \ study material as that was going to be my next question.

Are there any good online courses \ websites \ books you recommend to learn power shell?

I am currently going through online courses by Don Jones \ Jeff Hicks \ Michael Bender. It is helping but would you recommend any sites \ material that really help you get to your level \ anything you would recommend?

Many Thanks Again

Paul

• #222477
Participant
Topics: 4
Replies: 2249
Points: 5,494
Rank: Community MVP

I am currently going through online courses by Don Jones \ Jeff Hicks \ Michael Bender. It is helping but would you recommend any sites \ material that really help you get to your level \ anything you would recommend?

I work with Powershell for about 13 years now. The most experience comes with time. For beginners I usually recommend the beginner video course with Jeffrey Snover but I think your level is already above that. A free book to look something up if needed could be this: Windows PowerShell™ 4: TFM. I think the best way to get better is practice practice practice. 😉


text:
A satellite is in a circular orbit about the Earth at a distance of one Earth

A satellite is in a circular orbit about the earth at

• Test Prep
• 3
• 71% (7) 5 out of 7 people found this document helpful

This preview shows page 2 - 3 out of 3 pages.

10. A satellite is in a circular orbit about the Earth at a distance of one Earth radius above the surface. What is the speed of the satellite? (The radius of the Earth is 6.4 106m, and G= 6.67 1011Nm2/kg2.) ____ 11. If the mass of Mars is 0.107 times that of Earth, and its radius is 0.530 that of Earth, estimate the gravitational acceleration gat the surface of Mars. (gearth= 9.80 m/s2)


text:
# Dynamic optimization problem.

My starting equations are the following:

$V^{e}=w+\beta.((1-s).V^{e}+s.V^{u}(t))\\V^{u}(t)=\begin{matrix} \\max \\a(t) \end{matrix}b(t)-\psi.a(t)+\beta.[\pi(a(t)).V^{e}+(1-\pi(a(t))).V^{u}(t+1)]\\\pi(a(t))=1-exp(-\phi.a(t))\\b(t)=b.t^{-\mu}$

All the parameters are fixed, except from $a$ and $\phi$. When I use the first order condition on $V^{u}(t+1)$ with respect to $a(t)$, I obtain the following condition: $$\beta.\pi'.[V^{e}-V^{u}(t+1)]=\psi$$ My goal is to find, after calibration of the parameters, for which $\phi$ we have $V^{u}(t)>V^{e}$ after 13 periods. I have tried to put $V^{u}(t)$ on the right side of the first expression and $V^{u}(t+1)$ on the right side of the second one. After several substitutions, I get the following expression:$$V^{u}(t)=\frac{1}{\frac{1-\pi-\pi.\beta}{1-\pi}-\frac{s}{1-\beta(1-s)}}.[b(t)-\psi.a(t)+\frac{1-\pi}{2-\pi}.(\frac{\psi.\pi}{\pi'}+\frac{\pi.\beta.w}{(1-\pi).(1-\beta(1-s))})]$$ But this gets me nowhere near my problem. Does anyone have any idea on how I can have an optimization of $a(t)$, and therefore an a value for $\phi$ ? Thanks in advance.

-


text:
# Giải câu 3 trang 46 sách toán VNEN lớp 8 tập 2

• 1 Đánh giá

Câu 3: Trang 46 sách VNEN 8 tập 2

Giải các bất phương trình sau:

a) 3 - 2x > 4 ; b) 3x + 4 2 ; c) $\frac{4x - 5}{3}$ > $\frac{7 - x}{5}$ ; d) $\frac{2x + 3}{- 4}$ $\geq$ $\frac{4 - x}{- 3}$

e) < $x^{2}$ - 3 ; f) (x - 3)(x + 3) $\leq$ $(x + 2)^{2}$ + 3.

Bài làm:

Giải câu a)

Ta có: 3 - 2x > 4 3 - 4 > 2x - 1 > 2x x < $\frac{- 1}{2}$.

Giải câu b)

Ta có: 3x + 4 2 $\Leftrightarrow$ 3x 2 - 4 $\Leftrightarrow$ 3x - 2 $\Leftrightarrow$ x $\frac{- 2}{3}$

Giải câu c)

Ta có: > $\frac{7 - x}{5}$

$\frac{20x - 25}{15}$ > $\frac{21 - 3x}{15}$

20x - 25 > 21 - 3x

20x + 3x > 21 + 25

23x > 46

x > 2

Giải câu d)

Ta có: $\geq$ $\frac{4 - x}{- 3}$

$\frac{6x + 9}{- 12}$ $\geq$ $\frac{16 - 4x}{- 12}$

6x + 9 $\leq$ 16 - 4x

10x $\leq$ 7

x $\leq$ $\frac{7}{10}$

Giải câu e)

Ta có: < $x^{2}$ - 3

$x^{2}$ - 6x + 9 < $x^{2}$ - 3

9 + 3 < $x^{2}$ - $x^{2}$ + 6x

12 < 6x

x > 2

Giải câu f)

Ta có: (x - 3)(x + 3) $(x + 2)^{2}$ + 3

- 9 $\leq$ + 4x + 4 + 3

- - 4x $\leq$ 4 + 3 + 9

- 4x 16

x - 4.

• 7 lượt xem
Cập nhật: 07/09/2021


text: I figured it out. Turns out the USB 3.0 bus was waking it up. All I had to do was disable XHCI in /proc/acpi/wakeup and it fixed the problem. I’ve blogged about how to make the change permanent.


text:
## CryptoDB

### Paper: A Dedicated Processor for the eta Pairing

Authors: Robert Ronan Colm O hEigeartaigh Colin Murphy Michael Scott Tim Kerins W.P. Marnane URL: http://eprint.iacr.org/2005/330 Search ePrint Search Google The $\eta$ pairing is an efficient computation technique based on a generalization of the Duursma Lee method for calculating the Tate pairing. The pairing can be computed very efficiently on genus 2 hyperelliptic curves. In this paper it is demonstrated that this pairing operation is well suited to a dedicated parallel hardware implementation. An $\eta$ pairing processor is described in detail and the architectures required for such a system are discussed. Prototype implementation results are presented over a base field of $\mathbb{F}_{2^{103}}$ and the advantages of implementing the pairing on the dedicated processor are discussed.
##### BibTeX
@misc{eprint-2005-12664,
title={A Dedicated Processor for the eta Pairing},
booktitle={IACR Eprint archive},
keywords={implementation / pairing-based cryptosystem, $\eta$ pairing, genus 2 hyperelliptic, characteristic 2, dedicated processor},
url={http://eprint.iacr.org/2005/330},
note={ robertr@rennes.ucc.ie 13046 received 20 Sep 2005},
author={Robert Ronan and Colm O hEigeartaigh and Colin Murphy and Michael Scott and Tim Kerins and W.P. Marnane},
year=2005
}


text:
ASK - ANSWER - COMMENT - VOTE

MathsGee is Zero-Rated (You do not need data to access) on: Telkom |Dimension Data | Rain | MWEB

0 like 0 dislike
10 views
Solve $x^{2}+6 x+2=0$ by completing the square
| 10 views

0 like 0 dislike

We cannot use any of the techniques in factorization to solve for $x$. In this situation, we use the technique called completing the square. This makes the quadratic equation into a perfect square trinomial, i.e. the form $a^{2}+2 a b+b^{2}=(a+b)^{2}$.

NOTE: This technique is valid only when 1 is the coefficient of $\mathrm{x}^{2}$.

Here are the steps used to complete the square

Step 1 . Move the constant term to the right:
$$x^{2}+6 x=-2$$

Step 2. Add the square of half the coefficient of $x$ to both sides. In this case, add the square of half of 6 i.e. add the square of 3 .
$$x^{2}+6 x+9=-2+9$$
The left-hand side is now the perfect square of $(x+3) . \quad$ half of the
$$(x+3)^{2}=7$$

We know that if $a^{2}=b, a=\pm b$

Therefore, $x+3=\pm \sqrt{7}$
$$x=-3 \pm \sqrt{7}$$

by Gold Status (10,261 points)

0 like 0 dislike


text:
Tolerance interval

A tolerance interval is a statistical interval within which, with some confidence level, a specified proportion of a sampled population falls. "More speciﬁcally, a 100×p%/100×(1−α) tolerance interval provides limits within which at least a certain proportion (p) of the population falls with a given level of conﬁdence (1−α)."[1] "A (p, 1−α) tolerance interval (TI) based on a sample is constructed so that it would include at least a proportion p of the sampled population with conﬁdence 1−α; such a TI is usually referred to as p-content − (1−α) coverage TI."[2] "A (p, 1−α) upper tolerance limit (TL) is simply an 1−α upper confidence limit for the 100 p percentile of the population."[2]

A tolerance interval can be seen as a statistical version of a probability interval. "In the parameters-known case, a 95% tolerance interval and a 95% prediction interval are the same."[3] If we knew a population's exact parameters, we would be able to compute a range within which a certain proportion of the population falls. For example, if we know a population is normally distributed with mean $\mu$ and standard deviation $\sigma$, then the interval $\mu \pm 1.96\sigma$ includes 95% of the population (1.96 is the z-score for 95% coverage of a normally distributed population).

However, if we have only a sample from the population, we know only the sample mean $\hat{\mu}$ and sample standard deviation $\hat{\sigma}$, which are only estimates of the true parameters. In that case, $\hat{\mu} \pm 1.96\hat{\sigma}$ will not necessarily include 95% of the population, due to variance in these estimates. A tolerance interval bounds this variance by introducing a confidence level $\gamma$, which is the confidence with which this interval actually includes the specified proportion of the population. For a normally distributed population, a z-score can be transformed into a "k factor" for a given $\gamma$ via lookup tables or several approximation formulas.[4] "As the degrees of freedom approach infinity, the prediction and tolerance intervals become equal."[5]

Relation to other intervals

The tolerance interval is less widely known than the confidence interval and prediction interval, a situation some educators have lamented, as it can lead to misuse of the other intervals where a tolerance interval is more appropriate.[6][7]

The tolerance interval differs from a confidence interval in that the confidence interval bounds a single-valued population parameter (the mean or the variance, for example) with some confidence, while the tolerance interval bounds the range of data values that includes a specific proportion of the population. Whereas a confidence interval's size is entirely due to sampling error, and will approach a zero-width interval at the true population parameter as sample size increases, a tolerance interval's size is due partly to sampling error and partly to actual variance in the population, and will approach the population's probability interval as sample size increases.[6][7]

The tolerance interval is related to a prediction interval in that both put bounds on variation in future samples. The prediction interval only bounds a single future sample, however, whereas a tolerance interval bounds the entire population (equivalently, an arbitrary sequence of future samples). In other words, a prediction interval covers a specified proportion of a population on average, whereas a tolerance interval covers it with a certain confidence level, making the tolerance interval more appropriate if a single interval is intended to bound multiple future samples.[8][7]

Examples

[6] gives the following example:

So consider once again a proverbial EPA mileage test scenario, in which several nominally identical autos of a particular model are tested to produce mileage figures $y_1, y_2, ..., y_n$. If such data are processed to produce a 95% confidence interval for the mean mileage of the model, it is, for example, possible to use it to project the mean or total gasoline consumption for the manufactured fleet of such autos over their first 5,000 miles of use. Such an interval, would however, not be of much help to a person renting one of these cars and wondering whether the (full) 10-gallon tank of gas will suffice to carry him the 350 miles to his destination. For that job, a prediction interval would be much more useful. (Consider the differing implications of being "95% sure" that $\mu \ge 35$ as opposed to being "95% sure" that $y_{n+1} \ge 35$.) But neither a confidence interval for $\mu$ nor a prediction interval for a single additional mileage is exactly what is needed by a design engineer charged with determining how large a gas tank the model really needs to guarantee that 99% of the autos produced will have a 400-mile cruising range. What the engineer really needs is a tolerance interval for a fraction $p = .99$ of mileages of such autos.

Another example is given by [8]:

The air lead levels were collected from n=15 different areas within the facility. It was noted that the log-transformed lead levels fitted a normal distribution well (that is, the data are from a lognormal distribution). Let mu and sigma^2, respectively, denote the population mean and variance for the log-transformed data. If X denotes the corresponding random variable, we thus have X ~ N(mu, sigma^2). We note that exp(mu) is the median air lead level. A confidence interval for mu can be constructed the usual way, based on the t-distribution; this in turn will provide a confidence interval for the median air lead level. If $\bar{X}$ and S denote the sample mean and standard deviation of the log-transformed data for a sample of size n, a 95% confidence interval for mu is given by $\bar{X} \pm t_{n-1,0.975} S / \sqrt(n)$, where $t_{m,1-\alpha}$ denotes the 1-alpha quantile of a t-distribution with m degrees of freedom. It may also be of interest to derive a 95% upper confidence bound for the median air lead level. Such a bound for mu is given by $\bar{X} + t_{n-1,0.95} S / \sqrt{n}$. Consequently, a 95% upper confidence bound for the median air lead is given by $\exp{\left( \bar{X} + t_{n-1,0.95} S / \sqrt{n} \right)}$. Now suppose we want to predict the air lead level at a particular area within the laboratory. A 95% upper prediction limit for the log-transformed lead level is given by $\bar{X} + t_{n-1,0.95} S \sqrt{\left( 1 + 1/n \right)}$. A two-sided prediction interval can be similarly computed. The meaning and interpretation of these intervals are well known. For example, if the confidence interval $\bar{X} \pm t_{n-1,0.975} S / \sqrt{n}$ is computed repeatedly from independent samples, 95% of the intervals so computed will include the true value of mu, in the long run. In other words, the interval is meant to provide information concerning the parameter mu only. A prediction interval has a similar interpretation, and is meant to provide information concerning a single lead level only. Now suppose we want to use the sample to conclude whether or not at least 95% of the population lead levels are below a threshold. The confidence interval and prediction interval cannot answer this question, since the confidence interval is only for the median lead level, and the prediction interval is only for a single lead level. What is required is a tolerance interval; more specifically, an upper tolerance limit. The upper tolerance limit is to be computed subject to the condition that at least 95% of the population lead levels is below the limit, with a certain confidence level, say 99%.

• "Preliminaries", Chap. 1 in [8]; available at [1]
• [9]

References

1. ^ D. S. Young (2010), Book Reviews: "Statistical Tolerance Regions: Theory, Applications, and Computation", TECHNOMETRICS, FEBRUARY 2010, VOL. 52, NO. 1, pp.143-144.
2. ^ a b Krishnamoorthy, K. and Lian, Xiaodong(2011) 'Closed-form approximate tolerance intervals for some general linear models and comparison studies', Journal of Statistical Computation and Simulation,, First published on: 13 June 2011 doi:10.1080/00949655.2010.545061
3. ^ Thomas P. Ryan (22 June 2007). Modern Engineering Statistics. John Wiley & Sons. pp. 222–. ISBN 978-0-470-12843-5. Retrieved 22 February 2013.
4. ^ "Tolerance intervals for a normal distribution". Engineering Statistics Handbook. NIST/Sematech. 2010. Retrieved 2011-08-26.
5. ^ De Gryze, S.; Langhans, I.; Vandebroek, M. (2007). "Using the correct intervals for prediction: A tutorial on tolerance intervals for ordinary least-squares regression". Chemometrics and Intelligent Laboratory Systems 87 (2): 147. doi:10.1016/j.chemolab.2007.03.002. edit
6. ^ a b c Stephen B. Vardeman (1992). "What about the Other Intervals?". The American Statistician 46 (3): 193–197. JSTOR 2685212.
7. ^ a b c Mark J. Nelson (2011-08-14). "You might want a tolerance interval". Retrieved 2011-08-26.
8. ^ a b c K. Krishnamoorthy and Thomas Mathew (2009). Statistical Tolerance Regions: Theory, Applications, and Computation. John Wiley and Sons. pp. 1–6. ISBN 0-470-38026-8.
9. ^ Derek S. Young (8 2010). "tolerance: An R Package for Estimating Tolerance Intervals". Journal of Statistical Software 36 (5): 1–39. ISSN 1548-7660. Retrieved 19 February, 2013.


text:
# How do you solve |4x| - 12 = 4?

The solutions are $4 , - 4$
|4x| - 12 = 4=>abs(4x)=12+4=>4*absx=16=> absx=4=>x=+4 or x=-4


text:
I have an old copy of Time of Tumult that has the original writeup of the Locust Crusade. That chapter, of course, is crammed full of stuff, because it provides writeups for Alchemicals, talks about Autochthonia, and describes the Locust Crusade itself.

I dimly recall another book -- possibly a first edition book -- that provided alternative Locust Crusades. The chronicle that I'm running right now is set primarily in the North and I am considering introducing the Locust Crusade as a plotline in the North. However, I am exceedingly lazy, and if someone else has already done the legwork for me on this, I am inclined to steal it.

From reviewing the previews of the PDFs of the 2nd edition Alchemicals and Autochthonia books, it looks like the info I'm looking for isn't in there. But I'm not positive.

Can anybody point me in the right direction?

-

The book you are thinking of is almost certainly: Exalted: The Autochthonians. This was the 1st Ed equivalent to the Manual of Exalted power which also included setting information on Autochthonia and Alchemical Exalted. It also provided 3 separate scenarios on how the Locust Crusade could play out. It's been awhile since I've read them but if I recall correctly one roughly follows the Locust Crusade as laid out by Time of Tumult, one involves the players running around Creation to try and reactivate some manses to awaken Autochthon and the last involves the invasion of Autochthon by the Deathlord First and Forsaken Lion.

As towards having the Locust Crusade affect the south in none of the scenarios got too far in that direction. The default crusade still rampages all over the south and the one in Autochthonia naturally takes place in there. The only one that might touch upon in it is the remaining scenario since that involves traipsing all over Creation.

-
Thanks -- that must be what I am thinking of. I guess I'll have to be creative on my own if I want the invasion to happen in the North. Or leave it going on in the South until my players' characters reach the point that they're aware of the South in any real terms. – Jim Kiley Oct 26 '11 at 17:52
I think it should also be mentioned that many of the fans didn't have a particularly good view of the locust crusade as detailed in said book, so don't feel to obligated to uphold it's views on the matter. – sebsmith Oct 26 '11 at 20:25

The Locust Crusade doesn't happen in 2e by Default

You can read a summary of the relevant forum posts from the designers on this blog: http://nobilis.me/quotes:not-the-locust-crusade


text:
+0

# gen math

0
300
1

what is the answer to (y-a)^3-9 / 3(y-a)^2-6(y-a)-9

Aug 27, 2017

#1
+2298
0

This division symbol in your expression causes the ambiguity in your expression. When using a division symbol, you must clarify your expression with the use of parentheses or brackets. The strict interpretation of your expression is the following:

$$(y-a)^3-\frac{9}{3}(y-a)^2-6(y-a)-9$$

However, I could also imagine your expression any of the ones below:

$$\frac{(y-a)^3-9}{3(y-a)^2}-6(y-a)-9$$

$$\frac{(y-a)^3-9}{3(y-a)^2-6(y-a)}-9$$

$$\frac{(y-a)^3-9}{3(y-a)^2-6(y-a)-9}$$

Which one is it? Or is it something else?

Aug 27, 2017


text:
# Choosing the Right Radix: Measurement or Mathematics?

I recently wrote a post about radix sorting, and found that for large arrays of unsigned integers a handwritten implementation beats Arrays.sort. However, I paid no attention to the choice of radix and used a default of eight bits. It turns out this was a lucky choice: modifying my benchmark to parametrise the radix, I observed a maximum at one byte, regardless of the size of array.

Is this an algorithmic or technical phenomenon? Is this something that could have been predicted on the back of an envelope without running a benchmark?

### Extended Benchmark Results

Size Radix Score Score Error (99.9%) Unit
100 2 135.559923 7.72397 ops/ms
100 4 262.854579 37.372678 ops/ms
100 8 345.038234 30.954927 ops/ms
100 16 7.717496 1.144967 ops/ms
1000 2 13.892142 1.522749 ops/ms
1000 4 27.712719 4.057162 ops/ms
1000 8 52.253497 4.761172 ops/ms
1000 16 7.656033 0.499627 ops/ms
10000 2 1.627354 0.186948 ops/ms
10000 4 3.620869 0.029128 ops/ms
10000 8 6.435789 0.610848 ops/ms
10000 16 3.703248 0.45177 ops/ms
100000 2 0.144575 0.014348 ops/ms
100000 4 0.281837 0.025707 ops/ms
100000 8 0.543274 0.031553 ops/ms
100000 16 0.533998 0.126949 ops/ms
1000000 2 0.011293 0.001429 ops/ms
1000000 4 0.021128 0.003137 ops/ms
1000000 8 0.037376 0.005783 ops/ms
1000000 16 0.031053 0.007987 ops/ms

### Modeling

To model the execution time of the algorithm, we can write $t = f(r, n)$, where $n \in \mathbb{N}$ is the length of the input array, and $r \in [1, 32)$ is the size in bits of the radix. We can inspect if the model predicts non-monotonic execution time with a minimum (corresponding to maximal throughput), or if $t$ increases indefinitely as a function of $r$. If we find a plausible model predicting a minimum, temporarily treating $r$ as continuous, we can solve $\frac{\partial f}{\partial r}|_{n=N, r \in [1,32)} = 0$ to find the theoretically optimal radix. This pre-supposes we derive a non-monotonic model.

### Constructing a Model

We need to write down an equation before we can do any calculus, which requires two dangerous assumptions.

1. Each operation has the same cost, making the execution time proportional to the number of operation.
2. The costs of operations do not vary as a function of $n$ or $r$.

This means all we need to do is find a formula for the number of operations, and then vary $n$ and $r$. The usual pitfall in this approach relates to the first assumption, in that memory accesses are modelled as uniform cost; memory access can vary widely in cost ranging from registers to RAM on another socket. We are about to fall foul of both assumptions constructing an intuitive model of the algorithm’s loop.

while (shift < Integer.SIZE) {
Arrays.fill(histogram, 0);
for (int i = 0; i < data.length; ++i) {
++histogram[((data[i] & mask) >> shift) + 1];
}
for (int i = 0; i < 1 << radix; ++i) {
histogram[i + 1] += histogram[i];
}
for (int i = 0; i < data.length; ++i) {
copy[histogram[(data[i] & mask) >> shift]++] = data[i];
}
for (int i = 0; i < data.length; ++i) {
data[i] = copy[i];
}
}

The outer loop depends on the choice of radix while the inner loops depend on the size of the array and the choice of radix. There are five obvious aspects to capture:

• The first inner loop takes time proportional to $n$
• The third and fourth inner loops take time proportional to $n$
• We can factor the per-element costs of loops 1, 3 and 4 into a constant $a$
• The second inner loop takes time proportional to $2^r$, modeled with by the term $b2^r$
• The body of the loop executes $32/r$ times

This can be summarised as the formula:

$f(r, n) = 32\frac{(3an + b2^r)}{r}$

It was claimed the algorithm had linear complexity in $n$ and it only has a linear term in $n$. Good. However, the exponential $r$ term in the numerator dominates the linear term in the denominator, making the function monotonic in $r$. The model fails to predict the observed throughput maximising radix. There are clearly much more complicated mechanisms at play than can be captured counting operations.

# Sorting Unsigned Integers Faster in Java

I discovered a curious resource for audio-visualising sort algorithms, which is exciting for two reasons. The first is that I finally feel like I understand Alexander Scriabin: he was not a composer. He discovered Tim Sort 80 years before Tim Peters and called it Black Mass. (If you aren’t familiar with the piece, fast-forward to 1:40 to hear the congruence.)

The second reason was that I noticed Radix Sort (LSD). While it was an affront to my senses, it used a mere 800 array accesses and no comparisons! I was unaware of this algorithm so delved deeper and implemented it for integers, and benchmarked my code against Arrays.sort.

It is taken as given by many (myself included, or am I just projecting my thoughts on to others?) that $O(n \log n)$ is the best you can do in a sort algorithm. But this is actually only true for sort algorithms which depend on comparison. If you can afford to restrict the data types your sort algorithm supports to types with a positional interpretation (java.util can’t because it needs to be ubiquitous and maintainable), you can get away with a linear time algorithm.

Radix sort, along with the closely related counting sort, does not use comparisons. Instead, the data is interpreted as a fixed length string of symbols. For each position, the cumulative histogram of symbols is computed to calculate sort indices. While the data needs to be scanned several times, the algorithm scales linearly and the overhead of the multiple scans is amortised for large arrays.

As you can see on Wikipedia, there are two kinds of radix sort: Least Significant Digit and Most Significant Digit. This dichotomy relates to the order the (representational) string of symbols is traversed in. I implemented and benchmarked the LSD version for integers.

### Implementation

The implementation interprets an integer as the concatenation of n bit string symbols of fixed size size 32/n. It performs n passes over the array, starting with the least significant bits, which it modifies in place. For each pass the data is scanned three times, in order to:

1. Compute the cumulative histogram over the symbols in their natural sort order
2. Copy the value with symbol k to the mth position in a buffer, where m is defined by the cumulative density of k.
3. Copy the buffer back into the original array

The implementation, which won’t work unless the chunks are proper divisors of 32, is below. The bonus (or caveat) is that it automatically supports unsigned integers. The code could be modified slightly to work with signed integers at a performance cost.

import java.util.Arrays;

this(Byte.SIZE);
}

}

public void sort(int[] data) {
int[] histogram = new int[(1 << radix) + 1];
int shift = 0;
int[] copy = new int[data.length];
while (shift < Integer.SIZE) {
Arrays.fill(histogram, 0);
for (int i = 0; i < data.length; ++i) {
++histogram[((data[i] & mask) >> shift) + 1];
}
for (int i = 0; i < 1 << radix; ++i) {
histogram[i + 1] += histogram[i];
}
for (int i = 0; i < data.length; ++i) {
copy[histogram[(data[i] & mask) >> shift]++] = data[i];
}
for (int i = 0; i < data.length; ++i) {
data[i] = copy[i];
}
}
}
}

The time complexity is obviously linear, a temporary buffer is allocated, but in comparison to Arrays.sort it looks fairly spartan. Instinctively, cache locality looks fairly poor because the second inner loop of the three jumps all over the place. Will this implementation beat Arrays.sort (for integers)?

### Benchmark

The algorithm is measured using arrays of random positive integers, for which both algorithms are equivalent, from a range of sizes. This isn’t always the best idea (the Tim Sort algorithm comes into its own on nearly sorted data), so take the result below with a pinch of salt. Care must be taken to copy the array in the benchmark since both algorithms are in-place.

public void launchBenchmark(String... jvmArgs) throws Exception {
Options opt = new OptionsBuilder()
.include(this.getClass().getName() + ".*")
.mode(Mode.SampleTime)
.mode(Mode.Throughput)
.timeUnit(TimeUnit.MILLISECONDS)
.measurementTime(TimeValue.seconds(10))
.warmupIterations(10)
.measurementIterations(10)
.forks(1)
.shouldFailOnError(true)
.shouldDoGC(true)
.jvmArgs(jvmArgs)
.resultFormat(ResultFormatType.CSV)
.build();

new Runner(opt).run();
}

@Benchmark
public void Arrays_Sort(Data data, Blackhole bh) {
int[] array = Arrays.copyOf(data.data, data.size);
Arrays.sort(array);
bh.consume(array);
}

@Benchmark
public void Radix_Sort(Data data, Blackhole bh) {
int[] array = Arrays.copyOf(data.data, data.size);
bh.consume(array);
}

public static class Data {

@Param({"100", "1000", "10000", "100000", "1000000"})
int size;

int[] data;

@Setup(Level.Trial)
public void init() {
data = createArray(size);
}
}

public static int[] createArray(int size) {
int[] array = new int[size];
Random random = new Random(0);
for (int i = 0; i < size; ++i) {
array[i] = Math.abs(random.nextInt());
}
return array;
}

Benchmark Mode Threads Samples Score Score Error (99.9%) Unit Param: size
Arrays_Sort thrpt 1 10 1304.687189 147.380334 ops/ms 100
Arrays_Sort thrpt 1 10 78.518664 9.339994 ops/ms 1000
Arrays_Sort thrpt 1 10 1.700208 0.091836 ops/ms 10000
Arrays_Sort thrpt 1 10 0.133835 0.007146 ops/ms 100000
Arrays_Sort thrpt 1 10 0.010560 0.000409 ops/ms 1000000
Radix_Sort thrpt 1 10 404.807772 24.930898 ops/ms 100
Radix_Sort thrpt 1 10 51.787409 4.881181 ops/ms 1000
Radix_Sort thrpt 1 10 6.065590 0.576709 ops/ms 10000
Radix_Sort thrpt 1 10 0.620338 0.068776 ops/ms 100000
Radix_Sort thrpt 1 10 0.043098 0.004481 ops/ms 1000000
Arrays_Sort sample 1 3088586 0.000902 0.000018 ms/op 100
Arrays_Sort·p0.00 sample 1 1 0.000394 ms/op 100
Arrays_Sort·p0.50 sample 1 1 0.000790 ms/op 100
Arrays_Sort·p0.90 sample 1 1 0.000791 ms/op 100
Arrays_Sort·p0.95 sample 1 1 0.001186 ms/op 100
Arrays_Sort·p0.99 sample 1 1 0.001974 ms/op 100
Arrays_Sort·p0.999 sample 1 1 0.020128 ms/op 100
Arrays_Sort·p0.9999 sample 1 1 0.084096 ms/op 100
Arrays_Sort·p1.00 sample 1 1 4.096000 ms/op 100
Arrays_Sort sample 1 2127794 0.011876 0.000037 ms/op 1000
Arrays_Sort·p0.00 sample 1 1 0.007896 ms/op 1000
Arrays_Sort·p0.50 sample 1 1 0.009872 ms/op 1000
Arrays_Sort·p0.90 sample 1 1 0.015408 ms/op 1000
Arrays_Sort·p0.95 sample 1 1 0.024096 ms/op 1000
Arrays_Sort·p0.99 sample 1 1 0.033920 ms/op 1000
Arrays_Sort·p0.999 sample 1 1 0.061568 ms/op 1000
Arrays_Sort·p0.9999 sample 1 1 0.894976 ms/op 1000
Arrays_Sort·p1.00 sample 1 1 4.448256 ms/op 1000
Arrays_Sort sample 1 168991 0.591169 0.001671 ms/op 10000
Arrays_Sort·p0.00 sample 1 1 0.483840 ms/op 10000
Arrays_Sort·p0.50 sample 1 1 0.563200 ms/op 10000
Arrays_Sort·p0.90 sample 1 1 0.707584 ms/op 10000
Arrays_Sort·p0.95 sample 1 1 0.766976 ms/op 10000
Arrays_Sort·p0.99 sample 1 1 0.942080 ms/op 10000
Arrays_Sort·p0.999 sample 1 1 2.058273 ms/op 10000
Arrays_Sort·p0.9999 sample 1 1 7.526102 ms/op 10000
Arrays_Sort·p1.00 sample 1 1 46.333952 ms/op 10000
Arrays_Sort sample 1 13027 7.670135 0.021512 ms/op 100000
Arrays_Sort·p0.00 sample 1 1 6.356992 ms/op 100000
Arrays_Sort·p0.50 sample 1 1 7.634944 ms/op 100000
Arrays_Sort·p0.90 sample 1 1 8.454144 ms/op 100000
Arrays_Sort·p0.95 sample 1 1 8.742502 ms/op 100000
Arrays_Sort·p0.99 sample 1 1 9.666560 ms/op 100000
Arrays_Sort·p0.999 sample 1 1 12.916883 ms/op 100000
Arrays_Sort·p0.9999 sample 1 1 28.037900 ms/op 100000
Arrays_Sort·p1.00 sample 1 1 28.573696 ms/op 100000
Arrays_Sort sample 1 1042 96.278673 0.603645 ms/op 1000000
Arrays_Sort·p0.00 sample 1 1 86.114304 ms/op 1000000
Arrays_Sort·p0.50 sample 1 1 94.896128 ms/op 1000000
Arrays_Sort·p0.90 sample 1 1 104.293990 ms/op 1000000
Arrays_Sort·p0.95 sample 1 1 106.430464 ms/op 1000000
Arrays_Sort·p0.99 sample 1 1 111.223767 ms/op 1000000
Arrays_Sort·p0.999 sample 1 1 134.172770 ms/op 1000000
Arrays_Sort·p0.9999 sample 1 1 134.742016 ms/op 1000000
Arrays_Sort·p1.00 sample 1 1 134.742016 ms/op 1000000
Radix_Sort sample 1 2240042 0.002941 0.000033 ms/op 100
Radix_Sort·p0.00 sample 1 1 0.001578 ms/op 100
Radix_Sort·p0.50 sample 1 1 0.002368 ms/op 100
Radix_Sort·p0.90 sample 1 1 0.003556 ms/op 100
Radix_Sort·p0.95 sample 1 1 0.004344 ms/op 100
Radix_Sort·p0.99 sample 1 1 0.011056 ms/op 100
Radix_Sort·p0.999 sample 1 1 0.027232 ms/op 100
Radix_Sort·p0.9999 sample 1 1 0.731127 ms/op 100
Radix_Sort·p1.00 sample 1 1 5.660672 ms/op 100
Radix_Sort sample 1 2695825 0.018553 0.000038 ms/op 1000
Radix_Sort·p0.00 sample 1 1 0.013424 ms/op 1000
Radix_Sort·p0.50 sample 1 1 0.016576 ms/op 1000
Radix_Sort·p0.90 sample 1 1 0.025280 ms/op 1000
Radix_Sort·p0.95 sample 1 1 0.031200 ms/op 1000
Radix_Sort·p0.99 sample 1 1 0.050944 ms/op 1000
Radix_Sort·p0.999 sample 1 1 0.082944 ms/op 1000
Radix_Sort·p0.9999 sample 1 1 0.830295 ms/op 1000
Radix_Sort·p1.00 sample 1 1 6.660096 ms/op 1000
Radix_Sort sample 1 685589 0.145695 0.000234 ms/op 10000
Radix_Sort·p0.00 sample 1 1 0.112512 ms/op 10000
Radix_Sort·p0.50 sample 1 1 0.128000 ms/op 10000
Radix_Sort·p0.90 sample 1 1 0.196608 ms/op 10000
Radix_Sort·p0.95 sample 1 1 0.225792 ms/op 10000
Radix_Sort·p0.99 sample 1 1 0.309248 ms/op 10000
Radix_Sort·p0.999 sample 1 1 0.805888 ms/op 10000
Radix_Sort·p0.9999 sample 1 1 1.818141 ms/op 10000
Radix_Sort·p1.00 sample 1 1 14.401536 ms/op 10000
Radix_Sort sample 1 60843 1.641961 0.005783 ms/op 100000
Radix_Sort·p0.00 sample 1 1 1.251328 ms/op 100000
Radix_Sort·p0.50 sample 1 1 1.542144 ms/op 100000
Radix_Sort·p0.90 sample 1 1 2.002944 ms/op 100000
Radix_Sort·p0.95 sample 1 1 2.375680 ms/op 100000
Radix_Sort·p0.99 sample 1 1 3.447030 ms/op 100000
Radix_Sort·p0.999 sample 1 1 5.719294 ms/op 100000
Radix_Sort·p0.9999 sample 1 1 8.724165 ms/op 100000
Radix_Sort·p1.00 sample 1 1 13.074432 ms/op 100000
Radix_Sort sample 1 4846 20.640787 0.260926 ms/op 1000000
Radix_Sort·p0.00 sample 1 1 14.893056 ms/op 1000000
Radix_Sort·p0.50 sample 1 1 18.743296 ms/op 1000000
Radix_Sort·p0.90 sample 1 1 26.673152 ms/op 1000000
Radix_Sort·p0.95 sample 1 1 30.724915 ms/op 1000000
Radix_Sort·p0.99 sample 1 1 40.470446 ms/op 1000000
Radix_Sort·p0.999 sample 1 1 63.016600 ms/op 1000000
Radix_Sort·p0.9999 sample 1 1 136.052736 ms/op 1000000
Radix_Sort·p1.00 sample 1 1 136.052736 ms/op 1000000

The table tells an interesting story. Arrays.sort is vastly superior for small arrays (the arrays most people have), but for large arrays the custom implementation comes into its own. Interestingly, this is consistent with the computer science. If you need to sort large arrays of (unsigned) integers and care about performance, think about implementing radix sort.

# Targeting SIMD in Java

Vectorised instruction execution can be targeted directly in C++ but with Java there are extra layers of abstraction to go through. Folklore aside, when does vectorisation or SIMD execution actually happen in Java? Skeptical of old wives’ tales, I investigate when SIMD instructions are actually used in Java 9, and how to disable it by programming badly.

### Building a Benchmark Harness

I use JMH to write benchmarks. For the uninitiated, it is the standard Java micro-benchmarking framework and handles various pitfalls, the most salient of which being that it ensures that your code actually executes, and ensures measurement is performed against a monotonic measure of time. Benchmarks produced without JMH are unlikely to be correct and should arouse suspicion, especially if used during a sales process.

Averages always lie, so minimisation of 99.9th percentile execution time is a better objective to have in mind. As a general performance indicator I measure throughput in operations per time unit, which is useful to correlate with JVM compilation events.

To tune performance, before even worrying about achieving SIMD execution, we need to be aware of recompilation and failures to inline. These features are enabled by the arguments below and my simple harness has a specific mode to support these diagnostics:

-XX:+PrintCompilation
-XX:+UnlockDiagnosticVMOptions
-XX:+PrintInlining

The proof that code is actually being vectorised is to observe the emission of AVX instructions. To prove this has happened (and if it does, it will be correlated with astonishing performance statistics), we need to see the assembly code so I run the benchmark in a mode that will print out the generated assembly via the arguments:

-XX:+UnlockDiagnosticVMOptions
-XX:+PrintAssembly
-XX:PrintAssemblyOptions=hsdis-print-bytes
-XX:CompileCommand=print

However, SIMD execution only happens when SuperWord parallelism is enabled (and by default, it is) so we won’t even need to look at the assembly unless we see a clear difference when running the benchmark without the UseSuperWord option:

-XX:-UseSuperWord

### What Gains Can Be Expected?

Is vectorised code execution a panacea? Assuming we can force the JVM to use SIMD, how much performance can be expected? It turns out that java.util.Arrays.fill can be vectorised, so we can get a taste of the difference it makes. We can observe its impact by benchmarking throughput with and without SuperWord instruction level parallelism.

private void benchmark(String... jvmArgs) throws RunnerException {
Options opt = new OptionsBuilder()
.include(this.getClass().getName() + ",*")
.mode(Mode.Throughput)
.timeUnit(TimeUnit.MILLISECONDS)
.warmupIterations(5)
.measurementIterations(5)
.forks(1)
.shouldFailOnError(true)
.shouldDoGC(true)
.operationsPerInvocation(1_000_000)
.jvmArgs(jvmArgs)
.build();
new Runner(opt).run();
}

@Benchmark
public void fillArray(Blackhole bh)  {
double[] array = new double[1 << 10];
for(int i = 0; i << 1_000_000; ++i) {
Arrays.fill(array, i);
bh.consume(array);
}
}

# VM version: JDK 9-ea, VM 9-ea+166
...
# VM options: -XX:-UseSuperWord
...

Benchmark                 Mode  Cnt    Score     Error   Units
TestBenchmark.fillArray  thrpt    5  966.947 ± 596.705  ops/ms

# VM version: JDK 9-ea, VM 9-ea+166
...
# VM options: -XX:+UseSuperWord
...

Benchmark                 Mode  Cnt     Score      Error   Units
TestBenchmark.fillArray  thrpt    5  4230.802 ± 5311.001  ops/ms

The difference in throughput is palpable and astonishing.

### Intrinsics

Various intrinsics, such as Arrays.fill above, compile down to vectorised instructions. When SuperWord parallelism is enabled, they will always run faster. The JIT compiler will also target simple hand-written code, but intrinsics are a safer bet.

Addition of arrays will either use SIMD or not; it depends how you go about writing your code. If your code is too complicated then you will not achieve vectorised execution. I will start from a method which does not vectorise, transform it to one that does by a process of simplification, and then break it again by trying to be too clever. The code which does vectorise is the same naive code I would have written in C++ as a student, ignorant of JVM internals. All of the code is available at github.

To start off with I created a highly contrived class called BadCode which is actually inspired, albeit seriously exacerbated, by a generic function in an API I have seen in a professional setting. The so called object oriented (sic) API seeks to be able to operate on any type of primitive array, so takes the lowest common denominator (java.lang.Object) as parameters and performs instanceof checks to get the correctly typed array instance. While the code is bloated, this provides as much flexibility as possible, which suits the supplier of the API – which has many clients with disparate use cases – but not necessarily the performance constrained caller.

The code is too bloated to include here but can be seen on github. It has two major performance bugs which will be addressed in turn:

1. It’s verbose enough not to inline
2. It has more than one exit point

Because the method supports so many use cases, the code size is very large (2765 bytes). By default, any method with a code size of greater than 2000 bytes will fail to inline. Inlining is at the very base of our hierarchy of performance needs. We can see that the JIT compiler has failed to inline the method by printing inlining and compilation:

   2193  715 %     4       com.openkappa.simd.generated.TestBenchmark_badClass_jmhTest::badClass_thrpt_jmhStub @ 13 (55 bytes)
@ 19   com.openkappa.simd.TestBenchmark::badClass (9 bytes)   force inline by CompileCommand
@ 2   com.openkappa.simd.TestBenchmark$BadClassState::compute (16 bytes) inline (hot) @ 12 com.openkappa.simd.BadCode::bigMethod (2765 bytes) hot method too big  Taking a look at our throughput, we can see there is a problem. The code isn’t getting any faster, so clearly no optimisations are being applied. # Run progress: 0.00% complete, ETA 00:00:40 # Fork: 1 of 1 # Warmup Iteration 1: 0.193 ops/us # Warmup Iteration 2: 0.176 ops/us # Warmup Iteration 3: 0.216 ops/us # Warmup Iteration 4: 0.183 ops/us # Warmup Iteration 5: 0.294 ops/us Iteration 1: 0.260 ops/us Iteration 2: 0.224 ops/us Iteration 3: 0.170 ops/us Iteration 4: 0.169 ops/us Iteration 5: 0.169 ops/us  Our three nines is terrible, taking up to six microseconds to add two arrays: TestBenchmark.badClass:badClass·p0.999 sample 6.296 us/op Regardless of the large code size, the approach taken in the API has enforced multiple exit points in the method, which will always disable SIMD execution. Running with SuperWord disabled does not worsen performance, implying our code is not getting vectorised. #### Smaller Code Having noticed that the method is not getting inlined, let alone compiling to AVX instructions, we need to make the code smaller first. In this scenario our values are always double[] so the API provider effectively forces us to pay for the disparate use cases they must support, and this taxation without representation harms performance. We can rewrite it to be smaller, targeting our own specific use case. The code is concise enough to include here, and is the code any student would write to perform element-wise addition of two arrays. Notice the loop condition.  public class SmallerCode { public double[] smallMethod(double[] left, double[] right) { double[] result = new double[left.length]; for(int i = 0; i < left.length && i < right.length; ++i) { result[i] = left[i] + right[i]; } return result; } }  Let’s benchmark SmallerCode, where the same code has a size of 43B. The method is indeed inlined.  1374 647 3 com.openkappa.simd.TestBenchmark$SmallerCodeState::compute (16 bytes)   made not entrant
@ 12   com.openkappa.simd.SmallerCode::smallMethod (43 bytes)   inline (hot)

Throughput is doubled and we see evidence of dynamic optimisation.
# Run progress: 25.00% complete, ETA 00:02:42
# Fork: 1 of 1
# Warmup Iteration   1: 0.372 ops/us
# Warmup Iteration   2: 0.340 ops/us
# Warmup Iteration   3: 0.432 ops/us
# Warmup Iteration   4: 0.497 ops/us
# Warmup Iteration   5: 0.499 ops/us
Iteration   1: 0.398 ops/us
Iteration   2: 0.364 ops/us
Iteration   3: 0.408 ops/us
Iteration   4: 0.544 ops/us
Iteration   5: 0.401 ops/us

This code is twice as fast, and our three nines is better, just by virtue of keeping the code simple.
TestBenchmark.smallerCode:smallerCode·p0.999             sample       2.164          us/op

But are we getting SIMD execution? Possibly – disabling SuperWord yields noticeably worse results.
# Run progress: 25.00% complete, ETA 00:02:22
# Fork: 1 of 1
# Warmup Iteration   1: 0.261 ops/us
# Warmup Iteration   2: 0.343 ops/us
# Warmup Iteration   3: 0.294 ops/us
# Warmup Iteration   4: 0.320 ops/us
# Warmup Iteration   5: 0.316 ops/us
Iteration   1: 0.293 ops/us
Iteration   2: 0.276 ops/us
Iteration   3: 0.304 ops/us
Iteration   4: 0.291 ops/us
Iteration   5: 0.279 ops/us

It’s worth inspecting the assembly to see if we can observe the emission of AVX instructions once we reenable UseSuperWord. Assembly is easier to read if inlining is disabled, this can be controlled in JMH with this annotation: @CompilerControl(CompilerControl.Mode.DONT_INLINE). Applying the annotation, the assembly is printed using the appropriate JVM args:
-XX:+UnlockDiagnosticVMOptions
-XX:+PrintAssembly
-XX:PrintAssemblyOptions=hsdis-print-bytes
-XX:CompileCommand=print

0x00000154edb691e0: vmovdqu ymm0,ymmword ptr [rbp+r10*8+10h]

0x00000154edb691ee: vmovdqu ymmword ptr [r8+r10*8+10h],ymm0

0x00000154edb691f9: cmp     r10d,ebx

0x00000154edb691fc: jl      154edb691e0h

It’s true – this code is indeed vectorised – see the AVX instructions in bold!

#### Ruining It

Having witnessed vectorisation when adding arrays together, let’s try and break it. There are a few patterns we can apply to break our vectorised code:

• Putting an OR condition as the loop condition
• Putting a non-inlined method inside the loop
• Putting an arbitrary method as the loop condition
• Manually unrolling the loop
• Using a long as the loop variable
• Multiple exit points

The list goes on but now let’s really fuck it up. We were using double[] so let’s see what happens if we use a DirectByteBuffer as the backing for a homegrown vector construct instead. Instead of returning a new heap allocated array, we will write our doubles into a byte buffer, and use an offset and length to delineate the arrays. For instance, the code below will write the sum of two arrays stored in a byte buffer back into the same byte buffer. We can abstract vectors by creating small on-heap objects for each array which know the offset and length of each array in the buffer.

int leftOffset, int leftLength,
int rightOffset, int rightLength,
int resultOffset) {
int resultIndex = resultOffset;
for(int l = leftOffset, r = rightOffset;
l < leftOffset + leftLength && r < rightOffset + rightLength;
l += 8, r += 8, resultIndex += 8) {
byteBuffer.putDouble(resultIndex, byteBuffer.getDouble(l) + byteBuffer.getDouble(r));
}
return resultIndex;
}

Is this clever? We’ve beaten the garbage collector. It certainly feels like a clever engineering story. No, performance wise, we are back to where we were with the remarkably convoluted and conflated catch all function. Entertainingly, had we only ever benchmarked against BadCode::bigMethod we may not have noticed this performance regression.

# Run progress: 0.00% complete, ETA 00:00:40
# Fork: 1 of 1
# Warmup Iteration   1: 0.156 ops/us
# Warmup Iteration   2: 0.160 ops/us
# Warmup Iteration   3: 0.198 ops/us
# Warmup Iteration   4: 0.190 ops/us
# Warmup Iteration   5: 0.272 ops/us
Iteration   1: 0.220 ops/us
Iteration   2: 0.242 ops/us
Iteration   3: 0.216 ops/us
Iteration   4: 0.248 ops/us
Iteration   5: 0.351 ops/us

TestBenchmark.byteBuffer:byteBuffer·p0.999     sample       6.552           us/op

The obvious indicator that this is not being vectorised is that performance does not degrade when setting
-XX:-UseSuperWord

And to be sure we can inspect the assembly code emitted (without disabling UseSuperWord!).
  0x000001869216cb67: mov     edx,ecx

0x000001869216cb6c: cmp     ecx,edx

0x000001869216cb6e: jnl     1869216cb1dh

0x000001869216cb70: mov     r13d,dword ptr [r12+r11*8+8h]

0x000001869216cb75: cmp     r13d,0f8007ed8h

0x000001869216cb7c: jne     1869216d015h

0x000001869216cb82: lea     r13,[r12+r11*8]

0x000001869216cb86: movzx   eax,byte ptr [r13+29h]

0x000001869216cb8b: test    eax,eax

0x000001869216cb8d: je      1869216d015h

The reality is that whenever sun.misc.Unsafe is used, directly or indirectly, we lose access to SIMD. The bottom line is if you want to exploit instruction level parallelism, then be prepared to write code even a beginner could understand instantly. Bizarre off-heap data structures and vectorised execution? Unlikely.