| Account Name | Account Number | Type | Login ID | Default Cloud | Default? |
|---|
$def with () $var jsfiles: managePageCommon.js cloudAccountEdit.js $var cssfiles:
The Manage Cloud Accounts screen allows administrators to modify, add and delete Cloud Accounts.
Select an Account from the list or select an action to edit or delete the Accounts you've selected.
Cloud Accounts are required to have a 'default' Cloud.
Cloud Accounts can not be deleted if they are associated with any other records.
Click here for a more detailed introduction to Cloud Accounts.
| Account Name | Account Number | Type | Login ID | Default Cloud | Default? |
|---|
| Account Name: | |
| Account Number: | |
| Provider: | |
| Access Key: | |
| Secret Key: | |
| Secret Key Confirm: | |
| Make Default: | |
| The "default" Account is automatically selected on intial login. | |
| Default Cloud: | |
| The "default" Cloud when using this Account. | |
Some of the selected Accounts may be referenced by automation.
Deleting an Account could cause automation to fail.
Would you like to delete these Accounts anyway?


Muhammad Ali entered the ring 61 times after turning professional in 1960.
|
||
|---|---|---|
| Total fights | Wins | loses |
| 61 | 56 | 5 |
“Don't count the days, make the days count.”


Search
search
Select Filter
Author:
None
From ...
To ...
Scored Articles
Sunburst
Title
Date
Author
Article
Hidden


"BETH-ARAM "house of the height; i.e., “mountain-house”, one of the towns of Gad, 3 miles east of Jordan, opposite Jericho (Joshua 13:27). Probably the same as Beth-haran in Numbers 32:36. It was called by king Herod, Julias, or Livias, after Livia, the wife of Augustus. It is now called Beit-haran.
"BETH-ARAM "house of the height; i.e., “mountain-house”, one of the towns of Gad, 3 miles east of Jordan, opposite Jericho (Joshua 13:27).
Probably the same as Beth-haran in Numbers 32:36. It was called by king Herod, Julias, or Livias, after Livia, the wife of Augustus. It is now called Beit-haran.


What is it about?
The regimented food
The myriad weights
The sleepless nights
The countless runs
The plastic meetings
The crushing of skulls
The redefinition of colors
The swallowing of dross
The battle against filth,
It is about what I want to be
It is about where I want to be
It is about who I want to see
Is it about what I want to have
It is about what makes me better
It is about my dreams of future
It is about my godliest gift
It is about the truest of freedoms
It is about the brightest of stars.
In everything,
It is about you.


This system is a web based
application that predicts the disease of the user with respect to the symptoms
given by the user.
With the availability of doctor consultation at home,
you no longer need to stress yourself about visiting a clinic or hospitals and
aggravate the injury.
Why wait to see a doctor , when
there is a doctor to see you? At home , at your convenience.


