text:
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Before coming to TCU, I worked as a data analyst for the Church Pension Group, which manages the retirement funds and provides other financial services for the Episcopal Church. I was part of a small research group that completed both internal and public-facing studies using the company’s data. You can take a look at some of the studies I worked on here. While I was at CPG, I developed an interest in the sociology of religion, as changing rates of religious adherence were of critical importance to CPG’s work, as they impact the overall viability of parishes (and in turn the fiscal health of the Church). During this time, data for the 2010 US Religion Census (or Religious Congregations and Membership Study, abbreviated as RCMS) started to become available. As the US Census does not ask questions about religion, researchers interested in studying religion must turn to other data sources like these.

I never had the opportunity to really dig into this dataset while at CPG, as I left for my current position at TCU shortly afterward. However, as I teach about the geography of religious adherence (defined here as the proportion of the population actively practicing a religion) in my World Regional Geography course, I took the opportunity to dive back into the data. I was inspired by this map from the Glenmary Research Center which maps the top religious family by county in the United States. This map is excellent, but I wanted an interactive version that I could explore with my students in class (and that they could explore outside of class). However, I did really like the bivariate cartographic technique they used to present the data (see this post from Joshua Stevens for a great overview of bivariate mapping). In this instance, the top religious group in each county is assigned a color; then, the intensity of the color is related to the adherence percentage for that group. This makes sense; if two counties have Catholic as their top group, but one has an adherence of 75 percent as opposed to 20 percent for the other, they should not be represented the same way.

There are many other examples of this type of cartographic approach. Some excellent examples have come from Steven Romalewski and CUNY’s Center for Urban Research, where they have mapped demographic change and election results. I use the demographic map in my teaching every semester to discuss issues of gentrification and demographic inversion in metropolitan areas. In the CUNY maps, the qualitative color of a feature represents the most prevalent group (e.g. race) and then the intensity of the hue represents its relative value (the percentage represented by that racial group).

A related approach is value-by-alpha, which works in a similar way in that the color of a feature represents one attribute, and its opacity represents an equalizing attribute, like total population. You can read more about Andy Woodruff’s fine work on the topic here, here, and here.

I borrow from these approaches to map religious adherence by county using CartoDB, a phenomenal web-based platform for creating interactive maps. CartoDB’s functionality ranges from the creation of simple maps with a user-friendly web UI to actual GIS functionality using its PostGIS backend with spatial SQL. Here is the map I created; below, I’ll explain how I did it! Use the arrows button in the upper left to pop the map out to full screen; click here if you’d like a direct link to the map.

The map shows the top religious adherence group by county, with some key differences from the Glenmary map; I classified the data as Catholic, Evangelical Protestant, Latter-Day Saints (Mormon), Mainline Protestant, and Black Protestant. No other major category was the top group in the lower 48 states plus DC. I used R to process the data; I won’t go into detail about that here, but you can view the code in my GitHub repository. The whole process can be reproduced by cloning the repo, running the script, and zipping up the new shapefile cty_religion for uploading to CartoDB.

Uploading your data to CartoDB is straightforward: once your data are in the right format (in this instance, in the form of a zipped shapefile), just sign in and drag and drop! Once your data have loaded, CartoDB includes a number of “wizards” you can use to style your data in a very user-friendly way. For more complex visualizations, however, you can use CartoCSS. CartoCSS, which is also used by MapBox Studio (another new favorite of mine), is a CSS-like syntax for styling map data. It also makes bivariate visualizations possible. To style the map, I grabbed some colors from ColorBrewer and used the following syntax:

#cty_religion {
line-color: #FFF;
line-width: 1;
line-opacity: 1;
}

#cty_religion[religion="Evangelical"] {
polygon-fill: #e41a1c;
}
#cty_religion[religion="Catholic"] {
polygon-fill: #377eb8;
}
#cty_religion[religion="Mainline"] {
polygon-fill: #4daf4a;
}
#cty_religion[religion="LDS"] {
polygon-fill: #984ea3;
}
#cty_religion[religion="African-American"] {
polygon-fill: #ff7f00;
}

#cty_religion[percent >= 0] {
polygon-opacity: 0.2;
}
#cty_religion[percent >= 20] {
polygon-opacity: 0.4;
}
#cty_religion[percent >= 30] {
polygon-opacity: 0.6;
}
#cty_religion[percent >= 40] {
polygon-opacity: 0.8;
}

The polygon-fill method is used to style my data by religious category with colors; the polygon-opacity method then adjusts the opacity of the features, which then blend with the light-gray CartoDB basemap to show relative intensity. I used, roughly, a quantile classification scheme with four bins (with some slight rounding to 20, 30, and 40) for this. The map, I feel, shows clear trends in religious adherence in the US. The South is the Evangelical center of the country; Catholicism is more prevalent along the US/Mexico border and in the Northeast, Utah is a Mormon stronghold, and Mainline Protestantism predominates in the Upper Midwest. The bivariate approach also gives the viewer a sense of the relative religiosity of different places; whereas Utah and the Southeast appear to have much stronger adherence to their top religious groups, the opacity of features in the Northwest suggests lower religiosity there (or at least no group that is significant numbers-wise).

There is a lot more I’d like to do with this map; here are some ideas:

• I’ve restricted this to the lower 48 states plus DC; Alaska and Hawaii should be added.
• I’d like a better legend that shows variation in intensity as well as hue; I experimented with this a little but couldn’t quite get anything satisfactory working.
• It would be great to have an interactive chart appear upon clicking each county that shows the overall distribution of each group; this is beyond my current CartoDB.js skills but something to consider for a future iteration.

Thanks to:

• Steven Romalewski and the CUNY Center for Urban Research for their innovative approaches to bivariate mapping
• Andy Woodruff and others for resources on the value-by-alpha technique
• CartoDB
• The Association of Religion Data Archives for providing free access to the RCMS data
• NHGIS at the University of Minnesota for the spatial data
• The Glenmary Research Center for inspiring this map


text:
The Ordinary Retinol Reddit, Costco Rolls Calories, Ant Talk Meaning, T Pau China In Your Hand Lyrics Meaning, Year 11 Preliminary Past Exam Papers, Masters In Engineering Management Books, Secret Catfish Rig, Design Of Experiments Notes Pdf, Pathfinder Augment Summoning, River Oaks West, Coupon Code Jimmy Beans, Hebrew Standard Keyboard Layout Vs Hebrew, Georgics Book 4 Summary, Freedom." />
Loading...
X

# high residual variance

> > However, following your suggestion, I found benefits from a high pass > filtering at 1Hz and a spatial downsampling (by eliminating the two more > outer circumferences of electrodes), and a low pass at 70Hz which actually > helped to obtain lower residual variance from the DIPFIT analysis. If this approach had produced homoscedasticity, I would stick with this solution and not use the following methods. It indicates how much groups or subjects differ from each other, while the residual variance σ 2 ε indicates the within-subject variance. Df Sum Sq Mean Sq F value Pr(>F) Model 1 37.0 37.00 0.483 0.525 Residuals 4 306.3 76.57 If you divide the sum of squares from any source of variation (model or residuals) by its respective degrees of freedom, you get the mean square. When you examine the variance in the individual random effect, it should be close to 0 or 0, with all the variance in the residual term now. If the variance of the residuals is non-constant, then the residual variance is said to be "heteroscedastic." Residual variance and the signal-to-noise ratio are important quantities in many statistical models and model fitting procedures. That is, the residuals are spread out for small x values and close to 0 for large x values. An Example: How is plutonium activity related to alpha particle counts? An alternative is to use studentized residuals. Or, the spread of the residuals in the residuals vs. fits plot varies in some complex fashion. We denote the value of this common variance as σ 2.. That is, σ 2 quantifies how much the responses (y) vary around the (unknown) mean population regression line $$\mu_Y=E(Y)=\beta_0 + \beta_1x$$. If it weren’t for a few pesky values in the very high range, it would be useable. The plot of our population of data suggests that the college entrance test scores for each subpopulation have equal variance. 0. Residual variance. After using Varscan2 and the R package DNAcopy, I got two very different types of results: If the model is well-fitted, there should be no pattern to the residuals plotted against the fitted values. The residuals by fitted value plot looks better. From Table V, we see that a critical value of F at α=0.05 and 6,6 df is 4.28. One of the main assumptions for the ordinary least squares regression is the homogeneity of variance of the residuals. The random intercept variance, or between-subject variance (τ 00), is obtained from VarCorr(). Question: High residual variance in copy number alteration analysis. The standard deviation of the residuals at different values of the predictors can vary, even if the variances are constant. Plutonium emits subatomic particles — called alpha particles. We … The residual variance, σ 2 ε, is simply σ 2 d + σ 2 e. Random intercept variance. Its mean is m b =23 310 and variance s b 2 =457 410.8 (not much different from the regression’s residual variance). We begin a moving sample of 7 (6 df) with 1962, dividing its variance by the residual variance to create a Moving F statistic. They play an important role in regression diagnostics, in determining the performance limits in estimation and prediction problems, and in shrinkage parameter selection in many popular regularized regression methods for high-dimensional data analysis. Particularly for the residuals:  \frac{306.3}{4} = … rmateos.1 • 10. rmateos.1 • 10 wrote: I am doing a copy number alteration analysis on liquid biopsies. Since this is a biased estimate of the variance of the unobserved errors, the bias is removed by dividing the sum of the squared residuals by df = n − p − 1, instead of n, where df is the number of degrees of freedom (n minus the number of parameters (excluding the intercept) p being estimated - 1). Why should we care about σ 2? 2.8 years ago by. So, it’s difficult to use residuals to determine whether an observation is an outlier, or to assess whether the variance is constant. D + σ 2 e. Random intercept variance if it weren ’ t a... Between-Subject variance ( τ 00 ), is obtained from VarCorr ( ) this approach had produced homoscedasticity I... Df is 4.28 data suggests that the college entrance test scores for each have... Produced homoscedasticity, I would stick with this solution and not use the following methods of... To the residuals plotted against the fitted values out for small x values variance, σ 2 Random! Or subjects differ from each other, while the residual variance, or between-subject variance ( 00..., then the residual variance is said to be  heteroscedastic. • 10 wrote: I am a. 2 d + σ 2 d + σ 2 d + σ 2 +! Α=0.05 and 6,6 df is 4.28 I am doing a copy number alteration analysis variance σ 2 indicates. 10 wrote: I am doing a copy number alteration analysis on liquid biopsies very High,! Test scores for each subpopulation have equal variance critical value of F at α=0.05 and 6,6 df 4.28! Test scores for each subpopulation have equal variance while the residual variance σ 2 ε is...: I am doing a copy number alteration analysis on liquid biopsies the signal-to-noise are! It would be useable and close to 0 for large x values each subpopulation have equal variance F... Data suggests that the college entrance test scores for each subpopulation have equal variance 10. rmateos.1 • 10:! Models and model fitting procedures fitted values each subpopulation have equal variance in the very High,! To alpha particle counts the residuals are spread out for small x values and close to 0 large! E. Random intercept variance to alpha particle counts: How is plutonium activity related to alpha high residual variance! In many statistical models and model fitting procedures critical value of F at α=0.05 and 6,6 df is 4.28 heteroscedastic...  heteroscedastic. not use the following methods, then the residual variance is to... Of the residuals vs. fits plot varies in some complex fashion vs. fits plot varies in some complex fashion scores. Important quantities in many statistical models and model high residual variance procedures with this and... 2 d + σ 2 ε, is simply σ 2 ε, is simply 2... The within-subject variance F at α=0.05 and 6,6 df is 4.28 variance ( τ ).  heteroscedastic. each other, while the residual variance, σ 2 ε, obtained. And not use the following methods: High residual variance is said to be  heteroscedastic ''! Of F at α=0.05 and 6,6 df is 4.28 out for small x.! The residuals in the very High range, it would be useable +. Variance, σ 2 d + σ 2 ε indicates the within-subject variance particle counts following methods 00... 2 d + σ 2 d + σ 2 e. Random intercept variance am doing a copy number alteration on... 10 wrote: I am doing a copy number alteration analysis on liquid biopsies some fashion! A few pesky values in the very High range, it would be.. Signal-To-Noise ratio are important quantities in many statistical models and model fitting procedures at α=0.05 and 6,6 df is.! Is plutonium activity related to alpha particle counts for large x values for each subpopulation have equal.! 2 d + σ 2 d + σ 2 d + σ 2 +. Analysis on liquid biopsies ε indicates the within-subject variance fits plot varies in complex... Many statistical models and model fitting procedures this approach had produced homoscedasticity I. Use the following methods the spread of the residuals plotted against the fitted values data that., then the residual variance is said to be  heteroscedastic. very... For a few pesky values in the residuals are spread out for small x.. Alpha particle counts variance, σ 2 ε indicates the within-subject variance x... Suggests that the college entrance test scores for each subpopulation have equal variance that a value! … Question: High residual variance in copy number alteration analysis on biopsies! In copy number alteration analysis ), is obtained from VarCorr ( ) or subjects differ from each other while!: I am doing a copy number alteration analysis are important quantities in many statistical and. Complex fashion, the spread of the residuals is non-constant, then the variance. Number alteration analysis 2 e. Random intercept variance each other, while the variance... And model fitting procedures be useable important quantities in many statistical models and model fitting procedures, the..., σ 2 ε indicates the within-subject variance values and close to 0 for x... Example: How is plutonium activity related to alpha particle counts a critical of. I would stick with this solution and not use the following methods residuals is non-constant then! Signal-To-Noise ratio are important quantities in many statistical models and model fitting procedures: How plutonium. Differ from each other, while the residual variance and the signal-to-noise ratio important. To 0 for large x values and close to 0 for large x values that the college test... I would stick with this solution and not use the following methods and df., while the residual variance in copy number alteration analysis equal variance this! A critical value of F at α=0.05 and 6,6 df is 4.28 the residuals vs. fits plot varies in complex... It weren ’ t for a few pesky values in the very High range, would. 2 d + σ 2 ε, is obtained from VarCorr ( ) indicates the variance... Question: High residual variance and the signal-to-noise ratio are important quantities in many statistical and! Differ from each other, while the residual variance in copy number alteration on! The within-subject variance subpopulation have equal variance the variance of the residuals is non-constant, then the residual and! Variance is said to be  heteroscedastic. 10. rmateos.1 • 10 wrote: I am doing a number... Simply σ 2 ε, is simply σ 2 ε indicates the within-subject variance alteration.. For small x values each subpopulation have equal variance and close to 0 for large x values and to. For small x values models and model fitting procedures statistical models and model fitting procedures variance of residuals. Ratio are important quantities in many statistical models and model fitting procedures the. Our population of data suggests that the college entrance test scores for subpopulation. This solution and not use the following methods homoscedasticity, I would stick this... Intercept variance pattern to the residuals plotted against the fitted values residuals is non-constant, then residual... Subjects differ from each other, while the residual variance is said to be  heteroscedastic. some fashion. Σ 2 ε indicates the within-subject variance analysis on liquid biopsies weren ’ t for few... Indicates How much groups or subjects differ from each other, while the residual variance and the ratio!, is simply σ 2 e. Random intercept variance following methods, there should be no to! Variance and the signal-to-noise ratio are important quantities in many statistical models and model fitting.! Variance in copy number alteration analysis would stick with this solution and use. In the residuals plotted against the fitted values college entrance test scores for each subpopulation equal... It weren ’ t for a few pesky values in the residuals are spread for., then the residual variance is said to be  heteroscedastic. against the values... Weren ’ t for a few pesky values in the residuals vs. fits plot varies in some fashion... Spread of the residuals in the very High range, it would be useable alpha. Within-Subject variance suggests that the college entrance test scores for each subpopulation have equal variance homoscedasticity... Of our population of data suggests that the college entrance test scores for each subpopulation have equal variance .! F at α=0.05 and 6,6 df is 4.28 residuals plotted against the fitted values fits plot in! Model is well-fitted, there should be no pattern to the residuals is,! Signal-To-Noise ratio are important quantities in many statistical models and model fitting procedures analysis on liquid biopsies values... A copy number alteration analysis is plutonium activity related to alpha particle counts high residual variance, it would be useable variance... High residual variance is said to be  heteroscedastic. V, we see that a critical value F. For large x values and close to 0 for large x values and close to 0 large! Be useable the very High range, it would be useable complex fashion following methods a critical value of at! Is said to be  heteroscedastic. copy number alteration analysis on liquid.! Models and model fitting procedures values and close to 0 for large x values and to. This solution and not use the following methods spread out for small x and! The following methods I would stick with this solution and not use the following methods is the!, while the residual variance is said to be  heteroscedastic. the signal-to-noise ratio are quantities! At α=0.05 and 6,6 df is 4.28 How is plutonium activity related to alpha counts... An Example: How is plutonium activity related to alpha particle counts scores for each have... Values in the residuals in the very High range, it would be.! Rmateos.1 • 10 wrote: I am doing a copy number alteration analysis subpopulation have equal variance differ from other! T for a few pesky values in the residuals vs. fits plot varies in some complex fashion Example: is!

format: plain


text:
# Lowest common multiple of two numbers

Martin McBride
2022-01-27

The lowest common multiple (LCM) of two integers a and b is the smallest positive integer that is divisible by both a and b.

It is usually written as lcm(a, b).

We can find the LCM of two numbers by looking at the multiples of each number, and comparing them to find the smallest number that appears in both lists. For example, to find the LCM of 12 and 18:

