Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 11 years ago.
Improve this question
What does correlation coefficient intuitively mean? If I have a series of X and then a series of Y, and if I input these two into Weka multilayer perceptron treating Y as the output and X as input, I get a correlation coefficient as 0.76. What does this intuitively represent, and how I explain this to a business man or a non-techie person?
There are several correlation coefficients. The most commonly used, and the one that is referred to as "the one" is Pearson's product moment correlation.
A correlation coefficient shows the degree of linear dependence of x and y. In other words, the coefficient shows how close two variables lie along a line.
If the coefficient is equal to 1 or -1, all the points lie along a line. If the correlation coefficient is equal to zero, there is no linear relation between x and y. however, this does not necessarily mean that there is no relation at all between the two variables. There could e.g. be a non-linear relation.
A positive relationship means that the two variables move into the same direction. A higher value of x corresponds to higher values of y, and vice versa.
A negative relationship means that the two variables move into the opposite directions. A lower value of x corresponds to higher values of y, and vice versa.
Here you have a handful of examples:
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
In R, how do you calculate the probability of negative or zero readings occurring?
μ and σ are giving.
You can use the distribution function of the gaussian distribution:
pnorm(0,μ,σ)
(I guess you are speaking about gaussian distribution)
edit
The pnorm is the cumulative density function. Its values are between 0 and 1, and its value at x gives the area under the gaussian curve from -inf to x. In my example below, the value at 0 of pnorm give the area in pink under the gaussian curve, so the probability you are looking for, i.e. the probability of sampling a value following the corresponding gausian distribution with a value below or equal to 0.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
I have distribution of parameter (natural gas mixture composition) expressed in percents. How to test such data for distribution parameters (it should be gamma, normal or lognormal distribution) and generate random composition based on that parameters in R?
This might be a better question for CrossValidated, but:
it is not generally a good idea to choose from among a range of possible distributions according to goodness of fit. Instead, you should choose according to the qualitative characteristics of your data, something like this:
Frustratingly, this chart doesn't actually have the best choice for your data (composition, continuous, bounded between 0 and 1 [or 0 and 100]), which is a Beta distribution (although there are technical issues if you have values of exactly 0 or 100 in your sample).
In R:
## some arbitrary data
z <- c(2,8,40,45,56,58,70,89)
## fit (beta values must be in (0,1), not (0,100), so divide by 100)
(m <- MASS::fitdistr(z/100,"beta",start=list(shape1=1,shape2=1)))
## sample 1000 new values
z_new <- 100*rbeta(n=1000,shape1=m$estimate["shape1"],
shape2=m$estimate["shape2"])
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
I have a linear interpolation methods. This is calculate interpolate value when (x1,y1) (x2,y2) and x0 known. it is calculate y0 value. But i need the do that when multi point known.
I am not talking about Bilinear or Trilinear interpolation.
For multi point interpolation there are 3 options:
piecewise linear interpolation
choose 2 closest points to your known coordinate if you use parameter then select the points containing parameter range and change the parameter range/scale to interpolation range (usually <0,1>) and interpolate as linear interpolation.
example of linear DDA on integers and more is in here:
Precise subpixel line drawing algorithm (rasterization algorithm)
polynomial interpolation
this is not linear !!! Take all known points, compute n-th degree polynomial from it (by Lagrange polynomial or by edge conditions or by regression/curve fitting or by whatever else) and compute the point from parameter as function of this polynomial. Usually you have one polynomial per axis the more the points and or degree of polynomial the less stable the result (oscillations).
piecewise polynomial interpolation
It is combination of #1,#2 (n is low to avoid oscillations). You need to call the point sequence properly to manage continuity between segments, the edge conditions must take into account previous and next segment...
here Piecewise interpolation cubic example
here How to construct own interpolation 3th degree polynomial
here How to construct own interpolation 4th degree polynomial
here point call sequence and BEZIER cubic as interpolation cubic
[notes]
SPLINE,BEZIER,... are approximation curves not interpolation (they do not necessarily cross the control points). There is a way how to convert in-between different types of curves by recomputation of control points. For example see this:
Interpolation cubic vs. Bezier cubic
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Closed 9 years ago.
Improve this question
I have a number of melting curves, for which I want to determine the slope of the steepest part between the minimum (valley) and maximum (peak) using R code (the slope in the inflection point corresponds to the melting point). The solutions I can imagine are either to determine the slope in every point and then find the maximum positive value, or by fitting a 4-parameter Weibull-type curve using the drc package to determine the inflection point (basically corresponding to the 50% response point between minimum and maximum). In the latter case the tricky part is that this fitting has to be restricted for each curve to the temperature range between the minimum (valley) and maximum (peak) fluorescence response. These temperature ranges are different for each curve.
Grateful for any feedback!
The diff function accomplishes the equivalent of numerical differentiation on equally spaced values (up to a constant factor) so finding maximum (or minimum) values can be used to identify location of steepest ascent (or descent):
z <- exp(-seq(0,3, by=0.1)^2 )
plot(z)
plot(diff(z))
z[ which(abs(diff(z))==max(abs(diff(z))) )]
# [1] 0.6126264
# could have also tested for min() instead of max(abs())
plot(z)
abline( v = which(abs(diff(z))==max(abs(diff(z))) ) )
abline( h = z[which(abs(diff(z))==max(abs(diff(z))) ) ] )
With an x-difference of 1, the slope is just the difference at that point:
diff(z) [ which(abs(diff(z))==max(abs(diff(z))) ) ]
[1] -0.08533397
... but I question whether that is really of much interest. I would have thought that getting the index (which would be the melting point subject to an offset) would be the value of interest.
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 11 years ago.
Improve this question
I have 24 samples from a real-valued signal. I perform the fft() function on the sample and get the complex output. I want to obtain the amplitude and phase angle of each of the non-redundant harmonics. I know my calculation must account for aliasing since I have real-valued data. How do I:
(1) convert from the two-sided to a one-sided Fourier transform,
I've heard several things here. For example, do I multiply the first 12 harmonics (i.e., 2nd through 13th elements of fft() output) by two and drop the rest of the harmonics (i.e., keep 1st through 13th elements of fft() output)?
(2) calculate the amplitude of the one-sided Fourier transform,
I know I can use the Mod() function, but when do I do this? Before or after I convert from two- to one-sided?
(3) calculate the phase angle of the one-sided Fourier transform.
I know I can use the atan() function on the ratio of imaginary to real parts of the fft() output, but again, when do I do this? Before or after two- to one-sided conversion? Also, what if atan is undefined?
Thanks.
Since your input is real the output of the FFT will be symmetric about N / 2 so you can just look at the first N / 2 bins and scale the magnitude by a factor of 2. For the phase you ideally need an atan2 function which takes the real and imaginary components as separate arguments and returns a 4 quadrant result.