Find the average spacing between an array of numbers
$begingroup$
If I had an array of 7 numbers and I wanted all numbers to be equally spaced within it but needed to start at 5 and end at 35 how would I do this?
For instance if I were given:
- Numbers in array: 7
- Largest number in array: 35
- Smallest number in array: 5
How do I find what number to increment the array by if I wanted to create an array of equally spaced numbers?
An example answer would be: Given the above three numbers I would say increment each array position by 5 and all 7 numbers will be equally spaced all the way to 35. The end result would look like this: [5,10,15,20,25,30,35]
Question 1: What would the formula be to repeat this any time I have array length, smallest, and largest number?
Question 2: In the above example if I were given the number 30 what is the formula to find its position in the given array? The formula should produce a result like this: If the array started at index one it would be position 6.
Any help would be great, thanks!
statistics
$endgroup$
add a comment |
$begingroup$
If I had an array of 7 numbers and I wanted all numbers to be equally spaced within it but needed to start at 5 and end at 35 how would I do this?
For instance if I were given:
- Numbers in array: 7
- Largest number in array: 35
- Smallest number in array: 5
How do I find what number to increment the array by if I wanted to create an array of equally spaced numbers?
An example answer would be: Given the above three numbers I would say increment each array position by 5 and all 7 numbers will be equally spaced all the way to 35. The end result would look like this: [5,10,15,20,25,30,35]
Question 1: What would the formula be to repeat this any time I have array length, smallest, and largest number?
Question 2: In the above example if I were given the number 30 what is the formula to find its position in the given array? The formula should produce a result like this: If the array started at index one it would be position 6.
Any help would be great, thanks!
statistics
$endgroup$
add a comment |
$begingroup$
If I had an array of 7 numbers and I wanted all numbers to be equally spaced within it but needed to start at 5 and end at 35 how would I do this?
For instance if I were given:
- Numbers in array: 7
- Largest number in array: 35
- Smallest number in array: 5
How do I find what number to increment the array by if I wanted to create an array of equally spaced numbers?
An example answer would be: Given the above three numbers I would say increment each array position by 5 and all 7 numbers will be equally spaced all the way to 35. The end result would look like this: [5,10,15,20,25,30,35]
Question 1: What would the formula be to repeat this any time I have array length, smallest, and largest number?
Question 2: In the above example if I were given the number 30 what is the formula to find its position in the given array? The formula should produce a result like this: If the array started at index one it would be position 6.
Any help would be great, thanks!
statistics
$endgroup$
If I had an array of 7 numbers and I wanted all numbers to be equally spaced within it but needed to start at 5 and end at 35 how would I do this?
For instance if I were given:
- Numbers in array: 7
- Largest number in array: 35
- Smallest number in array: 5
How do I find what number to increment the array by if I wanted to create an array of equally spaced numbers?
An example answer would be: Given the above three numbers I would say increment each array position by 5 and all 7 numbers will be equally spaced all the way to 35. The end result would look like this: [5,10,15,20,25,30,35]
Question 1: What would the formula be to repeat this any time I have array length, smallest, and largest number?
Question 2: In the above example if I were given the number 30 what is the formula to find its position in the given array? The formula should produce a result like this: If the array started at index one it would be position 6.
Any help would be great, thanks!
statistics
statistics
asked Jan 28 at 22:15