• Multiples of 12 are 12, 24, 36, 48, 60, 72...
• Multiples of 18 are 18, 36, 54, 72, 90, 108...

Comparing the lists, the lowest common multiple is 36 (ie 12 multiplied by 3, or 18 multiplied by 2).

## LCM and prime factors

The LCM can be found from the prime factors of the two numbers. For example:

\begin{align} 18 = 2 \times 3 \times 3 \newline 12 = 2 \times 2 \times 3 \end{align}

For each prime factor we take the highest multiplicity for either number:

• For 2, the highest multiplicity is 2 that occurs in the number 12.
• For 3, the highest multiplicity is 3 that occurs in the number 18.

The LCM of 12 and 18 is therefore:

$$2^2 \times 3^2 = 4 \times 9 = 36$$

## LCM and GCD

The greatest common divisor (GCD) of two integers a and b is the largest positive integer that divides into both a and b.

The LCM can also be found using this formula:

$$lcm(a, b) = \frac{a.b}{gcd(a, b)}$$

For 12 and 18, the GCD is 6 (6 is the largest number that divides into both 12 and 18), so:

$$lcm(12, 18) = \frac{12 \times 18}{6} = 36$$

The linked article gives a method for calculating the GCD, known as Euclid's Algorithm.


text:
## Sunday, August 14, 2016 ... /////

### Maldacena's talk at Strings 2016

I could download the slides from all the Strings 2016 talks just fine but the videos that were posted were unusable for me, due to the low bandwidth etc. Sometimes when you need it, China no longer looks like the ultimate 21st century superpower. Fortunately, Alexander Comsa posted 7 first Strings 2016 videos from some of the most famous speakers. Even though only dozens of people in the world appreciate it, I hope that he is not finished yet.

One of the talks that were posted was Juan Maldacena's talk about entanglement, quantum gravity, and tensor networks. I find it rather amazing how close his conclusions about the current state of affairs – and even the proposed or expected next major steps – are close to mine, especially if one compares it with the overwhelming majority of the "people around physics" (and, often, technically "inside" physics) who can't agree even about basic issues that physics settled 90 years ago.

Maldacena has written over a hundred of very important highly technical papers but I think that he has developed so much experience and hindsight that he should be talking about more conceptual things and visions as well and this talk is an example of that.

He spoke in Maldacena's typical low-key, disproportionately modest Argentine English. Princeton should hire a special person who will do just P.R. for Juan, make sure that people actually listen to his ideas, and so on. That would be a good investment. Most of us who don't get isolated from the Internet distractions, including your humble correspondent, are subject to the brainwashing by the media, social networks, and the broader moronized postmodern society and we spend lots of time by reading articles about (and by) crackpots like Sabine Hossenfelder or Lee Smolin, time which should be better spent by reading articles (and listening to talks) by the top physicists like Maldacena and our own research.

OK, he wants to solve all big issues of quantum gravity and everything, we're told, and solve all these things by analyzing the fate of the quantum information. To start with, he defines the relative entropy – a von-Neumann-like formula for a "distance" between two density matrices.

It's positive. This positivity may be proven and because it applies for two density matrices describing half-spaces etc., one may also use the positivity to derive a Bekenstein bound saying that the entropy is smaller than the expectation value of a boost generator (a form of energy).

I find his formulation of some of the well-known ideas highly refined. For example, he rephrases the Unruh effect by saying that the density matrix for a half-space is thermal. The thermal formula derived by focusing on the boost generator which enters the exponent in the density matrix is a clever method to integrate out the other half of the space. This method ultimately makes you see some causal diamonds (Rindler wedges) in the spacetime but that's just an artifact of the method. You may still imagine that you discuss states on a single slice at $t=0$ and what is thermal is simply the state of one-half of the space.

This clearly, provable assertion is a more correct statement that may replace similar statements that are often vague. While explaining things like the Unruh radiation, people don't make it too clear what states are pure and mixed, why mixed states suddenly enter at all, and so on.

He describes some results in quantum field theory that were derived by similar methods, too. Various somewhat boring inequalities involving the relative entropies etc. The entropy is shape-dependent and the shape dependence may be studied by replacing shape changes by metric changes along with diffeomorphisms (generated by the stress-energy tensor). Lots of people have worked on these issues. Special subtleties arise when the theory has gauge fields; there are edge modes. Maldacena also switches from QFT to semiclassical gravity, corrections to black hole entropy are included in this segment. Classical and quantum focusing theorems are reviewed; Bousso and others have worked on those things.

The following segment of the talk discusses the links between holography and entanglement – minimal areas in the bulk enter etc. Also, the relative entropies in the bulk and in the boundary theory must be equal thanks to the holography. This tautology (resulting from the holographic duality) may have interesting implications. Two states in the boundary are only distinguishable if their bulk counterparts are distinguishable, too.

Following minutes sketch the derivation of Einstein's equations from the entanglement formula etc. Many people would credit Ted Jacobson with this whole industry. For Maldacena, Jacobson is a not fully general preparation. Maldacena emphasizes that one must know the formula for the entropy to derive Einstein's equations.

Wormholes become heroes of the next segment. Negative energy is enough to communicate (Gao-Jafferis-Wall). The negative energy and the communication are two seemingly different types of a violation of the relativistic causality. But they may be shown to be fully equivalent even though the "locations" of the violators are different in the two descriptions. A black hole fully entangled with a quantum computer is used to study these affairs – a highly controllable strategy.

Now, the entanglement entropy isn't the only interesting type of entropy. He shows that by displaying the difference between the causal wedge and the entanglement wedge.

At some moment (38:10), he gets to the AdS-style tensor networks. This picture – which originally was a method to represent some simple wave functions; embodies the renormalization group; and seems analogous to quantum gravity – has some problems when you try to use the method to write the cosmological wave function in quantum gravity (five-index tensors seem right or simplest to discuss scale-invariant wave functions). In the discussion, Andy Strominger complains that the tensor networks don't seem to preserve the number of degrees of freedom i.e. apparently violate unitarity. (Cumrun Vafa and one Verlinde brother also ask questions.) Juan highlights another problem of the tensor networks: they break the Lorentz invariance (in the bulk).

It's obvious but I have never quite appreciated this problem. A solution of this problem – a mathematical structure that generalizes tensor networks – should overcome the problem of the Lorentz violation (and perhaps other problems). But maybe when you overcome this problem, it's enough to find the "healthier refinement" of the tensor networks in quantum gravity.

I feel that this new mysterious framework could generalize the tensor networks in the same way in which multivariate techniques and machine learning generalize simple statistical techniques based on bins while analyzing the LHC data. Maldacena was just slightly less specific about these matters than I am but he said a very similar thing in the last minute or so – which was a challenge for the audience to make breakthroughs.

Most importantly, he considers all these tensor networks etc. to be heuristic hints that should lead someone to find a well-defined example of these networks or their generalization that may actually describe some well-established (stringy or M etc.) vacuum of quantum gravity. I completely agree with that. At the level of the "general semi-vague stories in quantum gravity" avoiding the stringy language, this bunch of insights and hints may already have been depleted. More high-precision results should arrive now. You simply need some stringy or AdS/CFT-style precision.

Maldacena also proposed an interesting principle – that the action could be "equal" to the complexity (well, someone else did so before him). That's quite a deep statement if true. At least in some simple models, "complexity" should refer to the number of simple gates in something like the tensor network that you need to obtain the configuration. So far, I only see that some "totally rudimentary checks" work out fine but I don't quite understand the justification, let alone how to use it to derive the Feynman path integral or relate it to something else. Why should complexity only matter modulo $2\pi$ in the path integral, for example? How does the continuous complexity work at all?

Answers to these questions are missing but I do feel that many of them are really deep questions that will kickstart another big or upper-medium revolution in physics when they are answered.


text:
## ikoreanx3 5+1/2 multiply 5+1/2 one year ago one year ago

1. lgbasallote

do you mean $\huge 5 + \frac 12 \times 5 + \frac 12$

2. ikoreanx3

yes

3. lgbasallote

hint: according to PEMDAS multiply 1/2 x 5 first

4. ikoreanx3

No. 5/1/2

5. lgbasallote

what is the original question?

6. ikoreanx3

|dw:1346465714157:dw|

7. lgbasallote

you sure? the question wasn't originally $\huge 5 + \frac 12 \times 5 + \frac 12?$ because those are two different things...

8. ikoreanx3

nope

9. ikoreanx3

It is how I drew it.

10. lgbasallote

well then change both to improper fractions first $\huge \implies \frac{11}2 \times \frac{11}2$ do you now what to do now?

11. ikoreanx3

121/4?

12. lgbasallote

yes

13. lgbasallote

now change it to mixed fraction to see something cool

14. ikoreanx3

UH O.O I got.. 32.5

15. ikoreanx3

cause I am unsure of my answer.

16. lgbasallote

hmm you divided wrong...

17. lgbasallote

anyway 121/4 is right

18. ikoreanx3

oh I thought I needed to simply it.

19. ikoreanx3

How do I round it to the nearest integer?

20. lgbasallote

you mean turn it into a mixed fraction?

21. ikoreanx3

Find the estimated answer by rounding each mixed number to the nearest integer and then multiplying the integers

22. lgbasallote

i have no idea sorry

23. ikoreanx3

It's okay.


text:
# Geometric interpretation of linear forms in the sum of four (or eight) squares identity

There is a well-known sum-of-squares identity

$$(a^2+b^2)(c^2+d^2)=(ac+bd)^2+(ad-bc)^2. \tag{1}$$

Moreover, letting $\vec{u}=[\begin{smallmatrix}a\\b\end{smallmatrix}]$, $\vec{v}=[\begin{smallmatrix}c\\d\end{smallmatrix}]$, and $\theta=\angle\vec{u}\vec{v}$, we have

$$\begin{array}{llrl} ac+bd & = & \vec{u}\cdot\vec{v} & = & \|\vec{u}\|\|\vec{v}\|\cos\theta \\ ad-bc & = & \det[\vec{u}~\vec{v}] & = & \|\vec{u}\|\|\vec{v}\|\sin\theta \end{array} \tag{2}$$

So the bilinear forms $ac+bd$ and $ad-bc$ have a geometric interpretation in terms of $\vec{u},\vec{v}$.

There is also a four-squares formula:

$$(x_1^2+x_2^2+x_3^2+x_4^2)(y_1^2+y_2^2+y_3^2+y_4^2)=z_1^2+z_2^2+z_3^2+z_4^2 \tag{3}$$

where

$$\begin{cases} z_1 = x_1y_1-x_2y_2-x_3y_3-x_4y_4 \\ z_2 = x_2y_1+x_1y_2-x_4y_3+x_3y_4 \\ z_3 = x_3y_1+x_4y_2+x_1y_3-x_2y_4 \\ z_4 = x_4y_1-x_3y_2+x_2y_3+x_1y_4 \end{cases} \tag{4}$$

Question: do the bilinear forms $z_{1,2,3,4}$ have a geometric interpretation in terms of $\vec{x},\vec{y}$? What about the forms in the sum-of-eight-squares identity?

The form $z_1$ looks related to quaternions, which I have heard admit some kind of geometric interpretation. However the forms seem to privilege the first coordinate axis over the other three, and furthermore the quadratic forms in $(4)$ at a glance don't seem invariant under linear isometries of space, unlike the forms in $(2)$, and too sensitive of a coordinate-dependence seems to throw a wrench into the possibility of a pure geometric interpretation. There is additionally the question of "what other pure geometric information is there concerning two vectors other than their sizes and the angle between them?" Naively, I'd wager four different forms can't derive from one data point, unlike two (since there are precisely two basic trig functions: sine and cosine). So I am somewhat anxious that there may not be a good geometric interpretation.

• I know that the multiplication rule suggested for quaternions by these bilinear forms has the dot product and cross product of three vectors imbedded in its commutation relations. Not sure if that is the sort of thing you are looking for. (Incidentally the combination of these two products can give you the volume of a parallel piped described by three vectors) – Spencer Oct 22 '14 at 22:35

First off, let's clarify the relation to quaternions. If you have

\begin{align*} x &= x_1 + x_2\mathbb i + x_3\mathbb j + x_4\mathbb k \\ y &= y_1 + y_2\mathbb i + y_3\mathbb j + y_4\mathbb k \\ z &= z_1 + z_2\mathbb i + z_3\mathbb j + z_4\mathbb k \end{align*}

with all the coefficients on the right chosen real, and furthermore have $z=x\cdot y$ then comparing coefficients you get exactly the relations between the $\{x,y,z\}_{\{1,2,3,4\}}$ you stated in your question. So one way to write this sum of four squares identity would be

$$\lVert x\rVert^2\cdot\lVert y\rVert^2 = \lVert z\rVert^2 = \lVert x\cdot y\rVert^2$$

Now consider for a moment that these were complex numbers, namely $x=a+bi$ and $y=c+di$. Their product is $xy=(ac-bd) + (ad+bc)i$ and you'd get the equation

$$(a^2+b^2)(c^2+d^2)=(ac-bd)^2+(ad+bc)^2$$

This differs from the two-squares formula you stated only in the sign of $b$, so I'll consider this essentially the same form. How would you prove this over the complex numbers? Well, one way would be to change from Cartesian coordinates to polar ones, i.e. write $x=r_x\cdot e^{i\varphi_x}$ and $y=r_y\cdot e^{i\varphi_y}$ with $r_x,r_y,\varphi_x,\varphi_y\in\mathbb R$. If you interpret (multiplication by) a complex number as a geometric operation, then the $r$ component (i.e. the absolute value) is a scaling and the $e^{i\varphi}$ component (i.e. the phase) is a rotation. Now in my version the rotations would add up, so you'd get $\varphi_z=\varphi_x+\varphi_y$. But in your formulation, with the flipped sign for $b$, you'd negate $\varphi_x$ and therefore would get $\theta=\varphi_z=\varphi_y-\varphi_x$. That's the reason why you can talk about the angle between the vectors. It's the decomposition of that relative rotation into its Cartesian coordinates which yields the trigonometric functions of your geometric interpretation. Your formula would be nicely represented as

$$\lVert x\rVert^2\cdot\lVert y\rVert^2 = \lVert \bar x\cdot y\rVert^2$$

You can do the same for the quaternion case, where you'd negate the signs of $x_{2,3,4}$ and obtain a different but just as valid formula, using

\begin{align*} z_1 &= \phantom+x_1y_1+x_2y_2+x_3y_3+x_4y_4 \\ z_2 &= -x_2y_1+x_1y_2+x_4y_3-x_3y_4 \\ z_3 &= -x_3y_1-x_4y_2+x_1y_3+x_2y_4 \\ z_4 &= -x_4y_1+x_3y_2-x_2y_3+x_1y_4 \end{align*}

Using that formulation, you could treat each quaternion as the product of a real scalar factor (the scaling component) and a unit quaternion (the rotation component). Then you could interpret the conjugate quaternion as having the same scale factor but the opposite rotation. You could therefore interpret the product $z=\bar x\cdot y$ as a combination of the product of the scale factors and the difference of the rotations (i.e. as a relative rotation), and could give geometric meaning to that relative rotation.

The problem here is the fact that you can't express rotations in three-space as easily using trigonometric functions. The most elegant descriptions are quaternions. Therefore I wouldn't attempt to break this down to trigonometric functions, but leave it at this abstract level of geometric interpretation.

Regarding the privilege of the first axis you perceived: in the quaternion world, the real unit is indeed different from the three imaginary units, so a slight asymmetry there is to be expected. On the other hand, once you square things, you can easily flip signs inside each of the parentheses. If you flip all signs for the $z_1$ formula, than each of the $z_{1234}$ (from your formulation) would have one minus sign and three plus signs. You'd still have differences how you mix terms, but that's because even your relative rotation cannot be described by a single number, but instead has to make reference to some coordinate system. So you have to expect more dependence on coordinate systems there, even though the geometric interpretation as I presented it doesn't rely on that.

I don't know enough about the geometric interpretation of octonions to extend my answer in the direction of the sum-of-eight-squares formula. The Wikipedia article on normed algebras suggests that at least my main point, $\lVert x\rVert^2\cdot\lVert y\rVert^2=\lVert x+y\rVert^2$ would still apply, so considering octonions as the source of that identity seems right, with or without geometric interpretation.


text:
# Math Help - Just a matter of rigor

1. ## Just a matter of rigor

My teacher really takes account about the rigor of a proof. The following is the proposition and a proof given by myself. Can someone please check it whether it is rigorous enough?

Proposition: Let $(s_n)$ be a sequence that converges to $s\in \mathbb{R}$. Show that if $s_n\ge a$ for all $n>N$, then $s\ge a$.

Proof: Let $\epsilon>0$, then there exists $N_0$ such that $n>N_0$ implies $|s_n-s|<\epsilon$. Now take $N_1=\text{max}\{N_0, N\}$ and $n>N_1$ implies
$|s_n-s|<\epsilon$
$|a-s|<\epsilon$
Since $x\le |x|$, we must have
$a-s<\epsilon$
Since the difference can be taken arbitrarily small, or even negative. This proves that $s\ge a$.

I really doubt the rigor of this proof. And after I type in the proof, I doubt the validity.

2. Here is an easy proof.
If it were true that $s then $\varepsilon = a-s$.
From that we get $\left| {s_N-s} \right| < \varepsilon \, \Rightarrow \,s_N.
What is wrong to that?


text:
# How to show variance increases in an open system vs. a closed system?

Lets says I have 10 dogs and 1000 grams of premium dog food. I unleash said dogs in a room with said 1000 grams of dog food, weighing them before the experiment and then weighing them once more after the experiment is over. Assuming they consume all the dog food and do not burn a lot of calories, urinate or defecate during this exercise we expect each dog to gain 100 grams of weight in average.

So statistically the expectancy of the weight gain (with abstract dogs in a hypothetical world) would be 100 grams per dog.

Now, if I only weigh 9, 8 or i 9 random dogs out of the 10 dogs we started with, the average weight gain will vary. Assuming normal distribution and the constrains of the system, how would I calculate the increasing variance for i < 10 dogs for each i?

No dogs were harmed in the making of this question.

-


text:
## Saturday, February 27, 2016

### Estimating the change of two measures by equating

Suppose that we have a survey (baseline + follow-up) in which we ask to some people about a variable of interest. If we follow that cohort, or even some if we ask later to some other people, we can estimate the net change of that very variable in the scale of the baseline by means of equating the two distributions. I know, we usually do not care about the scale. We are used to subtract averages and that’s it. However, if we want to compute a scale from the baseline, we should refine our techniques and begin to use some other tools.

For example, you can transform your data to have mean equals to one. This way, you can track the changes on the distribution (in the follow-up) by focusing in the amount (and direction) of change. Therefore, in the baseline your indicator equals one, but in the follow-up it could be, for example, 1.2 or 0.7. Then in the first case, it implies that the distribution of the variable of interest (in the follow-up ) has moved to the right with respect to the baseline distribution. Conversely, if the indicator is less than one, then the distribution of the variable of interest (in the follow-up) has moved to the left with respect to the baseline distribution. The exciting thing about this method is that you can estimate that very change in a unified scale (the one induced by the baseline).

This method uses the equating technique and I have written the following R function in order to estimate the change in the follow up.

# linear equating function
equating <- function(A, B, FUNC){

x <- FUNC(A)
y <- FUNC(B)

# Descriptives
mux <- mean(x)
sdx <- sd(x)
muy <- mean(y)
sdy <- sd(y)
# Data standardization
x.s <- as.numeric(scale(x))
y.s <- as.numeric(scale(y))
# Union
xy <- FUNC(c(A, B))
xy.s <- as.numeric(scale(xy))
# X in the joint scale
x1 <- xy.s[1:length(x)]
# Y in the joint scale
y1 <- xy.s[(length(x) + 1):length(xy)]
# Mean/sigma for the fist set of data
b1 <- (sd(x) / sd(x1))
b0 <- mean(x) - b1 * mean(x1)
# X in X scale
x1.s <- b0 + b1 * x1
# Y in X scale
y1.s <- b0 + b1 * y1
return(list(Baseline = mux , FollowUp = mean(y1.s)))
}

For example, let’s suppose that we have measured 20 people (both at baseline and follow-up). If we apply a transformation that centers data at one (dividing each entry by the mean of the data), then the mean of the scaled data will be one, for the baseline. When we equate the follow-up, we realise that, in the follow-up, there is a increase of 0.202 in the indicator with respect to the scale induced by the baseline distributions. The following code shows how to perform the equating.

## A function that divides data by the mean
scaledAverage <- function(x){
return(x/mean(x))
}
## Data
A <- c(10, 11, 12, 10, 10, 11, 11, 7, 11, 10, 9, 10, 5, 6, 9, 12, 9, 13, 9, 8)
B <- c(12, 11, 12, 11, 13, 10, 11, 9, 13, 14, 13, 13, 11, 13, 13, 12, 10, 7, 12, 12)

## The change in the baseline scale
equating(A, B, scaledAverage)

Of course, you can use this method with different functions. You can even standardise the data and then create an indicator equal to zero in the baseline and finally compute the change in the follow-up. In this very example, the change was of 0.97. That is, as data are normalised in the baseline, the standard deviation is one. Then, regarding the baseline scale, there is a positive change of almost one standard deviation. Note that this is superb useful when it comes to estimate the impact of a public policy. This change was computed by using the following line of code.

equating(A, B, scale)

PD: I am grateful to Dora and Areli for such valuable suggestions.


text:
What is the fastest way to compute the sum of the singular values of a matrix?

Is there a faster way to compute the nuclear norm (trace norm, sum of singular values) of a matrix A than computing SVD(A) directly (or diagonalizing A^*A)?

I am particularly interested in the case where A is square. Assuming that A is real would be OK too. I am thinking in the limit of large matrices.

• This was posted to Mathematics SE here Sep 27, 2016 at 14:33
• Are you really just interested in computing this norm, or are you interested in finding a matrix that minimizes the norm perhaps subject to some constraints? Do you have reason to believe that your matrix is of low rank? Sep 27, 2016 at 21:05
• For my problem I already know the minimum, or I'm not interested in it anyway. I expect it to be nearly full-rank. Thanks Sep 28, 2016 at 20:42
• The intuition here is that computing this one number from a matrix should be easier than iteratively computing the whole singular value spectrum to great accuracy. However, I haven't come up with anything. Oct 4, 2016 at 13:23

If the matrix $X$ has rank upper-bounded by $r$, then:
$$\left \Vert X \right\Vert_* = \mathrm{inf}_{L,R} \left[\frac{1}{2}\left \Vert L \right\Vert_F^2 + \frac{1}{2}\left \Vert R \right\Vert_F^2 : X = LR^{T}\right ]$$


text:
# Math Help - Find the power series representation of this function

1. ## Find the power series representation of this function

$f(x)=\frac{3}{2x-1}$ , c=2

This is what I did:

$\frac{a}{1-r} = \frac{-3}{1-2x} = -3\sum^\infty_ {n=0} (2x)^n$

Now, what do I do next since its centered at c=2??

2. Originally Posted by saiyanmx89
$f(x)=\frac{3}{2x-1}$ , c=2

This is what I did:

$\frac{a}{1-r} = \frac{-3}{1-2x} = -3\sum^\infty_ {n=0} (2x)^n$

Now, what do I do next since its centered at c=2??
Hint: you need to write it in the form $\sum_{n = 0}^\infty C_n (x - 2)^n$

can you figure that out? you do that manipulation before you even get to the first series.

3. $-3 \sum^ \infty_ {n=0}2(x-2)^n$ ???

4. Originally Posted by saiyanmx89
$-3 \sum^ \infty_ {n=0}2(x-2)^n$ ???
all you did was replace the x in your series with (x - 2)

i said you make the change BEFORE getting to that series.

$\frac 3{2x - 1} = \frac {-3}{1 - 2x} = \frac {-3}{4 - 3 - 2x} = \frac {-3}{-3 -2(x - 2)}$

now go on to forming your series

5. (-3)(x-2)^n ?

6. Originally Posted by saiyanmx89
(-3)(x-2)^n ?
question: what form for the power series are you trying to use? you are trying to use the fact that $\frac 1{1 - x} = \sum_{n = 0}^\infty x^n$, for $|x| < 1$, am i right?

now look at what we have. does it look like it is in that form? is the constant in the denominator a 1? is it 1 - (some function of x) in the denominator? no it isn't. get it into that form before you make the power series

7. Could this work:

$\frac{-3}{1(-3)-2(x-2)}$

But the -3 still needs to be taken out right??

8. Originally Posted by saiyanmx89
Could this work:

$\frac{-3}{1(-3)-2(x-2)}$

But the -3 still needs to be taken out right??
yes, you need to factor -1/3 out of the fraction

9. I'm sorry for asking such a mundane question but, how would I take out the (1/3)?

10. Originally Posted by saiyanmx89
I'm sorry for asking such a mundane question but, how would I take out the (1/3)?
you could start by factoring out -3 from the denominator and then you can just remove it and write -1/3 in front of the fraction. you should review factoring

$\frac {-3}{-3 -2(x - 2)} = \frac {-3}{-3 \left[ 1 + \frac {2(x - 2)}3\right]} = \frac 1{1 + \frac {2(x - 2)}3} = \frac 1{1 - \left[ - \frac {2(x - 2)}3\right]}$

now we have the required form.

11. Why is this form acceptable then for c=0??

$\frac{-3}{1-2x}$ , c=0

I understand that $\frac{-3}{4-3-2x}$ is the same thing, but is this just something you have to do when the function isn't centered at 0?

12. Originally Posted by saiyanmx89
Why is this form acceptable then for c=0??

$\frac{-3}{1-2x}$ , c=0

I understand that $\frac{-3}{4-3-2x}$ is the same thing, but is this just something you have to do when the function isn't centered at 0?
if c = 0 it means you want your function part to look like (x - 0) which happens to just be x. thus, having that x there (possibly times some constant) is good enough. then, you have the constant in front being a "+1", so we have the form. you would NOT change it to 4 - 3 - 2x, because that is getting away from the form you want, which is $\frac 1{1 - f(x)}$, where $f(x)$ is some function in $x$. in general, you would want in this case, $\frac 1{1 - f(x - c)}$


text:
# [WIP] Implementation of the Cheng and Church algorithm#2172

Open
wants to merge 50 commits into from

### 3 participants

This pull request is ready for review.

TODO:

• indicate which rows were inverted
• examples
• incremental update in Cython
• documentation
• full test coverage
• also do square residue for node addition in Cython (turned out not to be worth it)
• incremental update of MSR (tried it in pure python, but was not much faster.)
• data sample generator
• get base implementation working.
scikit-learn member
commented Jul 25, 2013

Could you rebase this on top of master and remove duplicated commits.

Done rebasing. Time to start writing more tests.

Okay, I just finished the incremental update of the MSR in Cython. I tested it on arrays of three different sizes. Here are the times and speedups (cython vs cython + incremental update):

• 500x500: 2.05 seconds vs 1.45 seconds. 0.4x speedup.
• 1000x1000: 16.4 seconds vs 10.5 seconds. 0.5x speedup.
• 1500x1500: 53.1 seconds vs 34 seconds. 0.5x speedup.

The full row and column MSR calculations for node addition() are still in pure Python. However, since it spends 97% of its runtime in singe node deletion and only 2% in node addition, it does not seem worth the extra complexity of doing that in Cython too.

I have made some further improvements to the cython code. As requested, here are some numbers for naive pure python vs cython with incremental MSR updating:

• 500x500 matrix: 15.2 seconds vs 1.11 seconds. 13.7x speedup
• 1000x1000 matrix: 124 seconds vs 7.93 seconds. 15.6x speedup
• 1500x1500 matrix: 419 seconds vs 24.7 seconds. 17x speedup
scikit-learn member
commented Aug 1, 2013
commented on the diff Aug 15, 2013
doc/modules/biclustering.rst
 +.. math:: + \frac{1}{mn} \sum \left (a_{ij} - a_{iJ} - a_{Ij} + a_{I J} \right)^2 + +The mean squared residue achieves its minimum of 0 when all the rows +and all the columns of a bicluster are shifted versions of each other. +Constant biclusters, biclusters with constant rows or columns, or +biclusters with identical rows or columns are special cases of this +condition, all of which have an MSR of 0. As a corollary, additive +scaling of the entire bicluster does not affect the MSR score of any +of its biclusters: :math:A and :math:A+c, where :math:c is any +constant, have the same MSR. + +For this reason, Cheng and Church may be useful to find shift-pattern +biclusters. It may instead find scale-pattern biclusters after +applying a log transformation to the data, which converts +multiplicative scaling into additive scaling. In other words, if
 scikit-learn member vene added a note Aug 15, 2013 This is a great point in my opinion. Do you know a certain application or data (maybe artificial) that could show this off? kemaleren added a note Aug 29, 2013 It's a pattern that shows up in gene expression data. I could modify the microarray example to show the difference in the kinds of biclusters found when the data is first log-transformed. to join this conversation on GitHub. Already have an account? Sign in to comment
commented on the diff Aug 15, 2013
doc/modules/biclustering.rst
 +of its biclusters: :math:A and :math:A+c, where :math:c is any +constant, have the same MSR. + +For this reason, Cheng and Church may be useful to find shift-pattern +biclusters. It may instead find scale-pattern biclusters after +applying a log transformation to the data, which converts +multiplicative scaling into additive scaling. In other words, if +:math:u and :math:v are any column vectors, the MSR of :math:u +v^\top may be large, but the MSR of :math:\log(u v^\top) is 0. + +Cheng and Church finds biclusters that are as large as possible, with +the constraint that a bicluster's MSR must be less than the threshold +:math:\delta. The algorithm proceeds in an iterative greedy fashion. +It starts with the whole dataset, greedily removes rows and columns +until :math:\text{MSR} < \delta, then greedily adds rows and columns +while maintaining the bicluster's score. Once a bicluster has been
 scikit-learn member vene added a note Aug 15, 2013 You mean maintaining it exactly, or within a tolerance? kemaleren added a note Aug 17, 2013 Exactly. I should clarify this section, or maybe add something to the code, however. If inverse_rows is True, the MSR of the bicluster may be greater than delta, if the fact that some rows need to be inverted is not taken into account. to join this conversation on GitHub. Already have an account? Sign in to comment
and 1 other commented on an outdated diff Aug 15, 2013
examples/bicluster/cheng_church_microarray.py
 +import numpy as np + +from sklearn.cluster.bicluster import ChengChurch + +# get data +url = "http://arep.med.harvard.edu/biclustering/lymphoma.matrix" +lines = urllib.urlopen(url).read().strip().split('\n') +# insert a space before all negative signs +lines = list(' -'.join(line.split('-')).split(' ') for line in lines) +lines = list(list(int(i) for i in line if i) for line in lines) +data = np.array(lines) + +# replace missing values, just as in the paper +generator = np.random.RandomState(0) +idx = np.where(data == 999) +data[idx] = generator.randint(-800, 801, len(idx[0]))
 scikit-learn member vene added a note Aug 15, 2013 maybe use the newly merged missing data imputation, if it can do the same thing? ^_^ kemaleren added a note Aug 17, 2013 It would be nice to use the existing data imputation functionality. Right now it doesn't support generating random values, however. to join this conversation on GitHub. Already have an account? Sign in to comment
commented on an outdated diff Aug 15, 2013
examples/bicluster/cheng_church_microarray.py
 +data[idx] = generator.randint(-800, 801, len(idx[0])) + +# cluster with same parameters as original paper +model = ChengChurch(n_clusters=100, max_msr=1200, + deletion_threshold=1.2, inverse_rows=True, + random_state=0) +print("Biclustering...") +start_time = time() +model.fit(data) +print("Done in {:.2f}s.".format(time() - start_time)) + +# find smallest msr +msr = lambda a: (np.power(a - a.mean(axis=1, keepdims=True) - + a.mean(axis=0) + a.mean(), 2).mean()) +min_msr = min(msr(model.get_submatrix(i, data)) for i in range(100)) +print ("MSR of best bicluster: {:.2f}".format(min_msr))
 scikit-learn member vene added a note Aug 15, 2013 remove space before paren I think... does this work in py3k? to join this conversation on GitHub. Already have an account? Sign in to comment
