Calculate difference [closed] - math

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 10 years ago.
Improve this question
I have 5 values, for example like this:
3
11
8
5
8
I want to calculate the average difference between them.
If I had just two values, say 3 and 11, the difference would be 8.
But how do I do this when I have more values (for example five as in my example above)?

I can not show the answer in detail because I can not format math in this board. Please refer to the mathematics subboard for math related question.
Not exactly sure what you are after but it might be the standard deviation
The standard deviation is a measure of the relative deviation from each number with respect to the ensemble average.

You might be looking for Variance or Standard Deviation.
Variance -> A measure of the dispersion of a set of data points around their mean value. Variance is a mathematical expectation of the average squared deviations from the mean.
Estimating the variance

Related

normally distributed population, calculating in R the probability of negative or zero readings occurring [closed]

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.

How to construct a CDF if you don't have the data but you know the slope and 50% point? [closed]

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
I have a question regarding the CDF function. In a study, the researchers fitted a CDF of the normal distribution on their data and presented the median (= -8.4 dB) and the slope (=18.7). How can I recreate this function (in R) so I can find out what percentage (y-axis) is expected for e.g. 9 dB on the x-axis? When I look at the formula of the CDF, I'm not sure where to insert the slope and median statistics...
Many thanks in advance!
You need additional hypotheses on the distribution in order to recreate the full CDF function. Unless you have counter-arguments (from the data interpretation), let's assume it is normally distributed.
By definition, the derivative (slope) of a CDF function is its PDF function. Thus what you are given is the median and the PDF value at the median. For the normal distribution:
the median (50% point) equals the mean
PDF(mu) is 1/sqrt(2*pi*sd), where mu is the mean and sd is the standard deviation
Thus, with the additional hypothesis that the sought distribution is normal, its CDF will be the normal CDF (pnorm in R) with parameters:
mean = midpoint
sd = 1/(2*pi * slope^2)

function scale() in R doesn't scale the data symmetrically [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 5 years ago.
Improve this question
I apologize if my question is simple. I tried to find the answer but I didn't find much info.
I use the scale() function in R to scale my data. What I don't understand is that when I plot my scaled data using matplot() it seems my scaled data aren't symmetric. which means the range of the sacled data is -1,-0.5,0,0.5,1,1.5. As I know, we scale the data to mean zero and standard deviation s. So my data should have a deviation of s from mean but here I have a deviation of 1.5 and a deviation of -1. Why?
Your data are not symmetric around their mean.
Compare the following:
x <- runif(1000) # symmetric around 0.5
y <- rexp(1000) # not symmetric around 1 at all
summary(scale(x))
summary(scale(y))

distribution from percentage with R [closed]

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"])

Using R, how to estimate a distribution using known mean, median, percentile? [closed]

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 9 years ago.
Improve this question
How can I estimate a distribution if I know my sample size is 449, the mean is 81.69, the median is 81.68, the 30th percentile is 79.43, and the 90th percentile is 85.06?
The highest entropy distribution with known mean and variance is the normal distribution giving us a rationale to use it here provided the data is not inconsistent with it. Now using the given mean and estimating the standard deviation as:
q30 <- 79.43
q90 <- 85.06
SD <- (q90 - q30) / (qnorm(.9) - qnorm(.3))
we get the normal distribution with mean 81.69 and standard deviation SD. Here we have used the mean we were given, simply noted that the median being nearly identical to the mean is not inconsistent with the normal distribution and we used the two remaining quantiles to estimate the standard deviation.
The size of your sample is irrelevant to this question (it might be useful in calculating confidence intervals). What you have to work with is three quantiles (mean, 30th and 90th). Since the median is practically the same as the mean, that's a hint that your distribution is most likely symmetric. After that, you're pretty much dead-ended. You can fit those data points to a gaussian, or a supergaussian (or whatever exp(x^4) is called), or any number of decaying symmetric distributions.

Resources