class: center, middle ### W4995 Applied Machine Learning # Dimensionality Reduction ## PCA, Discriminants, Manifold Learning 04/01/20 Andreas C. Müller ??? Today we're going to talk about dimensionality reduction, mostly about principal component analysis. We're also going to talk about discriminant analysis and manifold learning. These all slightly different sets of goals. But the main idea here is to take a high dimensional input dataset and produce the dimensionality for processing. It can be either before the machine learning pipeline or often for visualization. FIXME PCA components and scaling: xlabel for components 0 and 1 FIXME LDA projection slide with explanation and diagram! FIXME compare Largevis, t-SNE, UMAP FIXME print output in PCA slides: I need to know the dimenionality (29?) FIXME trim tsne animation (why?) FIXME write down math for inverse transform? (and for pca transform?) FIXME show unwhitened vs whitened plot --- class: centre,middle # Principal Component Analysis ??? --- .center[ ![:scale 70%](images/pca-intuition.png) ] ??? Here, we have a 2D input space, there's some point scattered here. The color is supposed to show you where the data goes in the transformations. PCA finds the directions of the maximum variant in the data. So starting with this blob of data, you look at the direction that is the most elongated. And then you look for the next opponent that captures the second most various, that's orthogonal to the first component. Here in 2-dimensions, there's only one possibility to be orthogonal to the first component and so that's our second component. If you're in higher dimensions, there are obviously infinitely many different directions that could be orthogonal, and so then you would iterate. What PCA returns is basically an orthogonal basis of the space where the components are ordered by how much variance of the data they cover and so we get a new basis of the original space. So we can do this until like N dimensions many times. In this example, I could do two times, after that there are no orthogonal vectors left. And so this new basis corresponds to rotating the input space, I can rotate the input space so that the first component is my X-axis and the second component is my Y-axis and this is the transformation that PCA learns. This doesn't do any dimensionality reduction as of yet, this is just a rotation of the input space. If I want to use it for dimensionality reduction, I can now start dropping some of these dimensions. So they are ordered by decreasing variance, I could in this example drop, for example, the second component only to regain the first component. So basically, I dropped the Y-axis and projected everything to the X line. And this would be dimensionality reduction with the PCA going from two dimensions to one dimension. And the idea is that if your data lives on a lower dimensional space, or essentially lives on lower dimensional space, embedded in high dimensional space, you could think of this is mostly aligned or Gaussian blob along this direction and there's a little bit of noise in this direction. The most information about the data is sort of along this line. The idea is that does one-dimensional projection now covers as much as possible of this data set. You can also look at PCA as being sort of a de-noising algorithm, by taking this reduced representation in the rotated space and rotating it back to the original space. So this is basically transforming the data using PCA, the rotation dropping one dimension rotating back, you end up with this. And so this is through information that is retained in this projection, basically. And so, arguably, you still have a lot of information from this dataset. --- # PCA objective(s) `$$\large\min_{X', \text{rank}(X') = r}\|X-X'\|$$` .center[ ![:scale 45%](images/pca-intuition.png) ] ??? The maximum variance view can be formalized like this. So basically, you look at the variance of a projection. So you look over all possible vectors, U1 that have norm 1 and you look at what's the variance of projecting the data X along this axis and then the maximum of this will be the maximum variance of the data. You can also rewrite this in this way. Once you compute U1, you subtract the projection onto U1 from the data. Then you get everything orthogonal to U1. And then with this dataset where you subtracted the component along U1, you can again find the direction of maximum variance, and then you get U2 and so on iterate this…. One thing that you should keep in mind here is that the direction of U1 or the PCA component doesn't matter. These two definitions of the first principle component, if you set U1 to –U1 it would be the same maximum. It only depends on the direction of U1, not the sign. So whenever you look at principal components, the sign is completely meaningless. Restricted rank reconstruction --- class:split-40 # PCA objective(s) .left-column[ `$$\large\max\limits_{u_1 \in R^p, \| u_1 \| = 1} \text{var}(Xu_1)$$` `$$\large\max\limits_{u_1 \in R^p, \| u_1 \| = 1} u_1^T \text{cov} (X) u_1$$` ] .smaller.right-column[ .center[ ![:scale 90%](images/pca-intuition.png) ] ] ??? So second way to describe PCA is using Reconstruction Error. I can look at how well this reconstruction here matches the input space. And if I want a reconstruction X’, that is the best possible in the least squares sense, so that is the square norm. If I look at the square norm of X – X’, then this is minimized exactly when I'm using X’, X’ is the PCA reduction. This is like written in a slightly different way.  But this problem is exactly solved by basically rotating using PCA direction, dropping the data and then rotating back. Maximizing the variance is the same thing as minimizing the Reconstruction Error, given a fixed number of dimensions. Find directions of maximum variance. (Find projection (onto one vector) that maximizes the variance observed in the data.) Subtract projection onto u1, iterate to find more components. Only well-defined up to sign / direction of arrow! --- # PCA Computation - Center X (subtract mean). - In practice: Also scale to unit variance. - Compute singular value decomposition: ![:scale 100%](images/pca-computation.png) ??? If I want to apply PCA to my dataset, the first thing I have to do, which is sort of part of the algorithm subtracts the mean. Any package will subtract the mean for you before it does the SVD. What you should probably also do in practice is to scale the data to unit variance. And then the PCA algorithm just computes the singular level decomposition. We decompose the data X into an orthogonal, a diagonal, and an orthogonal. V^T is number of features, U is number of samples times number of samples, D is diagonal containing singular values. Singular values correspond to the variance of each of these directions. Usually, in SVD you sort them by singular values. So the largest singular value corresponds to the first principle components. There's an additional processing step that you can do which is the most basic form of PCA. You can also use these entries of the diagonal to really scale the data in the rotated space so that the variance is the same across each of the new dimensions. --- class: center # Whitening ![:scale 100%](images/whitening.png) ??? So I take my original data, I rotate it, and then I scale each of the dimension so that they have standard deviation one. It’s basically the same as doing PCA and then doing standard scaler. You can see now the variance, visually looks like a ball, it was a Gaussian before. In the context of signal processing, in general, this is called whitening. And if you want to use PCA as a feature transformation, to extract features you might want to do that, because otherwise, the magnitude of the first principle component will be much bigger than the magnitude of the other components since you just rotated it. So the small variance directions will have only very small variance because that's how you define them. The question here is do you think the principal components are of similar importance? Or do you think the original feature is of similar importance? And if you think the principal components are of similar important then you should do this. So if you want to go on and put this in a classifier, this might be helpful. But I don't think I can actually give you a clear rule when you would want to do this or when not to. But it kind of makes senses if you think of it as being centered scaler in a transformed space that seems like something that might be helpful for a classifier. Same as using PCA without whitening, then doing StandardScaler. --- class: split-40 # PCA for Visualization .tiny-code.left-column[```python from sklearn.decomposition import PCA print(cancer.data.shape) pca = PCA(n_components=2) X_pca = pca.fit_transform(cancer.data) print(X_pca.shape) plt.scatter(X_pca[:, 0], X_pca[:, 1], c=cancer.target) plt.xlabel("first principal component") plt.ylabel("second principal component") components = pca.components_ plt.imshow(components.T) plt.yticks(range(len(cancer.feature_names)), cancer.feature_names) plt.colorbar() ``` ![:scale 80%](images/pca-for-visualization-cancer-data.png) ] .right-column[ ![:scale 90%](images/pca-for-visualization-components-color-bar.png)] ??? I want to show you an example on real data set. So the first data set I'm going to use it on is the breast cancer data set. The way I use PCA most often is probably for visualization. I often do PCA with two components, because my monitor has two dimensions. I fit, transform the data and I scatter it and then I get the scatter plot of the first principle component versus second principal component. So this is the binary classification problem, PCA obviously is a completely unsupervised method, so it doesn't know what the class labels but I could look whether this is a hard problem to solve or is it an easy problem to solve. If I look at this plot, maybe it looks like it's a relatively easy problem to solve with the points being relatively well separated. Now I look at the principal component vectors. So there are two principal components, each of them has number of features many dimensions. So this is shown here as a heat map. And you can see that there are basically two features that dominate the principal components, which is mean area and worst area. And all the rest of the entries are approximately zero. So actually, I didn't rotate my data at all, I just looked at two features. So I didn't scale my data, if I don't scale my data and a particular feature has a much larger magnitude, this feature will basically be the first principle component because if I multiply a feature by 10,000, this feature will have the largest variance of everything. There will be no direction that has a larger variance than that. --- class:spacious # Scaling! .tiny-code[```python pca_scaled = make_pipeline(StandardScaler(), PCA(n_components=2)) X_pca_scaled = pca_scaled.fit_transform(cancer.data) plt.scatter(X_pca_scaled[:, 0], X_pca_scaled[:, 1], c=cancer.target, alpha=.9) plt.xlabel("first principal component") plt.ylabel("second principal component") ```] .center[![:scale 45%](images/scaled-pca-for-visualization-cancer-data.png)] ??? So now I scale the data. And then I get two components on the cancer data set. And now actually the data looks even better separated. Even with this unsupervised methods it very clearly shows me what separation of the classes is, I can also see things like the yellow class looks much denser than the purple class, maybe there are some outliers here, but this definitely gives me a good idea of this dataset. So this is much more compact than looking at a 30x30 scatter matrix, which I couldn't comprehend. So we can look at the components again. Imagine one feature with very large scale. Without scaling, it’s guaranteed to be the first principal component! --- class:split-40 # Inspecting components .tiny-code[```python components = pca_scaled.named_steps['pca'].components_ plt.imshow(components.T) plt.yticks(range(len(cancer.feature_names)), cancer.feature_names) plt.colorbar() ```] .smaller.left-column[ ![:scale 70%](images/inspecting-pca-scaled-components.png) ] .right-column[ ![:scale 100%](images/inspecting-pca-scaled-components-2.png)] ??? So components are stored in the components attribute of the PCA class. And you can see now all of the features contribute to the principal components. And if you're an expert in the area, and you know what these features mean, sometimes it's possible to read something in this. It's definitely helpful often to look at these component vectors. Another way to visualize the component vectors is to do a scatter plot. But that only works basically for the first two principal components. So you can basically look at the positions of the original features, each dot here is one of the original features, and you can look at how much does this feature contribute to principal component one versus principal component two. And so I can see that the second principal component is dominated by mean fractal dimension and the first personal component is dominated by the worst perimeter. And worse perimeter negatively contributes to the second principal component. And worst case point is also very strong in the first principle component but has zero in the second principal component. This was sort of the first approach trying to use PCA for 2-dimensional visualization and trying to understand what the components mean. sign of component is meaningless! --- # PCA for regularization .tiny-code[ ```python from sklearn.linear_model import LogisticRegression X_train, X_test, y_train, y_test = train_test_split(cancer.data, cancer.target, stratify=cancer.target, random_state=0) lr = LogisticRegression(C=10000).fit(X_train, y_train) print(lr.score(X_train, y_train)) print(lr.score(X_test, y_test)) ``` ``` 0.993 0.944 ``` ```python pca_lr = make_pipeline(StandardScaler(), PCA(n_components=2), LogisticRegression(C=10000)) pca_lr.fit(X_train, y_train) print(pca_lr.score(X_train, y_train)) print(pca_lr.score(X_test, y_test)) ``` ``` 0.961 0.923 ``` ] ??? One thing that PCA is often used for, in particular for statistics oriented people, is using it for regularizing a model. You can use PCA to reduce the dimensionality of your data set and then you can do a model on the on the reduced dimensional data set. Since it has fewer features, this will have less complexity, less power so you can avoid overfitting by reducing the dimensionality. I’ve given an example here on the same data set. I'm using logistic regression, and I basically turn off regularization. Instead of using L2 regularization in linear regression, I'm trying to do reduce the input space. So you can see that, if I do that, I basically overfit the data perfectly. So on the training dataset, I have 99.3% accuracy, and on test dataset I have 44.4% accuracy. Now if I use PCA with two dimensions, I reduce this down to just two features. I basically reduce overfitting a lot so I get a lower training score but I also get a lower test score. Generally, if you find that you only need 2-dimension to solve a problem, then that’s a very simple problem. But if you're shooting for accuracy, clearly you’ve regularized too much, you're restricted to the model too much by just using two components. One way to figure out a good number of components, obviously, doing grid search with cross-validation. Another way is to look at the variance that it is covered by each of the components, so this is basically the singular values. --- # Variance covered .center[ ![:scale 55%](images/variance-covered.png) ] .tiny-code[```python pca_lr = make_pipeline(StandardScaler(), PCA(n_components=6), LogisticRegression(C=10000)) pca_lr.fit(X_train, y_train) print(pca_lr.score(X_train, y_train)) print(pca_lr.score(X_test, y_test)) ``` ``` 0.981 0.958 ```] ??? So here are for the singular values. Here is the explained variance ratio, basically how much of the variance in the data is explained by each of the components. The components are sorted by decreasing variance so obviously, this always goes down. But now I can sort of look for kinks in this variance that's covered and I can see how many components it makes sense to keep for this dataset maybe if you don't want to do a grid search. Looking at the top plot, it looks like the six components are enough. And if I actually use six components, I overfit slightly less in the training dataset, I get a better result than I did without using PCA. People from statistics like this better than regularization since this doesn't bias to coefficients. I like it slightly less because the PCA is completely unsupervised and it might discard important information. But it's definitely a valid approach to regularize linear model. If you're using a linear model, what's nice is that you can still interpret the coefficients afterward. The linear model is just the dot product with the weights and PCA is just a rotation. And so it can take the coefficients and rotate them back into the original space. Could obviously also do cross-validation + grid-search --- class:split-40 # Interpreting coefficients .tiny-code[```python pca = pca_lr.named_steps['pca'] lr = pca_lr.named_steps['logisticregression'] coef_pca = pca.inverse_transform(lr.coef_)```] .center[Comparing PCA + Logreg vs plain Logreg:]
.left-column[ ![:scale 100%](images/PCA+logreg.png) ] .right-column[ ![:scale 100%](images/logreg+noPCA.png) ] ??? So that's what I'm doing here. I use the logistic regression coefficients in the PCA space, I think this was six components. And so then I can scatter them and look at them, what do these components mean, in terms of the original features. Here, I’m looking at with no PCA, which is just the logistic regression on the original data set, versus doing PCA, doing logistic regression on the six-dimensional data set, and then rotating the six coefficients back into the input space. Even though I did this transformation of the data, I can still see how this model in the reduced feature space uses these features. The left plot shows plain logistic regression coefficients and the back-rotated coefficients with PCA. The plot on the right shows for each feature the coefficient in the standard model and in the model including PCA. And you can see that they're sort of related. They're not going to be perfectly related because I reduced the dimensionality of this space and also the model with PCA did better in this case. So clearly they’re different. Rotating coefficients back into input space. Makes sense because model is linear! Otherwise more tricky. --- class:split-40 # PCA is Unsupervised! .left-column[ ![:scale 100%](images/pca-is-unsupervised-1.png) ] -- .right-column[ ![:scale 100%](images/pca-is-unsupervised-2.png) ] ??? Look at this dataset. It's a very fabricated data set. This is a 3d classification problem in two dimensions. This looks very unstructured. So if I do a PCA, I get this. And so if I now look at the first two principal components, the problem is actually completely random, because that's how I synthetically constructed it. And if I look at the third principal component, the third component perfectly classifies the dataset. Even though I constructed to be like that, there's nothing that prevents the data set in reality not to look like that. Just because the data is very small, or has small variance in a particular direction doesn't mean this direction is not important for classification. So basically, if you’re dropping components with small variance, basically what you're doing is you're doing feature selection in the PCA space based on the variance of the principal components. And so that's not necessarily a good thing. Because small variance in principal component doesn't necessarily mean uninformative. Dropping the first two principal components will result in random model! All information is in the smallest principal component! --- # PCA for feature extraction .center[ ![:scale 85%](images/pca-for-feature-extraction.png) ] ??? Next, I want to give an example of where PCA has been used, at least historically, for faces. This is a data set collected in the 90s. The idea is you have a face detector, given the face, you want to identify who this person is. Working on the original pixel space kind of seems like a pretty bad idea. The images here have about 6000 pixels, they're relatively low resolution but still has like 5000 features, just looking at the pixel values, which means very high dimensional. You can do a PCA and this is sort of the components that you get from this. You can see here, for example, here, from which direction does light come from, how much eyebrows do you have and do you have a mustache. These are the PCA components constructed on this data set. The idea is that these PCA components can be better features for doing classification than the original pixels. And this is an application where whitening helps. Rescaling the feature components so that they all have the same variance actually helps classification. One different way to think about these components instead of thinking about the mass rotations is you can think about equivalently that each point is a linear combination of all the components because the components form a basis of the input space. You can think that each picture, for example, Winona Ryder here, is a linear combination of all the components and these coefficients of linear combinations are the projection in the PCA space. I mean, these are the coefficients in the PCA bases after rotation. To me, this makes it more interpretable what these components might mean. So if I have, light from the person's right, then I would expect X1 want to be high, because then this component becomes active. If the light comes from a different direction, I would expect X1 to be negative. If there's no left or right gradient, I would expect the component to be about zero. --- # 1-NN and Eigenfaces .tiny-code[ ```python from sklearn.neighbors import KNeighborsClassifier # split the data into training and test sets X_train, X_test, y_train, y_test = train_test_split( X_people, y_people, stratify=y_people, random_state=0) print(X_train.shape) # build a KNeighborsClassifier using one neighbor knn = KNeighborsClassifier(n_neighbors=1) knn.fit(X_train, y_train) knn.score(X_test, y_test) ``` ``` (1547, 5655) 0.23 ``` ] -- .tiny-code[ ```python pca = PCA(n_components=100, whiten=True, random_state=0).fit(X_train) X_train_pca = pca.transform(X_train) X_test_pca = pca.transform(X_test) X_train_pca.shape ``` ``` (1547, 100) ``` ```python knn = KNeighborsClassifier(n_neighbors=1) knn.fit(X_train_pca, y_train) knn.score(X_test_pca, y_test)) ``` ``` 0.31 ``` ] ??? Alright, so now let's look at what it does. So here, on this dataset, I’m doing one nearest neighbor classifier. The reason I'm using one nearest neighbor classifier is that that's often used if people want to demonstrate what a good representation of the data is. The idea is that one nearest neighbor classifier just looks at your nearest neighbor and so it only relies on your representation of the data. So if 1NN classifier does well, your representation of the data is good. That’s the intuition behind this. If I use a linear model that's penalized, PCA will probably not make a lot of difference actually. Here with the nearest neighbor equal to one, you get about 23% accuracy. And you can see that the data set is very wide. So there are a lot more features than there are samples. If there are more features than in samples. PCA can only do as many components as there is the minimum of features and samples. So in this case, I could project a maximum of up to 1547 directions because this is the rank of the matrix and I can only get so many Eigenvectors. If I do the same thing with PCA, I go down from 5600 dimensions to only 100 dimensions and then the 1NN classifier actually does quite a bit better. Now it's 31% accurate. You could do a grid search to find the number of components or you could look at the explained variance ratio. --- # Reconstruction .center[ ![:scale 70%](images/reconstruction.png) ] ??? Another way to select how many components you want for classification instead of looking at the explained various ratios is looking at the reconstructions. That is most useful if you can look at the data points in some meaningful way. So for example, here, the bottom right image in my illustration is what happens if I rotate to 10 dimensions and then I rotate back to the original space. For example, you can see here if I use only 10 components, these people are not recognizable at all. So I wouldn't expect 10 components to make to make a lot of sense. On the other hand, if I look at 500 components, even though there’s high-frequency noise the person is recognizable. Using 500, I'm probably not going to lose anything here. This is also one way to see how many components you might need for a particular result. And so if I just use two components, you would see probably nothing. And yet, if I used as many components as there are samples in this case, if I used like 1500 components, it would be completely perfect, because I would basically rotate in space, not drop any dimensions and rotate back. Another thing that's interesting when you’re doing reconstructions is there’s a different application for PCA called outlier detection. You can think of PCA as a density model in the sense, you're fitting a big Gaussian and then you dropping directions of small variance. And so you can look at what are the faces that are reconstructed well versus those that are not reconstructed well. And so if they're not reconstructed as well, that means they are quite different from most of the data. --- class:split-40 # PCA for outlier detection .tiny-code[```python pca = PCA(n_components=100).fit(X_train) reconstruction_errors = np.sum((X_test - pca.inverse_transform(pca.transform(X_test))) ** 2, axis=1) ``` ] .left-column[ ![:scale 90%](images/best-reconstructions.png)
Best reconstructions ] .right-column[ ![:scale 90%](images/worst-reconstructions.png)
Worst reconstructions ] ??? So here, I used 100 components. And now I can look at what's the reconstruction error of rotating the data, dropping some components and rotating back, and the ones with good reconstructions are the ones that look like most of the data. And the ones that have bad reconstructions are the ones that are sort of outliers. If something looks a lot like the data, that's probably something the principal component will cover. Whereas if something looks very different than the data, that's something that principal component will not cover. If you look at these images, what is an outlier and what is not an outlier has nothing to do with the person in it but has only to do with the cropping of the image. So these images are all not very well aligned, they have like tilted head, wearing glasses, cropped too wide, cropped not wide enough, wearing caps and so on. Since they look very different from most of the images, and that's why they're outliers. But you can use this in general, as a density model, basically, looking at how well can the data point be reconstructed with PCA. There are more uses of PCA. These are like a couple of different applications of PCA that all have sort of quite different goals and quite different ways of setting dimensionality. --- class: middle # Discriminant Analysis ??? So the next thing I want to talk about is discriminate analysis. In particular, linear discriminate analysis. This is also a classifier, but it also can do dimensionality reduction. --- class: spacious # Linear Discriminant Analysis aka Fisher Discriminant `$$ P(y=k | X) = \frac{P(X | y=k) P(y=k)}{P(X)} = \frac{P(X | y=k) P(y = k)}{ \sum_{l} P(X | y=l) \cdot P(y=l)}$$` ??? Linear Discriminant Analysis is also called LDA, but never call it LDA because LDA also means Latent Dirichlet Allocation and so it might be confusing. Linear Discriminant Analysis is a linear classifier that builds on Bayes rule, in that, it assumes the density model for each of the classes, if you have a density model for each of the classes, you can build a classifier using Bayes rule. This is Bayes rule of having a joint distribution of X and Y. If you then look at the conditional probability of X, you can say that the probability of Y being a particular class given X is the probability of X given Y is class, times probability of being in this class divided by P(X). And so you can expand this now here, the P(x) as a sum over all classes. And so the only thing you really need is a probability distribution of P(X) given a particular class. So if you fix any possibilities distribution for particular class Bayes rule gives you like a classifier. Linear Discriminant Analysis does basically one particular distribution, which is the Gaussian distribution. - Generative model: assumes each class has Gaussian distribution - Covariances are the same for all classes. - Very fast: only compute means and invert covariance matrix (works well if n_features << n_samples) - Leads to linear decision boundary. - Imagine: transform space by covariance matrix, then nearest centroid. - No parameters to tune! - Don’t confuse with Latent Dirichlet Allocation (LDA) --- class: spacious # Linear Discriminant Analysis aka Fisher Discriminant `$$ P(y=k | X) = \frac{P(X | y=k) P(y=k)}{P(X)} = \frac{P(X | y=k) P(y = k)}{ \sum_{l} P(X | y=l) \cdot P(y=l)}$$` `$$ p(X | y=k) = \frac{1}{(2\pi)^n |\Sigma|^{1/2}}\exp\left(-\frac{1}{2} (X-\mu_k)^t \Sigma^{-1} (X-\mu_k)\right) $$` ??? So what we're doing is basically, we're fitting a Gaussian to each of the classes, but we're sharing the covariance matrix. So for each class, we estimate the mean of the class, and then we estimate the joint covariance matrix, so we subtract the mean of the class from all the data points, and then we compute the covariance matrix of that. So now we have fitted Gaussian into each class, they all have the same covariance matrix and then we can apply this rule. And this gives us a classifier. --- class: spacious # Linear Discriminant Analysis aka Fisher Discriminant `$$ P(y=k | X) = \frac{P(X | y=k) P(y=k)}{P(X)} = \frac{P(X | y=k) P(y = k)}{ \sum_{l} P(X | y=l) \cdot P(y=l)}$$` `$$ p(X | y=k) = \frac{1}{(2\pi)^n |\Sigma|^{1/2}}\exp\left(-\frac{1}{2} (X-\mu_k)^t \Sigma^{-1} (X-\mu_k)\right) $$` `$$ \log\left(\frac{P(y=k|X)}{P(y=l | X)}\right) = 0 \Leftrightarrow (\mu_k-\mu_l)\Sigma^{-1} X = \frac{1}{2} (\mu_k^t \Sigma^{-1} \mu_k - \mu_l^t \Sigma^{-1} \mu_l) $$` ??? You can actually write this in a slightly different way. The decision boundary between the two classes is the same as this formula on the right. What this is basically, the single data point lies on the decision boundary, if inverse square matrix times x is some constant. This is actually just a nearest centroid classifier in the space that was rotated by this joint covariance matrix or rotated and stretched by the joint covariance matrix. So basically, I compute the joint covariance matrix and then I look at what's the closest mean and I adjust it based on the prior probabilities of the class. --- class: spacious # Quadratic Discriminant Analysis LDA: `$$ p(X | y=k) = \frac{1}{(2\pi)^n |\Sigma|^{1/2}}\exp\left(-\frac{1}{2} (X-\mu_k)^t \Sigma^{-1} (X-\mu_k)\right) $$` QDA: `$$ p(X | y=k) = \frac{1}{(2\pi)^n |\Sigma_k|^{1/2}}\exp\left(-\frac{1}{2} (X-\mu_k)^t \Sigma_k^{-1} (X-\mu_k)\right) $$` ??? - Each class is Gaussian, but separate covariance matrices! - More flexible (quadratic decision boundary), but less robust: have less points per covariance matrix. - Can’t think of it as transformation of the space. ??? Quadratic Discriminate Analysis is exactly the same thing, only that you have a separate covariance matrix for each of the classes. This makes a more flexible classifier, but also, you have fewer points to estimate each of the various matrices. So you have many more parameters, which makes it a little bit harder to fit. --- class:center ![:scale 55%](images/linear-vs-quadratic-discriminant-analysis.png) ??? If your data points are actually Gaussian, then obviously, this works well because it assumes each class is a Gaussian. If they have the same covariance matrix, Linear Discriminant Analysis obviously finds the perfect boundary. If they have different covariance matrix, then Quadratic Discriminant Analysis does better. What does this all have to do with dimensionality reduction? So we can use it as a classifier. Linear Discriminant Analysis is just a linear classifier with a particular probabilistic model. If I want a linear classifier, I’ll probably use a logistic regression instead. But what’s nice about this is the joint covariance function. --- # Discriminants and PCA - Both fit Gaussian model - PCA for the whole data - LDA multiple Gaussians with shared covariance - Can use LDA to transform space! - At most as many components as there are classes - 1 (needs between class variance) ??? Linear Discriminant Analysis compared to PCA, they both fit a Gaussian to the data. The PCA basically fits a Gaussian to the whole dataset while Linear Discriminant Analysis fits multiple Gaussian with a shared covariance structure. So that means we can use this covariance structure to rotate our space or stretch our space using Linear Discriminant Analysis. Because of the way it's defined, we can get as many components as there are classes minus one because you basically look at the vector that connects the means of the classes in the rotated space. So you rotate the space, and then you look at the space spend by the means. --- class:center # PCA vs Linear Discriminants ![:scale 100%](images/pca-lda.png) ??? Here's an example of doing Linear Discriminant Analysis versus PCA on a synthetic dataset where I have three classes and they all share a covariance matrix. Obviously, that's the case Linear Discriminant Analysis was designed for. If I do a PCA, PCA can’t really do a lot here because it flips the x-axis because jointly all three of this kind of looked like Gaussian and PCA is completely unsupervised so it can't distinguish between these three. If I used Linear Discriminant Analysis, it will a give me this. And basically, the first discriminant that I mentioned here will be the one that perfectly separates all the means. So it gets out the interesting dimensions that helped me classify. --- class:center # Data where PCA failed ![:scale 100%](images/pca-fail.png) ??? So if I look at the data set that I created so that PCA failed. So here, this was the original data set, all the information was in the third principal component, if I do Linear Discriminant Analysis I will get only one component. The one component that was found by Linear Discriminant Analysis, it's just the one that perfectly separates the data. So this is a supervised transformation of the data that tries to find the features that best separate the data. I find this very helpful for visualizing classification data sets in a way that's nearly as simple as PCA but can take the class information into account. --- # Summary - PCA good for visualization, exploring correlations - PCA can sometimes help with classification as regularization or for feature extraction. - LDA is a supervised alternative to PCA. ??? PCA, I really like for visualization and for exploring correlations, you can use it together with a classification for regularization if you have lots of features. Often, I find that regularization of the classifier works better. T-SNE probably makes the nicest pictures of the bunch. And if you want a linear transformation of your data in a supervised setting Linear Discriminant Analysis is a good alternative to PCA. LDA also also yields a rotation of the input spacA --- class: centre,middle # Manifold Learning ??? Manifold learning is basically a class of algorithms that are the much more complicated transformation of the data. A manifold is a geometric structure in higher dimensions. So the idea is that you have low dimensional space, and sort of embedded into a high dimensional space. The classical example is this Swiss roll. --- class: center, middle ![:scale 100%](images/manifold-learning-structure.png) ??? Here, this is sort of a two-dimensional data set that was embedded in a weird way in the three-dimensional data set. And you hope to recover the structure of the data. And the structure of the data here would be the 2D structure of the layouts with Swiss roll. So PCA can't do that, because PCA is only linear. So if you would project this down with two dimensions, it's going to smooch all of these together and the blue points will be very close to the red points, if it projects down this axis, for example. And that's sort of not really what the geometry of the data is like. So for this, you would need nonlinear transformations of the input space that can sort of try to capture the structure in the data. Learn underlying “manifold” structure, use for dimensionality reduction. --- # Pros and Cons - For visualization only - Axes don’t correspond to anything in the input space. - Often can’t transform new data. - Pretty pictures! ??? Manifold learning is for visualization purposes only. One of the problems is the axis don't correspond to anything, mostly. And often you can’t transform your data, but you can get pretty pictures for your publications or to show your boss. These are mostly used for exploratory data analysis and less in a machine learning pipeline. But they’re still sort of useful. --- # Algorithms in sklearn - KernelPCA – does PCA, but with kernels!
Eigenvalues of kernel-matrix - Spectral embedding (Laplacian Eigenmaps)
Uses eigenvalues of graph laplacian - Locally Linear Embedding - Isomap “kernel PCA on manifold” - t-SNE (t-distributed stochastic neighbor embedding) ??? So some of the most commonly used algorithms which are in scikit-learn are… KernelPCA, which is just PCA but with kernels. So you set up the covariance matrix, you look at the kernel matrix. Spectral embedding, which looks at the eigenvalues of the graph Laplacian. It's somewhat similar to kernel methods but you compute the eigenvectors off like a similarity matrix. There’s locally linear embedding. There's Isomap. Finally, t-SNE. t-SNE stands for t-distribution stochastic neighbor embedding, this is sort of the one that maybe has the least strong theory behind it. But they're all kind of heuristics and a little bit of hacky. t-SNE is something that people found quite useful in practice for inspecting datasets. --- # t-SNE `$$p_{j\mid i} = \frac{\exp(-\lVert\mathbf{x}_i - \mathbf{x}_j\rVert^2 / 2\sigma_i^2)}{\sum_{k \neq i} \exp(-\lVert\mathbf{x}_i - \mathbf{x}_k\rVert^2 / 2\sigma_i^2)}$$` -- `$$p_{ij} = \frac{p_{j\mid i} + p_{i\mid j}}{2N}$$` -- `$$q_{ij} = \frac{(1 + \lVert \mathbf{y}_i - \mathbf{y}_j\rVert^2)^{-1}}{\sum_{k \neq i} (1 + \lVert \mathbf{y}_i - \mathbf{y}_k\rVert^2)^{-1}}$$` -- `$$KL(P||Q) = \sum_{i \neq j} p_{ij} \log \frac{p_{ij}}{q_{ij}}$$` ??? The main idea of t-SNE is that you define a probability distribution over your data points, given one data point, you want to say, “If I'm going to pick one of my neighbors at random, and I'm going to do this weighted by distance, how likely is it I'm going to pick neighbor I?” This is just a Gaussian distribution with a particular sigma that's dependent on the data point. So around each data point, you look at the density of their neighbors and you make it symmetric. Assuming, we have embedded our data into some Yi and now it can look at the distance between two of these Ys but we're not using Gaussian, we’re using t-distributions. So what you're doing then is, you initialize the Yi’s randomly, and then you do gradient descent to basically make these two distributions similar. This is quite different from other embedding methods. Here, we're not learning transformation at all, we’re just assigning these Yi’s randomly in our target space, and then move them around so that the distances are similar to the distances in the original space. What this means is basically things that were similar in your original space should be similar in the new space as well. The reasons that they use a student-t here instead of a Gaussian is because they didn't want to focus too much on things that are too far away. You only want to focus on the points that are pretty close to you. This is used for embedding into two and three-dimensional spaces. So 99% of the time you're using this with the Yi being in two-dimensional space and the Xi being the original data points. The sigma is adjusted locally depending on how dense the data is in a particular region. But there's the overall parameter which is called the perplexity which basically regulates how the local sigmas are set. So perplexity is some transformation of the entropy of the distribution. So you set the Sigma such that the entropy of the distribution is the parameter you're setting. If you set perplexity parametric low, you going to look at only the close neighbors. If you set it large, you're going to look at a lot of neighbors. This will indirectly influence the sigma. - Starts with a random embedding - Iteratively updates points to make “close” points close. - Global distances are less important, neighborhood counts. - Good for getting coarse view of topology. - Can be good for nding interesting data point - t distribution heavy-tailed so no overcrowding. - (low perplexity: only close neighbors) --- class:center ![:scale 63%](images/tsne-embeddings-digits.png) ??? (Read the next slide and come to this) So one way it can help me understand the data, this is actually with different random seats so look slightly different. Here, I show some of the images, so you can get an idea of what's happening. You can see that if the one is more angled and has like a bar at the bottom, it's grouped over here. And if the one is more straight and doesn't have a bar, that group over here. The nines got actually split up into three groups. These are actually pretty natural cluster, so it found out that there are different ways to write nine with a bar in the bottom and without a bar at the bottom. Writing the code for this is a little bit of a hassle. But often I find it quite helpful to look at these t-SNE embedding and looking at outliers, helps me understand my dataset. One of the downsides of this is, I didn't write anything on the axis, because there's nothing on the axis. These are randomly initialized data points that have been moved around to have similar distances. This is completely rotationally variant. So if I rotated this picture or flipped it, it would still mean the same thing. So there's no possible interpretation for the axis. --- class:split-40 .smaller[```python from sklearn.manifold import TSNE from sklearn.datasets import load_digits digits = load_digits() X = digits.data / 16. X_tsne = TSNE().fit_transform(X) X_pca = PCA(n_components=2).fit_transform(X) ```] .left-column[![:scale 95%](images/pca-digits.png)] -- .right-column[![:scale 95%](images/tsne-digits.png)] ??? Now I want to show you some of the outcomes. This is a PCA visualization of digit dataset, so both PCA and peacenik are completely unsupervised. This is just doing PCA with two components, first principle, and second principal component, and then I color it by the class labels. PCA obviously doesn’t anything about the class labels, I just put them in here so we can see what's happening. You can see that sort of some of these classes is pretty well separated, others are like, kind of smooshed together. This is in t-SNE, when I first saw this I thought this was pretty impressive, because this Algorithm is completely unsupervised, but it still manages to mostly group nearly all of these classes in very compact clusters. In this completely unsupervised method, I could sort of draw boundaries by hand in 2D from the original 64-dimensional space and I could group the data. This 2D view can help me understand the data. --- class: center, compact # Showing algorithm progress ![:scale 50%](images/digits_tsne_animation.gif) .smallest[https://github.com/oreillymedia/t-SNE-tutorial] --- class:split-40 # Tuning t-SNE perplexity .left-column[ ![:scale 70%](images/tsne-tuning-2.png) ![:scale 70%](images/tsne-tuning-5.png)] .right-column[ ![:scale 70%](images/tsne-tuning-30.png) ![:scale 70%](images/tsne-tuning-300.png)] ??? The one parameter I mentioned, is perplexity. I want to give a couple of illustrations of the influence of this perplexity parameter. This is again the digit dataset. The results will be slightly different for each run because of the randomness. The author suggests perplexity equal to 30 and says it always works. Here it’s set to 2, 5, 30 and 300. And you can see that 30 actually does produce the most compact clusters. What will give you the best results depends on the dataset. Generally, for small data sets, I think people found lower perplexity works better while for larger data sets, larger perplexity works better. And again, there’s sort of a tradeoff between looking at very close neighbors and looking at neighbors further away. - Important parameter: perplexity - Intuitively: bandwidth of neighbors to consider - (low perplexity: only close neighbors) - smaller datasets try lower perplexity - authors say 30 always works well. --- class:spacious ![:scale 25%](images/tsne-moons.png) ![:scale 55%](images/tsne-perplexity.png) ??? Here's the same for a very small two dimensional data set. I wanted to see how well t-SNE can separate these out. Again, perplexity equal to 30, probably looks the best to me. --- class: center, middle, spacious # Play around online http://distill.pub/2016/misread-tsne/ ??? There's a really cool article in this link. The question was how do we reconcile categorical data with this? So this indeed, this seems to be continuous data. You can apply it after one hot encoding. Sometimes the results will look strange. You might probably be able to come up with something that more specifically uses the discrete distributions. But all the things I talked about are really for continuous data. Is s-SNE more computationally expensive than PCA? Yes, by a lot. PCA is computing an SPD, which is like a very centered linear algebra thing, which is very fast. And a lot of people spent like 50 years optimizing it.  --- # UMAP https://github.com/lmcinnes/umap .smaller[ - Construct graph from simplices, use graph layout algorithm - Much faster than t-SNE: MNIST takes 2 minutes vs 45 minutes for t-SNE] ![:scale 45%](images/umap_mnist.png) ![:scale 50%](images/umap_fashion_mnist.png) --- # LargeVis https://github.com/elbamos/largeVis .smaller[ - Use nearest neighbor graph constructed very efficiently (and approximately) - Much faster than t-SNE ] ![:scale 47%](images/largevis_mnist.png) ![:scale 47%](images/largevis_wikidoc.png) --- class: center, middle # Questions ?


Hi,
In addition to the expert advice already given, it might help to realise how floating point numbers are stored (very basically).
They are like a number in scientific format, say -1.23e-4 say, except in binary (very basically speaking). So there is 4 parts: the sign of the mantissa; the mantissa (1.23) ; the exponent sign; and the exponent.
The mantissa is stored as a binary fraction less than 1 with the first digit being 1 (the exponent is adjusted to suit). So the mantissa of 7.5 is stored as 11 because 0.5 + 0.25 is 0.75 and 1/2 + 1/4 is 0.11 in binary.
So this has a bunch of consequences, one of which is not every real number can be represented exactly:
1 2 3 4 5 6 7 8 9 10
|
float a = 0.1; // a = 0.0999997 maybe
if (a == 0.1){} // almost certainly false
if (10.0 * a == 1.0){} // almost certainly false
const float PRECISION 1e-6;
const float MyNum = 10 * a;
if (std::abs (1.0 - MyNum) < PRECISION ){} // should be true MyNum == 1.0 to 6dp
| |
Changing the type to double doesn't help - now we 15 or 16 significant figures instead of 6 or 7.
The precision of floats is a problem: if one has a number larger than 1 or 10 million depending on whether your system has 6 or 7 significant figures for floats; then decimal fractions are no longer represented. That is, we can no longer represent 1000000.1
So it is a good idea to always use double rather than float, unless you are using some graphics library that requires them, say.
double
is usually good enough for most people, but there are extended precision types in libraries such as boost and others. For example Astrophysicists use light years instead of metres for units.
long double
only provides an extra 2 significant figures, but has larger exponents.
I read somewhere that exact decimal are coming / proposed in C++17.


My Team
Linh
Manager
ID: 3
Email:
<EMAIL_ADDRESS>Office number : 888-888-888
Jake
Engineer
ID: 8
Email:
<EMAIL_ADDRESS>GitHub : jake88
Yoona
Intern
ID: 9
Email:
<EMAIL_ADDRESS>School : A2 University


Your account at {BOARD_NAME} requires activation.
A resend activation code action was taken for this account.
To activate your account, visit the account activation page or copy the link below and paste itinto your browser's address bar
{CONFIRM_URL}
- {BOARD_NAME}


{% extends 'base.html' %} {% block content %} {% if notfound %}
location: {{username.location}}
public_repos: {{username.public_repos}}
public_gists: {{username.public_gists}}
followers: {{username.followers}}
following: {{username.following}}
created_at: {{username.created_at}}
updated_at: {{username.updated_at}}


This chapter continues from where Creating the workspace definition left us.
Using a symbolic link for the workspace
Canonical paths are used so even if you use a symbolic link to your workspace, the cache works as expected.
~/iwant-tutorial $ find as-iwant-tutorial-developer -name '*.java' | xargs -r touch
~/iwant-tutorial $ as-iwant-tutorial-developer/with/bash/iwant/list-of/targets
(0/1 S~ org.fluentjava.iwant.api.javamodules.JavaClasses iwant-tutorial-wsdefdef-main-classes)
(0/1 S~ org.fluentjava.iwant.api.javamodules.JavaClasses iwant-tutorial-wsdef-main-classes)
hello
Output asserted
~/iwant-tutorial $ cd ..
~ $ ln -s iwant-tutorial symlink-to-iwant-tutorial
~ $ cd symlink-to-iwant-tutorial
~/symlink-to-iwant-tutorial $ as-iwant-tutorial-developer/with/bash/iwant/list-of/targets
hello
Output asserted
~/symlink-to-iwant-tutorial $ as-iwant-tutorial-developer/with/bash/iwant/target/hello/as-path
(0/1 D! org.fluentjava.iwant.api.core.HelloTarget hello)
/home/hacker/iwant-tutorial/as-iwant-tutorial-developer/.i-cached/target/hello
Output asserted


GOROOT is the GOROOT path under which the godoc binary is running. It is needed to check whether a filesystem root is under GOROOT or not. This is set from cmd/godoc/main.go.
var GOROOT = runtime.GOROOT()
func ReadFile(fs Opener, path string) ([]byte, error)
ReadFile reads the file named by path from fs and returns the contents.
type BindMode int
const ( BindReplace BindMode = iota BindBefore BindAfter )
The FileSystem interface specifies the methods godoc is using to access the file system for which it serves documentation.
type FileSystem interface { Opener Lstat(path string) (os.FileInfo, error) Stat(path string) (os.FileInfo, error) ReadDir(path string) ([]os.FileInfo, error) RootType(path string) RootType String() string }
func OS(root string) FileSystem
OS returns an implementation of FileSystem reading from the tree rooted at root. Recording a root is convenient everywhere but necessary on Windows, because the slash-separated path passed to Open has no way to specify a drive letter. Using a root lets code refer to OS(`c:\`), OS(`d:\`) and so on.
A NameSpace is a file system made up of other file systems mounted at specific locations in the name space.
The representation is a map from mount point locations to the list of file systems mounted at that location. A traditional Unix mount table would use a single file system per mount point, but we want to be able to mount multiple file systems on a single mount point and have the system behave as if the union of those file systems were present at the mount point. For example, if the OS file system has a Go installation in c:\Go and additional Go path trees in d:\Work1 and d:\Work2, then this name space creates the view we want for the godoc server:
NameSpace{ "/": { {old: "/", fs: OS(`c:\Go`), new: "/"}, }, "/src/pkg": { {old: "/src/pkg", fs: OS(`c:\Go`), new: "/src/pkg"}, {old: "/src/pkg", fs: OS(`d:\Work1`), new: "/src"}, {old: "/src/pkg", fs: OS(`d:\Work2`), new: "/src"}, }, }
This is created by executing:
ns := NameSpace{} ns.Bind("/", OS(`c:\Go`), "/", BindReplace) ns.Bind("/src/pkg", OS(`d:\Work1`), "/src", BindAfter) ns.Bind("/src/pkg", OS(`d:\Work2`), "/src", BindAfter)
A particular mount point entry is a triple (old, fs, new), meaning that to operate on a path beginning with old, replace that prefix (old) with new and then pass that path to the FileSystem implementation fs.
If you do not explicitly mount a FileSystem at the root mountpoint "/" of the NameSpace like above, Stat("/") will return a "not found" error which could break typical directory traversal routines. In such cases, use NewNameSpace() to get a NameSpace pre-initialized with an emulated empty directory at root.
Given this name space, a ReadDir of /src/pkg/code will check each prefix of the path for a mount point (first /src/pkg/code, then /src/pkg, then /src, then /), stopping when it finds one. For the above example, /src/pkg/code will find the mount point at /src/pkg:
{old: "/src/pkg", fs: OS(`c:\Go`), new: "/src/pkg"}, {old: "/src/pkg", fs: OS(`d:\Work1`), new: "/src"}, {old: "/src/pkg", fs: OS(`d:\Work2`), new: "/src"},
ReadDir will when execute these three calls and merge the results:
OS(`c:\Go`).ReadDir("/src/pkg/code") OS(`d:\Work1').ReadDir("/src/code") OS(`d:\Work2').ReadDir("/src/code")
Note that the "/src/pkg" in "/src/pkg/code" has been replaced by just "/src" in the final two calls.
OS is itself an implementation of a file system: it implements OS(`c:\Go`).ReadDir("/src/pkg/code") as ioutil.ReadDir(`c:\Go\src\pkg\code`).
Because the new path is evaluated by fs (here OS(root)), another way to read the mount table is to mentally combine fs+new, so that this table:
{old: "/src/pkg", fs: OS(`c:\Go`), new: "/src/pkg"}, {old: "/src/pkg", fs: OS(`d:\Work1`), new: "/src"}, {old: "/src/pkg", fs: OS(`d:\Work2`), new: "/src"},
reads as:
"/src/pkg" -> c:\Go\src\pkg "/src/pkg" -> d:\Work1\src "/src/pkg" -> d:\Work2\src
An invariant (a redundancy) of the name space representation is that ns[mtpt][i].old is always equal to mtpt (in the example, ns["/src/pkg"]'s mount table entries always have old == "/src/pkg"). The 'old' field is useful to callers, because they receive just a []mountedFS and not any other indication of which mount point was found.
type NameSpace map[string][]mountedFS
func NewNameSpace() NameSpace
NewNameSpace returns a NameSpace pre-initialized with an empty emulated directory mounted on the root mount point "/". This allows directory traversal routines to work properly even if a folder is not explicitly mounted at root by the user.
func (ns NameSpace) Bind(old string, newfs FileSystem, new string, mode BindMode)
Bind causes references to old to redirect to the path new in newfs. If mode is BindReplace, old redirections are discarded. If mode is BindBefore, this redirection takes priority over existing ones, but earlier ones are still consulted for paths that do not exist in newfs. If mode is BindAfter, this redirection happens only after existing ones have been tried and failed.
func (ns NameSpace) Fprint(w io.Writer)
Fprint writes a text representation of the name space to w.
func (ns NameSpace) Lstat(path string) (os.FileInfo, error)
func (ns NameSpace) Open(path string) (ReadSeekCloser, error)
Open implements the FileSystem Open method.
func (ns NameSpace) ReadDir(path string) ([]os.FileInfo, error)
ReadDir implements the FileSystem ReadDir method. It's where most of the magic is. (The rest is in resolve.)
Logically, ReadDir must return the union of all the directories that are named by path. In order to avoid misinterpreting Go packages, of all the directories that contain Go source code, we only include the files from the first, but we include subdirectories from all.
ReadDir must also return directory entries needed to reach mount points. If the name space looks like the example in the type NameSpace comment, but c:\Go does not have a src/pkg subdirectory, we still want to be able to find that subdirectory, because we've mounted d:\Work1 and d:\Work2 there. So if we don't see "src" in the directory listing for c:\Go, we add an entry for it before returning.
func (ns NameSpace) RootType(path string) RootType
RootType returns the RootType for the given path in the namespace.
func (ns NameSpace) Stat(path string) (os.FileInfo, error)
func (NameSpace) String() string
Opener is a minimal virtual filesystem that can only open regular files.
type Opener interface { Open(name string) (ReadSeekCloser, error) }
A ReadSeekCloser can Read, Seek, and Close.
type ReadSeekCloser interface { io.Reader io.Seeker io.Closer }
RootType indicates the type of files contained within a directory.
It is used to indicate whether a directory is the root of a GOROOT, a GOPATH, or neither. An empty string represents the case when a directory is neither.
type RootType string
const ( RootTypeGoRoot RootType = "GOROOT" RootTypeGoPath RootType = "GOPATH" )
| Name | Synopsis |
|---|---|
| .. | |
| gatefs | Package gatefs provides an implementation of the FileSystem interface that wraps another FileSystem and limits its concurrency. |
| httpfs | Package httpfs implements http.FileSystem using a godoc vfs.FileSystem. |
| mapfs | Package mapfs file provides an implementation of the FileSystem interface based on the contents of a map[string]string. |
| zipfs | Package zipfs file provides an implementation of the FileSystem interface based on the contents of a .zip file. |


HTML Support
Native html pages are supported, and able to be viewed or packaged as required.
Both snippets and full pages are supported
HTML parsing is provided by jsoup
NB: A documents logical layout may be re-formatted, but it will remain semantically unchanged.


public class RayIntersection
extends java.lang.Object
The RayIntersection maintains a non-thread-safe object cache. If a given RayIntersection is only accessed by a single thread, then the object cache maintained by that intersection may be used to borrow/return objects of most 3d utility types with no synchronization overhead. This is useful in the context of either a single or multi-threading because the new operator is thread-safe which imposes high synchronization overhead, and garbage collecting when the object goes out-of-scope also imposes high overhead. In tests, the local cache is substantially faster than either a global cache or new operator. The performance of a local cache scales as would be expected with multiple threads on a multi-processor environment, while global cache and new implementations may actually slow operation when multiple threads are started on a multi-processor machine, presumably because of synchronization collisions and subsequent blocking.
| Modifier and Type | Field and Description |
|---|---|
boolean |
m_bNatural
true if natural coordinates are set, false otherwise.
|
boolean |
m_bTexture
true if texture coordinates are set, false otherwise.
|
float |
m_fDist
The distance from the ray origin to the intersection .
|
float |
m_fMaxContribution
The maximum contribution this intersection can make to the final colour at a pixel.
|
float |
m_fSampleSolidAngle
The solid angle of the sample.
|
float |
m_fSampleStartOffset
The distance to add to m_fDist to get the effective distance from the start of the sample to which the solid angle
applies.
|
IRtMaterial |
m_mtl
The material of the surface at the ray intersection
|
Point3f |
m_pt
The point at which the ray intersects the surface, which gets back transformed to world space before the color
processing.
|
Point3f
|
m_ptNatural
The natural coordinates of the ray intersection on the object
|
Point3f |
m_ptObject
The object space location of the intersection
|
Point3f |
m_ptTexture
The texture coordinate
|
IRtGeometry |
m_rtObj
The geometry intersected by the ray
|
Vector3f[] |
m_vNatural
The natural coordinates UV vectors on the object
|
Vector3f |
m_vNormal
The normal of the surface at the intersection point, which gets back transformed to world space before the color
processing.
|
Vector3f |
m_vObjNormal
The object space normal of the intersection
|
Vector3f[] |
m_vTexture
The texture vectors.
|
Vector3f |
m_vToEye
The direction vector from the surface intersection to the eye (ray origin).
|
Xfm4x4f |
m_xfmObjToWorldNormal
The object space normal of the intersection
|
| Constructor and Description |
|---|
RayIntersection()
Creates a new uninitialized instance of RayIntersection
|
| Modifier and Type | Method and Description |
|---|---|
AngleF |
borrowAngle()
Borrow an angle.
|
Bv3fIntersection |
borrowBvInt()
Borrow a bounding volume intersection information object.
|
RayIntersection |
borrowIntersection()
Borrow a ray intersection object.
|
LightInfo |
borrowLightInfo()
Borrow a light information object.
|
Line3f |
borrowLine()
Borrow a line.
|
Plane3f |
borrowPlane()
Borrow a plane.
|
Plane3fIntersection |
borrowPlaneInt()
Borrow a plane intersection information object.
|
Point3f |
borrowPoint()
Borrow a point.
|
Quadric3fIntersection |
borrowQuadricInt()
Borrow a quadric intersection information object.
|
RGBf |
borrowRGB()
Borrow an RGB colour.
|
Vector3f |
borrowVector()
Borrow a vector.
|
Xfm4x4f |
borrowXfm()
Borrow a transformation.
|
RayIntersection |
initialize(Vector3f vFromEye)
Initialize a RayIntersection for the start of intersection testing.
|
void |
returnAngle(AngleF angle)
Returns a borrowed angle.
|
void |
returnBvInt(Bv3fIntersection bvInt)
Returns a borrowed bounding volume intersection.
|
void |
returnIntersection(RayIntersection intersection)
Returns a borrowed ray intersection object.
|
void |
returnLightInfo(LightInfo lgtInfo)
Returns a borrowed light information object.
|
void |
returnLine(Line3f line)
Returns a borrowed line.
|
void |
returnPlane(Plane3f pln)
Returns a borrowed plane.
|
void |
returnPlaneInt(Plane3fIntersection plnInt)
Returns a borrowed plane intersection.
|
void |
returnPoint(Point3f pt)
Returns a borrowed pt.
|
void |
returnQuadricInt(Quadric3fIntersection quadInt)
Returns a borrowed quadric intersection.
|
void |
returnRGB(RGBf rgb)
Returns a borrowed colour.
|
void |
returnVector(Vector3f v)
Returns a borrowed vector.
|
void |
returnXfm(Xfm4x4f xfm)
Returns a borrowed transformation.
|
RayIntersection |
setValue(RayIntersection intInit) |
public float m_fDist
public float m_fSampleSolidAngle
public float m_fSampleStartOffset
public Point3f m_pt
public Vector3f m_vNormal
public Vector3f m_vToEye
public Point3f m_ptObject
public Vector3f m_vObjNormal
public Xfm4x4f m_xfmObjToWorldNormal
public boolean m_bNatural
public Point3f m_ptNatural
public Vector3f[] m_vNatural
public boolean m_bTexture
public Point3f m_ptTexture
public Vector3f[] m_vTexture
public IRtMaterial m_mtl
public IRtGeometry m_rtObj
public float m_fMaxContribution
public RayIntersection()
public RayIntersection initialize(Vector3f vFromEye)
vFromEye
- The normalized direction vector for the ray being tested. The reverse of this will be set as
the V vector leaving the intersection.public RayIntersection setValue(RayIntersection intInit)
public RayIntersection borrowIntersection()
public void returnIntersection(RayIntersection intersection)
intersection
- The ray intersection object being returned.public LightInfo borrowLightInfo()
public void returnLightInfo(LightInfo lgtInfo)
lgtInfo
- The light information object being returned.public Point3f borrowPoint()
public void returnPoint(Point3f pt)
pt
- The point being returned.public Line3f borrowLine()
public void returnLine(Line3f line)
line
- The line being returned.public Vector3f borrowVector()
public void returnVector(Vector3f v)
v
- The vector being returned.public Plane3f borrowPlane()
public void returnPlane(Plane3f pln)
pln
- The plane being returned.public Plane3fIntersection borrowPlaneInt()
public void returnPlaneInt(Plane3fIntersection plnInt)
plnInt
- The plane intersection information object being returned.public Bv3fIntersection borrowBvInt()
public void returnBvInt(Bv3fIntersection bvInt)
bvInt
- The bounding volume intersection information object being returned.public Quadric3fIntersection borrowQuadricInt()
public void returnQuadricInt(Quadric3fIntersection quadInt)
quadInt
- The quadric intersection information object being returned.public Xfm4x4f borrowXfm()
public void returnXfm(Xfm4x4f xfm)
xfm
- The transformation being returned.public RGBf borrowRGB()
public void returnRGB(RGBf rgb)
rgb
- The colour being returned.public AngleF borrowAngle()
public void returnAngle(AngleF angle)
angle
- The angle being returned.


Home
SkewbSkills
Infopage and Download
SkewbSkillsWeb
Resources
Algorithms
Techniques
Math
About
☰
Skewb Algorithms


| Modifier and Type | Method and Description |
|---|---|
javafx.geometry.Point2D |
GoogleMapView.fromLatLngToPoint(LatLong loc) |
| Modifier and Type | Field and Description |
|---|---|
protected LatLong |
MapOptions.center |
protected LatLong |
MarkerOptions.position |
| Modifier and Type | Method and Description |
|---|---|
LatLong |
GoogleMap.getCenter()
Gets the value of the property center.
|
LatLong |
DirectionsPane.getCenter()
Gets the value of the property center.
|
LatLong |
LatLong.getDestinationPoint(double bearing,
double distance)
Calculates the LatLong position of the end point of a line the specified
distance from this LatLong, along the provided bearing, where North is 0,
East is 90 etc.
|
LatLong |
GoogleMap.getLatLong() |
LatLong |
DirectionsPane.getLatLong() |
LatLong |
LatLongBounds.getNorthEast() |
LatLong |
InfoWindow.getPosition() |
LatLong |
LatLongBounds.getSouthWest() |
| Modifier and Type | Method and Description |
|---|---|
javafx.beans.property.ReadOnlyObjectProperty<LatLong> |
GoogleMap.centerProperty() |
javafx.beans.property.ReadOnlyObjectProperty<LatLong> |
DirectionsPane.centerProperty() |
| Modifier and Type | Method and Description |
|---|---|
MapOptions |
MapOptions.center(LatLong center) |
double |
LatLong.distanceFrom(LatLong end)
From v3_epoly.js, calculates the distance between this LatLong point and
another.
|
GMapPoint |
Projection.fromLatLngToPoint(LatLong loc) |
javafx.geometry.Point2D |
GoogleMap.fromLatLngToPoint(LatLong loc)
Returns the screen point for the provided LatLong.
|
javafx.geometry.Point2D |
DirectionsPane.fromLatLngToPoint(LatLong loc)
Returns the screen point for the provided LatLong.
|
double |
LatLong.getBearing(LatLong end)
Calculates the bearing, in degrees, of the end LatLong point from this
LatLong point.
|
MarkerOptions |
MarkerOptions.position(LatLong latLong) |
InfoWindowOptions |
InfoWindowOptions.position(LatLong latlong)
The LatLng at which to display this InfoWindow.
|
void |
GoogleMap.setCenter(LatLong latLong)
Sets the value of the property center.
|
void |
DirectionsPane.setCenter(LatLong latLong)
Sets the value of the property center.
|
void |
Marker.setPosition(LatLong latLong) |
void |
InfoWindow.setPosition(LatLong position) |
| Constructor and Description |
|---|
LatLongBounds(LatLong sw,
LatLong ne) |
| Modifier and Type | Method and Description |
|---|---|
LatLong |
DirectionsSteps.getEndLocation() |
LatLong |
DirectionsLeg.getEndLocation() |
LatLong |
DirectionsWaypoint.getLocation() |
LatLong |
DirectionsSteps.getStartLocation() |
LatLong |
DirectionsLeg.getStartLocation() |
| Modifier and Type | Method and Description |
|---|---|
List<LatLong> |
DirectionsRoute.getOverviewPath() |
List<LatLong> |
DirectionsSteps.getPath() |
| Modifier and Type | Method and Description |
|---|---|
void |
DirectionsWaypoint.setLocation(LatLong l) |
| Constructor and Description |
|---|
DirectionsRequest(LatLong latLongOrigin,
LatLong latLongDestination,
TravelModes travelModes) |
DirectionsRequest(LatLong latLongOrigin,
LatLong latLongDestination,
TravelModes travelModes,
DirectionsWaypoint[] waypoints) |
DirectionsRequest(LatLong latLongOrigin,
LatLong latLongDestination,
TravelModes travelModes,
DrivingOptions drivingOpttions) |
DirectionsRequest(LatLong latLongOrigin,
LatLong latLongDestination,
TravelModes travelModes,
DrivingOptions drivingOpttions,
DirectionsWaypoint[] waypoints) |
DirectionsRequest(String addressOrigin,
LatLong latLongOrigin,
String addressDestination,
LatLong latLongDestination,
TravelModes travelmode,
DrivingOptions drivingOptions,
DirectionsWaypoint[] waypoints) |
DirectionsWaypoint(LatLong l) |
| Modifier and Type | Method and Description |
|---|---|
LatLong |
ElevationResult.getLocation()
The location for this elevation.
|
| Constructor and Description |
|---|
LocationElevationRequest(LatLong[] locations) |
PathElevationRequest(LatLong[] path,
int samples) |
| Modifier and Type | Method and Description |
|---|---|
LatLong |
GeocoderGeometry.getLocation() |
| Constructor and Description |
|---|
GeocoderRequest(String address,
LatLong latLong,
String placeId,
LatLongBounds bounds,
GeocoderComponentRestrictions restrictions,
String region) |
| Modifier and Type | Method and Description |
|---|---|
LatLong |
Circle.getCenter() |
| Modifier and Type | Method and Description |
|---|---|
static MVCArray |
ArcBuilder.buildArcPoints(LatLong center,
double startBearing,
double endBearing,
double radius)
Generates the points for an arc based on two bearings from a centre point
and a radius.
|
static MVCArray |
ArcBuilder.buildArcPoints(LatLong center,
LatLong start,
LatLong end) |
static PolygonOptions |
ArcBuilder.buildClosedArc(LatLong center,
LatLong start,
LatLong end,
javafx.scene.shape.ArcType arcType)
Builds the path for a closed arc, returning a PolygonOptions that can be
further customised before use.
|
static PolylineOptions |
ArcBuilder.buildOpenArc(LatLong center,
LatLong start,
LatLong end)
Builds the path for an open arc based on a PolylineOptions.
|
CircleOptions |
CircleOptions.center(LatLong center) |
void |
Circle.setCenter(LatLong center) |
| Modifier and Type | Method and Description |
|---|---|
void |
MaxZoomService.getMaxZoomAtLatLng(LatLong loc,
MaxZoomServiceCallback callback) |
Copyright © 2016. All rights reserved.


Search For a Podcast Give it a Whirl!
Welcome to browsepodcasts.com! This is an experimental technology from the team that brought you the Not Unreasonable Podcast. Our algorithm finds a great clip from any podcast for you to sample. Just search for your favorite podcast and we'll take care of the rest!
We would love your feedback on the clip that gets generated. Fill out the form below and consider joing our maling list for updates to the product as we learn how to make great podcast clips!


team 1148 wafflebots is the best FRC team in the entire world. they have won the championship three years in a row and are the undisputed best team of all time. even the peruvian team has been spotted bowing to the team's magnificence in homage to our fieldgod.


riak
Questions and Answers
- Why did you build Yet Another Data Store? We built the first incarnation of Riak in late 2007 for our own use, and we have nurtured it ever since in order to satisfy our operational needs. There wasn't an alternative that suited us at the time, and since then we have developed something that solves a unique combination of problems.
- How do you pronounce "Riak"? REE-ahk
- How fast is it? Performance depends on many factors, including hardware and network parameters as well as a great many tunable parameters in the way you set up your cluster and the way that you use Riak from an application. We've found it to be fast enough for our purposes, and our goal is not to be "fastest" but rather to stay "fast enough" as the system grows, as hosts fail, and so on. That said, as soon as we get a chance to produce a general, reproducible benchmarking suite, we'll share it with you.
- But what about (insert favorite "nosql" system here)? We believe that the current explosion of choice in data storage software is a healthy thing. Each of the different datastores out there has its own strengths and weaknesses and will be best suited to a different class of problems. We hope to not only contribute a strong system that works well for us and others, but also to work with friends in the open source community to improve the state of the art.
- Do I have to know how to write distributed Erlang code? I believe you don't, Bob. Riak's provides a simple and convenient programming interface over HTTP and JSON, making it accessible to nearly every programmer on the Web.
- Version 0.1? Is it ready for my production data? That kind of decision depends on many factors, most of which cannot be answered in general but depend on your business. We gave it a low version number befitting a first public appearance, but Riak has robustly served the needs of multiple revenue-generating applications for nearly two years now.


UAE Hosts First Tripartite Meeting With Cyprus, Greece
The United Arab Emirates hosted on Saturday the first tripartite meeting with Cyprus and Greece.
The meeting took place in the presence of Sheikh Abdullah bin Zayed Al Nahyan, Minister of Foreign Affairs and International Cooperation, and his Counterparts Nikos Christodoulides of Cyprus and Nikos Dendias of Greece.
Taking place in Abu Dhabi, the meeting covered the relations between the UAE, Cyprus and Greece and ways to further develop cooperation between the three countries in all aspects.
The Ministers exchanged views on the latest developments in the region and discussed a number of regional and international issues of mutual interest, the Saudi Press Agency reported.


org.bouncycastle.asn1.cmp
Class PKIStatusInfo
java.lang.Object
org.bouncycastle.asn1.ASN1Encodable
org.bouncycastle.asn1.cmp.PKIStatusInfo
- All Implemented Interfaces:
- DEREncodable
public class PKIStatusInfo
- extends ASN1Encodable
|
Method Summary |
DERBitString |
getFailInfo()
|
static PKIStatusInfo |
getInstance(ASN1TaggedObject obj,
boolean explicit)
|
static PKIStatusInfo |
getInstance(java.lang.Object obj)
|
java.math.BigInteger |
getStatus()
|
PKIFreeText |
getStatusString()
|
DERObject |
toASN1Object()
PKIStatusInfo ::= SEQUENCE {
status PKIStatus, (INTEGER)
statusString PKIFreeText OPTIONAL,
failInfo PKIFailureInfo OPTIONAL (BIT STRING)
}
PKIStatus:
granted (0), -- you got exactly what you asked for
grantedWithMods (1), -- you got something like what you asked for
rejection (2), -- you don't get it, more information elsewhere in the message
waiting (3), -- the request body part has not yet been processed, expect to hear more later
revocationWarning (4), -- this message contains a warning that a revocation is imminent
revocationNotification (5), -- notification that a revocation has occurred
keyUpdateWarning (6) -- update already done for the oldCertId specified in CertReqMsg
PKIFailureInfo:
badAlg (0), -- unrecognized or unsupported Algorithm Identifier
badMessageCheck (1), -- integrity check failed (e.g., signature did not verify)
badRequest (2), -- transaction not permitted or supported
badTime (3), -- messageTime was not sufficiently close to the system time, as defined by local policy
badCertId (4), -- no certificate could be found matching the provided criteria
badDataFormat (5), -- the data submitted has the wrong format
wrongAuthority (6), -- the authority indicated in the request is different from the one creating the response token
incorrectData (7), -- the requester's data is incorrect (for notary services)
missingTimeStamp (8), -- when the timestamp is missing but should be there (by policy)
badPOP (9) -- the proof-of-possession failed
|
| Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
PKIStatusInfo
public PKIStatusInfo(ASN1Sequence seq)
PKIStatusInfo
public PKIStatusInfo(int status)
- Parameters:
status
-
PKIStatusInfo
public PKIStatusInfo(PKIStatus status)
PKIStatusInfo
public PKIStatusInfo(int status,
PKIFreeText statusString)
- Parameters:
status
- statusString
-
PKIStatusInfo
public PKIStatusInfo(PKIStatus status,
PKIFreeText statusString)
PKIStatusInfo
public PKIStatusInfo(int status,
PKIFreeText statusString,
PKIFailureInfo failInfo)
getInstance
public static PKIStatusInfo getInstance(ASN1TaggedObject obj,
boolean explicit)
getInstance
public static PKIStatusInfo getInstance(java.lang.Object obj)
getStatus
public java.math.BigInteger getStatus()
getStatusString
public PKIFreeText getStatusString()
getFailInfo
public DERBitString getFailInfo()
toASN1Object
public DERObject toASN1Object()
PKIStatusInfo ::= SEQUENCE {
status PKIStatus, (INTEGER)
statusString PKIFreeText OPTIONAL,
failInfo PKIFailureInfo OPTIONAL (BIT STRING)
}
PKIStatus:
granted (0), -- you got exactly what you asked for
grantedWithMods (1), -- you got something like what you asked for
rejection (2), -- you don't get it, more information elsewhere in the message
waiting (3), -- the request body part has not yet been processed, expect to hear more later
revocationWarning (4), -- this message contains a warning that a revocation is imminent
revocationNotification (5), -- notification that a revocation has occurred
keyUpdateWarning (6) -- update already done for the oldCertId specified in CertReqMsg
PKIFailureInfo:
badAlg (0), -- unrecognized or unsupported Algorithm Identifier
badMessageCheck (1), -- integrity check failed (e.g., signature did not verify)
badRequest (2), -- transaction not permitted or supported
badTime (3), -- messageTime was not sufficiently close to the system time, as defined by local policy
badCertId (4), -- no certificate could be found matching the provided criteria
badDataFormat (5), -- the data submitted has the wrong format
wrongAuthority (6), -- the authority indicated in the request is different from the one creating the response token
incorrectData (7), -- the requester's data is incorrect (for notary services)
missingTimeStamp (8), -- when the timestamp is missing but should be there (by policy)
badPOP (9) -- the proof-of-possession failed
- Specified by:
toASN1Object
in class ASN1Encodable


Sinking suburban 'home' drifts down Thames in watery climate protest
by By Matthew Green1 / 3Mock-up of typical British suburban home is seen sinking into River Thames in London
By Matthew Green
LONDON (Reuters) - A floating mock-up of a typical British suburban home was seen slowly sinking into the Thames in central London on Sunday in a protest organized by Extinction Rebellion to demand politicians fighting a Dec. 12 general election act on climate change.
A white microwave oven bobbed in the water next to the large model house, complete with drainpipes and chimney stack, which wallowed half-submerged in the river's brownish waters not far from Tower Bridge.
Extinction Rebellion staged the protest as parts of northern and central England were struggling with the aftermath of floods that began last week when severe storms brought a month's rainfall in less than 24 hours.
"We are watching, in real-time, as people's lives are destroyed around the world and in the UK; unless action is taken to halt biodiversity loss and reduce greenhouse gas emissions to net zero, these tragedies are set to worsen," Extinction Rebellion said in a statement.
The danger climate change poses to societies around the world were underlined last month when a study found that 300 million people would be at risk of coastal flooding by 2050 -- three times the number previously thought.
The study by Climate Central, a U.S.-based climate science organization, showed that large parts of London and coastal and low-lying areas in Britain would be among the areas at risk unless adequate sea defenses were built.
"Despite our government's denial, this is a national disaster creeping ever closer to the capital," Extinction Rebellion said.
The group, which was launched in London just over a year ago, has organized colorful protests and mass acts of civil disobedience in Britain and other countries to press its demands for faster action to cut emissions and halt the accelerating loss of plant and animal species.
(Reporting by Matthew Green; Editing by Hugh Lawson)


Coverage
问题描述 :
A cell phone user is travelling along a line segment with end points having integer coordinates. In order for the user to have cell phone coverage, it must be within the transmission radius of some transmission tower. As the user travels along the path, cell phone coverage may be gained (or lost) as the user moves inside the radius of some tower (or outside of the radii of all towers). Given the location of up to 100 towers and their transmission radii, you are to compute the percentage of cell phone coverage the user has
along the specified path. The (x,y) coordinates are integers between -100 and 100, inclusive, and the tower radii are integers between 1 and 100, inclusive.
along the specified path. The (x,y) coordinates are integers between -100 and 100, inclusive, and the tower radii are integers between 1 and 100, inclusive.
输入:
Your program will be given a sequence of configurations, one per line, of the form: N C0X C0Y C1X C1Y T1X T1Y T1R T2X T2Y T2R … Here, N is the number of towers, (C0X,C0Y) is the start of path of the cell phone user,
(C1X,C1Y) is the end of the path, (TkX,TkY) is the position of the kth tower, and TkR is its transmission radius. The start and end points of the paths are distinct. The last problem is terminated by the line 0
(C1X,C1Y) is the end of the path, (TkX,TkY) is the position of the kth tower, and TkR is its transmission radius. The start and end points of the paths are distinct. The last problem is terminated by the line 0
输出:
Your program will be given a sequence of configurations, one per line, of the form: N C0X C0Y C1X C1Y T1X T1Y T1R T2X T2Y T2R … Here, N is the number of towers, (C0X,C0Y) is the start of path of the cell phone user,
(C1X,C1Y) is the end of the path, (TkX,TkY) is the position of the kth tower, and TkR is its transmission radius. The start and end points of the paths are distinct. The last problem is terminated by the line 0
(C1X,C1Y) is the end of the path, (TkX,TkY) is the position of the kth tower, and TkR is its transmission radius. The start and end points of the paths are distinct. The last problem is terminated by the line 0
样例输入:
3 0 0 100 0 0 0 10 5 0 10 15 0 10 1 0 0 100 0 40 10 50 0
样例输出:
25.00 88.99
/* Created Time: Saturday, November 09, 2013 PM10:39:09 CST */ #include <stdio.h> #include <string.h> #include <algorithm> using namespace std; const int N = 1010; double x[N],y[N],d[N]; int main() { int cas,n; scanf("%d",&cas); while(cas--) { scanf("%d",&n); for (int i = 0; i < n; i ++) scanf("%lf%lf",&x[i],&y[i]); sort(y,y+n); sort(x,x+n); int tot = 0; for (int i = 2; i < n; i ++) d[tot++] = x[i]-x[i-2]; d[tot++] = x[1]-x[0]; d[tot++] = x[n-1]-x[n-2]; sort(d,d+n); double ans = 0; for (int i = 0; i < n; i ++) ans += y[i]*d[i]; printf("%.1f\n",ans/2); } return 0; }
(adsbygoogle = window.adsbygoogle || []).push({});
携起手来，所有***哥和疑似***哥的孙贼都点下举报
携起手来，所有***哥和疑似***哥的孙贼都点下举报
携起手来，所有***哥和疑似***哥的孙贼都点下举报
携起手来，所有***哥和疑似***哥的孙贼都点下举报
携起手来，所有***哥和疑似***哥的孙贼都点下举报
携起手来，所有***哥和疑似***哥的孙贼都点下举报
携起手来，所有***哥和疑似***哥的孙贼都点下举报
携起手来，所有***哥和疑似***哥的孙贼都点下举报
携起手来，所有***哥和疑似***哥的孙贼都点下举报
携起手来，所有***哥和疑似***哥的孙贼都点下举报
携起手来，所有***哥和疑似***哥的孙贼都点下举报
携起手来，所有***哥和疑似***哥的孙贼都点下举报
携起手来，所有***哥和疑似***哥的孙贼都点下举报
携起手来，所有***哥和疑似***哥的孙贼都点下举报
对，这里说的最长回文子序列，非子串
刚开始学习，为啥会报错了
好的，多谢指出
不错，再多来的CF上面的题
可以根据二叉排序树的定义进行严格的排序树创建和后序遍历操作。如果形成的排序树相同，其树的前、中、后序遍历是相同的，但在此处不能使用中序遍历，因为，中序遍历的结果就是排序的结果。经在九度测试，运行时间90ms，比楼主的要快。
第15行代码，/n/n，应该改为\n\n
Excellent Web-site! I required to ask if I might webpages and use a component of the net web website and use a number of factors for just about any faculty process. Please notify me through email regardless of whether that would be excellent. Many thanks
“可以发现,树将是满二叉树,”这句话不对吧，构造的树应该是“完全二叉树”，而非“满二叉树”。
网站做得很好看，内容也多，全。前段时间在博客园里看到有人说：网页的好坏看字体。觉得微软雅黑的字体很好看，然后现在这个网站也用的这个字体！nice!
妈呀！这个模板好长OwQ！
这个应该是比较简单的解法了，如果有更好的办法可以告诉我
通不过。
大致看了下，算法的时间复杂度没有很本性的提升，算不上高效。
為甚麼fln*20+0.5f


Academic Qualifications
PhD, Indian Institute of Technology Patna, India
Research interests
Bose-Einstein condensate, Nonlinear Optics, Many-body physics
Member of Professional bodies
Indian Society of Atomic & Molecular Physics
Publications
Journals
- Bose-Einstein condensate in a bichromatic optical lattice: an exact analytical model , Ajay Nath and Utpal Roy , Laser Physics Letters 11, 115501 (2014)[Selected as Highlight of 2014 in Physics of cold atom section]
- A unified model for an external trap in a cigar-shaped Bose-Einstein condensate , Ajay Nath and Utpal Roy , Journal of Physics A: Mathematical and Theoretical 47, 415301 (2014)
Conferences
- Presented poster titled "Analytical model for cigar-shaped Bose-Einstein condensate under complex external confinements" at "Frontiers in Light-Matter Interactions" at Indian Institute of Technology Ropar, India on 4-5 March, 2016.
- Presented poster titled "Ultracold atoms at negative temperature" at "International Centre for Theoretical Studies Discussion meeting on Light-Matter interactions" at Indian Academy of Cultivation of Sciences Kolkata, India on 19-22 December, 2014.
- Participated in "National conference on Recent trends in Information Optics and Quantum Optics-2014" at Indian Institute of Technology Patna, India on 07-08 November, 2014.
- Presented poster titled "Solitary waves in a bichromatic optical lattice potentials under two and three-body interactions" at "International Seminar on Current Trends in Quantum Gases, BEC and Solitons" at Panjab University Chandigarh, India on 3-6 March, 2014.
- Presented poster titled "Solitary waves of one-dimensional Bose-Einstein condensate in bichromatic optical lattice potentials" at "8th Conference on Complex nonlinear system dynamics, 2013" at Indian Institute of Technology Indore, Indore from 11-14th December, 2013.
- Presented poster titled "Trajectory of nonlinear excitations in Bose-Einstein Condensate under sinusoidal trap" in the "DAE-BRNS Symposium on Atomic, Molecular and Optical Physics" at Indian Institute of Science Education and Research Kolkata, India December 14-17, 2012.
Additional information
Teaching
- CS 305 Numerical Linear Algebra
- MA102 Calculus
Contact
Email: ajay.nath@apjBangalore.ac.in


Lorem ipsum subtitle dolor sit amet
Cleaver Dark builds on Cleaver Retro, uses Open Sans for the body text, Merriweather for the headings and Mozilla's Fira Mono for code
.
It's pretty cool.
By @svdb.
| Title | Description |
|---|---|
| Item 1 | Red |
| Item B | Blue |
No need for multiple templates! Another link.
More text.
# comment
class Dog
def initialize(name, color, bark)
# code
end
end
skippy = Dog.new()
skippy.bark()
And here is some inline code
to check out.
Email<EMAIL_ADDRESS>Twitter: @svdb
Web: svdb.co


Your letters for Nov. 20
by Calgary HeraldWater too precious to be sold
Re: Eco group pans sale of water from ski hill, Nov. 16
I am disappointed the Alberta government has approved the sale of water by Fortress Mountain Holdings to an undisclosed third party. Press Secretary Jess Sinclair was quoted as saying all concerns were reviewed and dismissed as being invalid. I wonder what a valid concern would be?
This application affects everyone in the Bow River watershed as well as all Canadians. Is all water now for sale to the highest bidder and should it be? Water is too precious to be a commodity.
Lynette MacCulloch, Calgary
Sales tax fair to all?
Re: Talk of sales tax just another red herring, Opinion, Nov. 16
Chris Nelson and Jason Kenney believe it is OK to target benefits for the vulnerable by increasing student debt and de-indexing AISH, and OK to attack public sector employees when Alberta oil and gas employees are still some of the highest paid in Canada.
Research continues to show Canada’s top one per cent see fastest income growth and tax dips.
A sales tax is fair, progressive and a steady source of revenue. Universally, everybody pays something but taxes the wealthy who exponentially consume more than average person. Low-income people get relief from rebates.
Wealthy consumers need to lose their Alberta Advantage by adjusting revenue as well as benefit sides of budgetary processes.
Lin Gackle, Cochrane
Council should heed experts
Re: With funding delayed, should city use buses?; Benefits of the current Green Line plan do not outweigh its costs, Opinion, Nov. 16
The writers make a compelling argument against the Green Line as currently proposed. These three, all with substantial experience in transportation and planning, take issue with the line on a cost-benefit basis. I question the expertise of city councillors on the Stage 1 meetings relative to that of the aforementioned.
The Green Line, as proposed, going from urban 16th Avenue N.E. to the Shepard Dump only underscores the dismal lack of understanding of mass transit exhibited by the majority of those on council.
Eric Hindson, Calgary
Not a test but a show of appreciation
Re: Cherry’s rant shows poppy’s meaning is lost”, Opinion, Nov. 16
Srdja Pavlovic has accomplished nothing by going on a rant to criticize another rant, the one by Don Cherry. He is wrong when he says the original purpose of the poppy has changed to become a marker for a militarized society. The poppy is as much a marker as it ever was for seeking peace and for showing respect and appreciation for those who have made huge sacrifices in war. The fact that its frame of reference now encompasses all conflicts Canadians have been involved in since 1918 only reinforces its original purpose.
Wearing a poppy, as Pavlovic suggests, is not a test of one’s loyalty to Canada, but when immigrants wear one, it does show a true appreciation of Canadian history, of what has made Canada a country so many want to become part of. Is this a bad thing?
Peter Mannistu, Calgary
Organ donation saves lives
Re: What You Can Do To Help Save A Life, Nov. 16
I was in the bone marrow registry for several decades, and was never even a potential match although there were many who died because there was no match available to them.
My thoughts on donating are very simple: “Would you give your right arm to save the life of your child? Would you please be willing to tolerate a bit of discomfort to save mine?”
Doug James, Calgary


I think if criticism were seen less as something grown-up and boring, and more as something for all ages, there would be many more kid critics. We can talk to young people and ask questions about the movie they just experienced, and we should regard their opinions as legitimate. We should ask them for reasons and clarifications to make their argument stronger. Eventually, they will see that criticism can be as simple as having a conversation with another human.
I think criticism is important because it can elevate a kid’s perception of moviemaking. For example, when I went to go see Moana, I wasn’t just thinking that it was a fun movie. I was thinking about how long it took to animate all that water. I wondered if the voice actors were all in the same room when they were recording certain scenes. I was thinking about whether the singing voices were the same as the acting voices. If we encourage kids to understand the process of moviemaking, then maybe they will have stronger opinions about the final product.
I think criticism is about expressing your honest opinion: expressing what you think could make a movie better, or saying something unique that you loved about it. It is the story of your experience of watching the movie. I think some young people don’t think their opinions are worth anything. They wonder, “Why would anyone want to know what I thought?” However, if we think about criticism as more of a story of your experience, and less of a composed “perfect judgment,” we’ll be open to hearing stories from everyone.


--- layout: post title: Tablesaw that Won't Cut Fingers date: 2009-07-19 02:40:52.000000000 -07:00 type: post parent_id: '0' published: true password: '' status: publish categories: [] tags: - Graphs - Interesting Things meta: _edit_last: '1' tmac_last_id: '166390240574062592' _jetpack_related_posts_cache: a:1:{s:32:"8f6677c9d6b0f903e98ad32ec61f8deb";a:2:{s:7:"expires";i:1543061065;s:7:"payload";a:3:{i:0;a:1:{s:2:"id";i:702;}i:1;a:1:{s:2:"id";i:754;}i:2;a:1:{s:2:"id";i:437;}}}} _jetpack_dont_email_post_to_subs: '1' author: login: Philihp email<EMAIL_ADDRESS>display_name: Philihp first_name: '' last_name: '' ---
This is one of the greatest inventions I've seen in a long time. Using a charge in the saw blade, if it detects capacitance from human flesh it immediately halts and retracts the spinning blade. When pushing wood through at any reasonable speed, it's supposed to stop before the blade cuts any deeper than 1/16th an inch. Probably does irreparable damage to the saw's blade, but at least you keep your fingers.
Not that I have any use for a table saw, but if I did, I'd buy this one, more reviews here.


--- layout: post title: Git at FSFTN date: 2014-02-17 20:47:00.000000000 +05:30 type: post published: true status: publish categories: - Projects tags: [] meta: blogger_blog: www.technoruler.com blogger_author: VISWAPRASATH KS blogger_cb097c283b9bbfde97b4822e7250157d_permalink: '6313476860797446009' author: login: viswaprasath email<EMAIL_ADDRESS>display_name: Vitchu first_name: '' last_name: '' ---
On my previous visit to FSFTN I was discussing about my final semester project. What I found is that I have not studied well how my project will be very helpful for this community. I really left bad, so I am planning to think differently and start doing things which helps everyone.
I was discussing about the list of projects FSFTN is currently involved. And I found Spell Checker for Tamil to be interesting.
I started a simple discussion that what happen when I change the list of english words to tamil words so the spell checker is done. But I found there are some complexity with the language.
Then I was reading some technical papers about the spell check.
Then On my second day I was taught how to use github. It was very informative session. Previously I have used github but the session was bit interesting to learn from good tutor.
That time learnt a lot from interaction. I have discussed about the Tamil Spell Checker project and got the contact of other two mentors who are using python in day to day life.
+Shrinivasan T and Welkin
For this week I would like to learn more about Python from Internet.
Some links to learn