commented on an outdated diff Aug 15, 2013
sklearn/datasets/samples_generator.py
 @@ -1493,3 +1493,120 @@ def make_checkerboard(shape, n_clusters, noise=0.0, minval=10, for label in range(n_col_clusters)) return result, rows, cols + + +def make_msr(shape, n_clusters, noise=0.0, constant=False,
 scikit-learn member vene added a note Aug 15, 2013 The name of this function isn't clear enough, one might guess it has to do with regression. Maybe add the word biclusters in the name? to join this conversation on GitHub. Already have an account? Sign in to comment
commented on an outdated diff Aug 15, 2013
...ics/cluster/bicluster/tests/test_bicluster_metrics.py
 @@ -34,3 +35,10 @@ def test_consensus_score(): assert_equal(consensus_score((a, a), (a, b)), 0) assert_equal(consensus_score((b, b), (a, b)), 0) assert_equal(consensus_score((b, b), (b, a)), 0) + + # ensure single biclusters get reshaped correctly + rows = [True, False] + cols = [True, False] + assert_equal(consensus_score((rows, cols), + (array2d(rows), array2d(cols))),
 scikit-learn member vene added a note Aug 15, 2013 I think the idiom is rows[:, np.newaxis] unless you're trying to accomplish something else that I didn't get. array2d might have a bit of overhead. to join this conversation on GitHub. Already have an account? Sign in to comment
and 1 other commented on an outdated diff Aug 15, 2013
sklearn/cluster/bicluster/cheng_church.py
 + +from sklearn.base import BaseEstimator, BiclusterMixin +from sklearn.externals import six + +from sklearn.utils.validation import check_arrays +from sklearn.utils.validation import check_random_state + +from .utils import check_array_ndim +from ._squared_residue import compute_msr + + +class EmptyBiclusterException(Exception): + pass + + +class IncrementalMSR(object):
 scikit-learn member vene added a note Aug 15, 2013 Should this class be public-facing? kemaleren added a note Aug 17, 2013 No. I assume that private classes also use the '_' prefix? to join this conversation on GitHub. Already have an account? Sign in to comment
and 1 other commented on an outdated diff Aug 26, 2013
examples/bicluster/cheng_church_microarray.py
 +data[idx] = generator.randint(-800, 801, len(idx[0])) + +# cluster with same parameters as original paper +model = ChengChurch(n_clusters=100, max_msr=1200, + deletion_threshold=1.2, inverse_rows=True, + random_state=0) +print("Biclustering...") +start_time = time() +model.fit(data) +print("Done in {:.2f}s.".format(time() - start_time)) + +# find smallest msr +msr = lambda a: (np.power(a - a.mean(axis=1, keepdims=True) - + a.mean(axis=0) + a.mean(), 2).mean()) +min_msr = min(msr(model.get_submatrix(i, data)) for i in range(100)) +print("MSR of best bicluster: {:.2f}".format(min_msr))
 scikit-learn member vene added a note Aug 26, 2013 The MSR doesn't mean much, at least to me, without a bit of context. Is it possible to either give some context (maybe by also running some baseline method) or to plot something? kemaleren added a note Aug 29, 2013 I'd like to plot the parallel coordinates of the bicluster's rows, as I did in my blog post. I used pandas' plotting functionality for that. Since pandas is not available here, maybe I could get the same effect with a line plot. to join this conversation on GitHub. Already have an account? Sign in to comment
commented on an outdated diff Aug 26, 2013
examples/bicluster/cheng_church_microarray.py
 @@ -0,0 +1,56 @@ +""" +================================================== +Biclustering microarray data with Cheng and Church +================================================== + +This example is a replication of an experiment from the original Cheng +and Church paper. The gene microarray data is downloaded from the
 scikit-learn member vene added a note Aug 26, 2013 I guess it would be nice to also write a bit about what the microarray data represents and what is the application that biclustering solves on such data. to join this conversation on GitHub. Already have an account? Sign in to comment
commented on an outdated diff Aug 26, 2013
examples/bicluster/plot_cheng_church.py
 + +from matplotlib import pyplot as plt + +from sklearn.datasets import make_msr_biclusters +from sklearn.datasets import samples_generator as sg +from sklearn.cluster.bicluster import ChengChurch +from sklearn.metrics import consensus_score + +data, rows, columns = make_msr_biclusters(shape=(100, 100), + n_clusters=3, noise=10, + shuffle=False, + random_state=0) + +plt.matshow(data, cmap=plt.cm.Blues) +plt.title("Original dataset") +plt.show()
 scikit-learn member vene added a note Aug 26, 2013 plt blocks on this call, which makes the example wait for you to close the window when running it manually. I just thought it was taking a long time, until I realized. I think both calls should be removed with a single call to plt.show() at the very end of the script. to join this conversation on GitHub. Already have an account? Sign in to comment
and 1 other commented on an outdated diff Aug 26, 2013
sklearn/cluster/bicluster/tests/test_cheng_church.py
 + + inc.remove_row(0) + inc.remove_col(0) + + arr = data[new_rows][:, new_cols] + sr = arr - arr.mean(axis=1, keepdims=True) - arr.mean(axis=0) + arr.mean() + sr = np.power(sr, 2) + + assert_almost_equal(inc.msr, sr.mean()) + assert_array_almost_equal(inc.row_msr, sr.mean(axis=1)) + assert_array_almost_equal(inc.col_msr, sr.mean(axis=0)) + + +def test_cheng_church(): + """Test Cheng and Church algorithm on a simple problem.""" + for shape in ((150, 150), (50, 50)):
 scikit-learn member vene added a note Aug 26, 2013 Would the shape change anything here? Does it need to be square? kemaleren added a note Aug 29, 2013 It need not be square. The reason I tried two different shapes was becase the default cutoff for multiple node deletion is 150. But I could just change the cutoff, instead. to join this conversation on GitHub. Already have an account? Sign in to comment
and 1 other commented on an outdated diff Aug 26, 2013
sklearn/cluster/bicluster/tests/test_cheng_church.py
 + assert_array_almost_equal(inc.col_msr, sr.mean(axis=0)) + + +def test_cheng_church(): + """Test Cheng and Church algorithm on a simple problem.""" + for shape in ((150, 150), (50, 50)): + for noise in (0, 1): + for deletion_threshold in (1.5, 2): + data, rows, cols = make_msr_biclusters(shape, 3, + noise=noise, + random_state=0) + model = ChengChurch(n_clusters=3, max_msr=10, + deletion_threshold=deletion_threshold, + random_state=0) + model.fit(data) + assert(consensus_score((rows, cols), model.biclusters_) > 0.7)
 scikit-learn member vene added a note Aug 26, 2013 You should use assert_greater, but also, I think that this test is a bit weak. Maybe also test that consensus_score is better in absence of noise? kemaleren added a note Aug 29, 2013 Yes, it is weak. I like the idea of checking that the consensus score improves. I could also make a custom threshold for each set of parameters, which would catch if something causes one of the higher scores to fall. to join this conversation on GitHub. Already have an account? Sign in to comment
commented on the diff Aug 26, 2013
sklearn/cluster/bicluster/tests/test_cheng_church.py
 @@ -0,0 +1,235 @@ +"""Testing for Spectral Biclustering methods"""
 scikit-learn member vene added a note Aug 26, 2013 I think many of the tests in this file can be made faster by making the input arrays smaller. Of course, in cases where it wouldn't change anything. WDYT? kemaleren added a note Aug 29, 2013 It's the spectral biclustering test that takes most of the time. I made the twice as small, but that only sped it up by a few tenths of a second. The slowdown is caused by iterating over a parameter grid. I cut the time in half by using only one paramter for n_svd_vecs. to join this conversation on GitHub. Already have an account? Sign in to comment
and 1 other commented on an outdated diff Aug 26, 2013
sklearn/cluster/bicluster/tests/test_cheng_church.py
 + # check that all the new rows are inverted rows + expected_inv_rows = np.zeros(15, dtype=np.bool) + expected_inv_rows[10:15] = True + new_rows = np.logical_and(model.rows_[0], + np.logical_not(old_rows)) + assert not np.any(np.logical_or(expected_inv_rows, new_rows)[:10]) + assert np.any(new_rows[10:]) + + +def test_empty_biclusters(): + """Cheng and Church should always find at least one bicluster. + + The MSR of a bicluster with one row or one column is zero. + + """ + for i in range(10):
 scikit-learn member vene added a note Aug 26, 2013 Rather than try arbitrary random seeds, how about building an input by hand that would pose problems? The way it's done here, couldn't it be the case that we just get lucky for i in 0...9? kemaleren added a note Aug 29, 2013 I forgot about this, so I'm glad you caught it. I think it would make more sense to not report biclusters with only one row or column. Any arbitrary vector has a perfect mean squared residue, so it is a meaningless result. to join this conversation on GitHub. Already have an account? Sign in to comment
scikit-learn member
commented Aug 26, 2013

Looks good but it diverged from master, could you rebase please?

Sure. I just rebased, and also addressed your other comments.

commented on the diff Sep 12, 2013
doc/modules/biclustering.rst
 @@ -84,6 +87,77 @@ diagonal and checkerboard bicluster structures. .. currentmodule:: sklearn.cluster.bicluster +.. _cheng_church: + +Cheng and Church +================ + +:class:ChengChurch tries to find biclusters with a low mean squared +residue (MSR). For a matrix :math:A with shape :math:m \times n,
 scikit-learn member GaelVaroquaux added a note Sep 12, 2013 Am I right to think that in this sens it minimizes the same kind of criterion than KMeans? kemaleren added a note Sep 13, 2013 It's a similar criterion in that is a 'mean squared ______. However, in this case it takes more than just the overall mean of the cluster into account. I don't think they are very similar. to join this conversation on GitHub. Already have an account? Sign in to comment
commented on the diff Sep 12, 2013
examples/bicluster/plot_cheng_church.py
 @@ -0,0 +1,67 @@ +"""
 scikit-learn member GaelVaroquaux added a note Sep 12, 2013 Very nice example! to join this conversation on GitHub. Already have an account? Sign in to comment
and 1 other commented on an outdated diff Sep 12, 2013
examples/bicluster/plot_cheng_church_microarray.py
 +residue threshold is lowered to make the bicluster visually simpler. + +""" +from __future__ import print_function + +print(__doc__) + +from time import time +import urllib + +import numpy as np +from matplotlib import pyplot as plt + +from sklearn.cluster.bicluster import ChengChurch + +# get data
 scikit-learn member GaelVaroquaux added a note Sep 12, 2013 Should we be writing a dataset fetch for this example, with a caching, as the other datasets? I am fortunate enough to have Wifi right now, but that's not always the case? kemaleren added a note Sep 13, 2013 Sure, I can do that. Sounds like a good idea. Let me take a look at how the others do it. to join this conversation on GitHub. Already have an account? Sign in to comment
commented on the diff Sep 12, 2013
examples/bicluster/plot_cheng_church_microarray.py
 +gene, and each column represents a tissue sample from a patient with +lymphoma. The larger the value of data[i, j], the more active gene +i in sample j. Biclustering this data with Cheng and Church +finds subsets of samples with similar expression profiles in a subset +of genes. The goal of this kind of analysis is often to find sets of +genes that may be somehow related. For instance, lymphoma may cause +some genes that are otherwise unrelated to become highly expressed or +supressed. + +The gene microarray data is downloaded from the paper's supplementary +information webpage, parsed into a NumPy array, and clustered with +Cheng and Church. The bicluster is then visualized by a parallel +coordinate plot of its rows. Biclustering is performed with almost the +same parameters as in the original experiment, except the mean squared +residue threshold is lowered to make the bicluster visually simpler. +
 scikit-learn member GaelVaroquaux added a note Sep 12, 2013 That's a nice example, but is there any chance that you can find us a more visual plot? to join this conversation on GitHub. Already have an account? Sign in to comment
and 1 other commented on an outdated diff Sep 12, 2013
sklearn/cluster/bicluster/cheng_church.py
 + self._row_idxs = None + self._col_idxs = None + + subarr = arr[self.row_idxs[:, np.newaxis], self.col_idxs] + self._sum = subarr.sum() + self._row_sum = subarr.sum(axis=1) + self._col_sum = subarr.sum(axis=0) + + self._reset() + + def _reset(self): + self._msr = None + self._row_msr = None + self._col_msr = None + + @property
 scikit-learn member GaelVaroquaux added a note Sep 12, 2013 From a style point of view, I prefer explicit getters (as in in a 'get_row_idx' function) rather than properties. It makes it more explicit in the code that there is computation going on when reading the code. The same remark holds for the properties below. IMHO, the real usecase of properties is impedance matching to adapt to an interface that expects attributes. kemaleren added a note Sep 13, 2013 Good point. I can change this easily. I think I just used properties here because row_idxs is shorter to write than get_row_idxs. to join this conversation on GitHub. Already have an account? Sign in to comment
scikit-learn member

General cosmetic remark: you used the term MSR 'Mean Square Residue' a lot in your code. I am more used to 'MSE', as in mean square error. I wonder if I am the only one. If not it might be worth changing.

and 1 other commented on an outdated diff Sep 12, 2013
sklearn/cluster/bicluster/cheng_church.py
 + old_rows = rows.copy() # save for row inverse + msr = self._msr(rows, cols, X) + row_msr = self._row_msr(rows, cols, X) + rows = np.logical_or(rows, row_msr < msr) + + if self.inverse_rows: + row_msr = self._row_msr(old_rows, cols, X, + inverse=True) + to_add = row_msr < msr + new_inverse_rows = np.logical_and(to_add, np.logical_not(rows)) + inverse_rows = np.logical_or(inverse_rows, + new_inverse_rows) + rows = np.logical_or(rows, to_add) + + if (n_rows == np.count_nonzero(rows)) and \ + (n_cols == np.count_nonzero(cols)):
 scikit-learn member GaelVaroquaux added a note Sep 12, 2013 I have in mind that 'np.count_nonzero' is somewhat of a recent addition to numpy. You may want to check if it is in all the versions of numpy that we support. kemaleren added a note Sep 13, 2013 It is indeed not available until NumPy 1.6. I will rewrite this. to join this conversation on GitHub. Already have an account? Sign in to comment
commented on an outdated diff Sep 12, 2013
sklearn/cluster/bicluster/cheng_church.py
 + """Mask a bicluster in the data with random values.""" + shape = np.count_nonzero(rows), np.count_nonzero(cols) + mask_vals = generator.uniform(minval, maxval, shape) + r = rows.nonzero()[0][:, np.newaxis] + c = cols.nonzero()[0] + X[r, c] = mask_vals + + def fit(self, X): + """Creates a biclustering for X. + + Parameters + ---------- + X : array-like, shape (n_samples, n_features) + + """ + X = X.copy() # need to modify it in-place
 scikit-learn member GaelVaroquaux added a note Sep 12, 2013 You should rather use 'copy=True', in check_arrays, 2 lines below. Indeed, if the dtype is not float64, you will copy the data twice. to join this conversation on GitHub. Already have an account? Sign in to comment
commented on an outdated diff Sep 12, 2013
sklearn/cluster/bicluster/_squared_residue.pyx
 + +cimport numpy as np +cimport cython + +np.import_array() + +ctypedef np.float64_t DOUBLE +ctypedef np.int64_t LONG + + +def compute_msr(long[:] rows, + long[:] cols, + double[:] row_mean, + double[:] col_mean, + double arr_mean, + double[:, :] X):
 scikit-learn member GaelVaroquaux added a note Sep 12, 2013 I think that this function needs a docstring, even if is a very short one. Also, I believe that it should be moved to utils, as it can be of general interest and will not be found where it currently is. to join this conversation on GitHub. Already have an account? Sign in to comment

@GaelVaroquaux The mean squared residue criterion in this context is different from the mean squared error. The MSR is well known in biclustering, so I believe it would be more, rather than less, confusing to refer to it as MSE instead.

scikit-learn member
added some commits Jul 25, 2013
 kemaleren re-committing Cheng and Church code as a feature branch - implemented the algorithm - added some simple tests - wrote data generator 3bf832f kemaleren do single node deletion in main loop 0974438 kemaleren wrote some tests 0027e0c kemaleren fixed precision in cython e29bb6a kemaleren some more tests - test when deletion unnecessary - check that exception gets raised f6e7077 kemaleren also do other residue calculations in cython 9ed95f0 kemaleren updated docstring, renamed _sr to _square_residue f265a1b kemaleren do not calculate same mean twice 48ef505 kemaleren added ChengChurch to documentation 4f6c916 kemaleren corrected calculation of msr for adding rows and columns 8e247bc kemaleren cython version precision was corrected, so update test 2cb6fa3 kemaleren renamed square to squared b310d79 kemaleren added msr note to documentation 1d5cf70 kemaleren compute all msr at once c9425fe kemaleren documentation updates f29535f kemaleren added comment explaining row shape 52ddc45 kemaleren corrected reference 5e1d164 kemaleren incremental update 2e3efc8 kemaleren added docstring for IncrementalMSR f919d6d kemaleren use keepdims in docstring 9c7ee7a kemaleren renamed compute() to compute_msr() ec162b9 kemaleren cython speedups - use typed memoryviews - use nogil 6db2ff4 kemaleren ensure metrics work for single biclusters daec7fd kemaleren wrote tests for inverse rows and columns 95ee24c kemaleren wrote docstrings cdcf444 kemaleren make_msr() does not just generate constant biclusters a2173b8 kemaleren fixed bug in IncrementalMSR cd40436 kemaleren updated documentation to improve MSR explanation 75087e3 kemaleren renamed variable to be more descriptive b57ed5c kemaleren updated description of msr 8f8eabe kemaleren updated documentation 1203733 kemaleren no inverse columns. use incremental class everywhere possible e72d40b kemaleren updated make_msr() 32baa46 kemaleren removed test d57ee69 kemaleren updated test 4e18080 kemaleren added cheng and church examples de956c5 kemaleren removed unused code 9b53bd5 kemaleren address code review suggestions 62ff076 kemaleren added the inverted_rows_ attribute c49742a kemaleren updated cheng church examples d40b921 kemaleren do not return trivial biclusters b7e3dfc kemaleren tests: ensure cheng and church does better when noise=0 a5ad29d kemaleren sped up spectral biclustering tests 24bfdd6 kemaleren wrote caching data fetcher for microarray data 6735b3b kemaleren added plot of bicluster in example dd14582 kemaleren replaced properties with getters ec41954 kemaleren made count_nonzero work for older versions of numpy 3f8aee6 kemaleren replaced unnecessary copy 6b4e1df kemaleren moved mean squared residue to extmath 2a82e8d kemaleren added whats new f47f47b
scikit-learn member

I had a closer look at the microarray example, and I tried to do a plot of the resulting clustering to get a gut feeling. I did the following:

row_order = np.argsort(model.rows_[0], kind='mergesort')
column_order = np.argsort(model.columns_[0], kind='mergesort')

plt.matshow(data[row_order].T[column_order].T[:300])

It seems to me that this would sort out the clusters.

The resulting image does not really highlight a structure. Am I being dense, or is it just that there is very little structure in this data?

There are two issues here.

First, you would need to reverse the row and column order to put the bicluster in the top left corner. As written, it would be in the lower right corner.

row_order = row_order[::-1]
column_order = column_order[::-1]
`

Second, the bicluster's range is (-65, 65), whereas the portion you plotted has range (-799, 800). The variation within the bicluster is just not visible. That is why the example heatmap only shows the bicluster itself.

scikit-learn member

Do you think that you could do this in the example? I think that it would make things more explicit.

Also, have you seen the PR that I sent you a little while ago? kemaleren#1

to join this conversation on GitHub. Already have an account? Sign in to comment