TimTim
1033
1033
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
$begingroup$
Hints:
- How many gaps between consecutive pairs of numbers? In your example, $7-1=6$
- What do the gaps add up to? In your example, $35-5=30$
- What is the size of a gap? In your example, $frac{30}{6}=5$
- suppose there was a value before the first; what would it be? (call this the zeroth value) In your example, $5-5=0$
- how many gaps would you need to add to the zeroth value to get your target value? In your example, $frac{30}{5}=6$
So the $n$th value would be the zeroth value plus $n$ gaps, while value $x$ would be in the position corresponding to $x$ minus the zeroth value, all divided by the gap size
$endgroup$
add a comment |
$begingroup$
We have 2 numbers, $a,b$ with $a<b$. Suppose we want $c$ numbers in the array. Then the array would look like this: $(a,a+d,a+2d,....,a+(c-2)d,b)$ For some number $d$. Notice that the difference between any consecutive numbers in the array is $d$ (by construction). Using this fact, $b-(a+(c-2)d)=d.$ (last number in array minus penultimate) which we can solve for $d$ to obtain $d=(b-a)/(c-1)$ and $c neq 1$ since we always have at least 2 numbers in the array.
$endgroup$
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
return StackExchange.using("mathjaxEditing", function () {
StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
});
});
}, "mathjax-editing");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "69"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
noCode: true, onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f3091464%2ffind-the-average-spacing-between-an-array-of-numbers%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
$begingroup$
Hints:
- How many gaps between consecutive pairs of numbers? In your example, $7-1=6$
- What do the gaps add up to? In your example, $35-5=30$
- What is the size of a gap? In your example, $frac{30}{6}=5$
- suppose there was a value before the first; what would it be? (call this the zeroth value) In your example, $5-5=0$
- how many gaps would you need to add to the zeroth value to get your target value? In your example, $frac{30}{5}=6$
So the $n$th value would be the zeroth value plus $n$ gaps, while value $x$ would be in the position corresponding to $x$ minus the zeroth value, all divided by the gap size
$endgroup$
add a comment |
$begingroup$
Hints:
- How many gaps between consecutive pairs of numbers? In your example, $7-1=6$
- What do the gaps add up to? In your example, $35-5=30$
- What is the size of a gap? In your example, $frac{30}{6}=5$
- suppose there was a value before the first; what would it be? (call this the zeroth value) In your example, $5-5=0$
- how many gaps would you need to add to the zeroth value to get your target value? In your example, $frac{30}{5}=6$
So the $n$th value would be the zeroth value plus $n$ gaps, while value $x$ would be in the position corresponding to $x$ minus the zeroth value, all divided by the gap size
$endgroup$
add a comment |
$begingroup$
Hints:
- How many gaps between consecutive pairs of numbers? In your example, $7-1=6$
- What do the gaps add up to? In your example, $35-5=30$
- What is the size of a gap? In your example, $frac{30}{6}=5$
- suppose there was a value before the first; what would it be? (call this the zeroth value) In your example, $5-5=0$
- how many gaps would you need to add to the zeroth value to get your target value? In your example, $frac{30}{5}=6$
So the $n$th value would be the zeroth value plus $n$ gaps, while value $x$ would be in the position corresponding to $x$ minus the zeroth value, all divided by the gap size
$endgroup$
Hints:
- How many gaps between consecutive pairs of numbers? In your example, $7-1=6$
- What do the gaps add up to? In your example, $35-5=30$
- What is the size of a gap? In your example, $frac{30}{6}=5$
- suppose there was a value before the first; what would it be? (call this the zeroth value) In your example, $5-5=0$
- how many gaps would you need to add to the zeroth value to get your target value? In your example, $frac{30}{5}=6$
So the $n$th value would be the zeroth value plus $n$ gaps, while value $x$ would be in the position corresponding to $x$ minus the zeroth value, all divided by the gap size
edited Jan 28 at 22:26
answered Jan 28 at 22:19
HenryHenry
101k482169
101k482169
add a comment |
add a comment |
$begingroup$
We have 2 numbers, $a,b$ with $a<b$. Suppose we want $c$ numbers in the array. Then the array would look like this: $(a,a+d,a+2d,....,a+(c-2)d,b)$ For some number $d$. Notice that the difference between any consecutive numbers in the array is $d$ (by construction). Using this fact, $b-(a+(c-2)d)=d.$ (last number in array minus penultimate) which we can solve for $d$ to obtain $d=(b-a)/(c-1)$ and $c neq 1$ since we always have at least 2 numbers in the array.
$endgroup$
add a comment |
$begingroup$
We have 2 numbers, $a,b$ with $a<b$. Suppose we want $c$ numbers in the array. Then the array would look like this: $(a,a+d,a+2d,....,a+(c-2)d,b)$ For some number $d$. Notice that the difference between any consecutive numbers in the array is $d$ (by construction). Using this fact, $b-(a+(c-2)d)=d.$ (last number in array minus penultimate) which we can solve for $d$ to obtain $d=(b-a)/(c-1)$ and $c neq 1$ since we always have at least 2 numbers in the array.
$endgroup$
add a comment |
$begingroup$
We have 2 numbers, $a,b$ with $a<b$. Suppose we want $c$ numbers in the array. Then the array would look like this: $(a,a+d,a+2d,....,a+(c-2)d,b)$ For some number $d$. Notice that the difference between any consecutive numbers in the array is $d$ (by construction). Using this fact, $b-(a+(c-2)d)=d.$ (last number in array minus penultimate) which we can solve for $d$ to obtain $d=(b-a)/(c-1)$ and $c neq 1$ since we always have at least 2 numbers in the array.
$endgroup$
We have 2 numbers, $a,b$ with $a<b$. Suppose we want $c$ numbers in the array. Then the array would look like this: $(a,a+d,a+2d,....,a+(c-2)d,b)$ For some number $d$. Notice that the difference between any consecutive numbers in the array is $d$ (by construction). Using this fact, $b-(a+(c-2)d)=d.$ (last number in array minus penultimate) which we can solve for $d$ to obtain $d=(b-a)/(c-1)$ and $c neq 1$ since we always have at least 2 numbers in the array.
answered Jan 28 at 22:29
DisplaynameDisplayname
25612
25612
add a comment |
add a comment |
Thanks for contributing an answer to Mathematics Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
Use MathJax to format equations. MathJax reference.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f3091464%2ffind-the-average-spacing-between-an-array-of-numbers%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown