When I use Aws dynamodb, I didn't know how the service calculate the cost with auto scale in each hour.
example:
If first 12 "minutes" the write unit is 10 WCU, after that write unit is
20 WCU in one hour.
What is actual write unit should I pay? (10, 20 or 10 * 0.2 + 0.8 * 20)
There's specific examples of this at https://aws.amazon.com/dynamodb/pricing, and in short you will pay for the maximum capacity units in a given hour when scaling up, and the target capacity units when scaling down.
Related
I'm learning computer structure.
I have a question about MIPS, one of the ways to calculate CPU execution time.
The MIPS formula is as follows.
And if the clock rate is 4 GHz and the CPI is 1.
I think MIPS is 4,000hz.
Because It's 4 * 10^9 * Hz / 1 * 10^6.
I don't know if it's right to leave units of Hz.
Hz is 1/s. MIPS is actually "mega instruction / s". To be clear, "Per" is the slash for division: Mega Instructions / Second
4GHz is 4G s⁻¹. Divide that by 1 cycle per instruction... but cycle is period, which is inverse of frequency.
It's not 4000Hz MIPS because the MIPS means "Per second". You wrote 4000 million instruction 1/s 1/s.
You eat the Hz because it's part of the name you are labeling it with.
For any quantity, it's important to know what units it's in. As well as a scale factor (like a parsec is many times longer than an angstrom), units have dimensions, and this is fundamental (at least for physical quantities like time; it can get less obvious when you're counting abstract things).
Those example units are both units of length so they have the same dimensions; it's physically meaningful to add or subtract two lengths, or if we divide them then length cancels out and we have a pure ratio. (Obviously we have to take care of the scale factors, because 1 parsec / 1 angstrom isn't 1, it's 3.0856776e+26.) That is in fact why we can say a parsec is longer than an angstrom, but we can't say it's longer than a second. (It's longer than a light-second, but that's not the only possible speed that can relate time and distance.)
1 m/s is not the same thing as 1 kg, or as dimensionless 1.
Time (seconds) is a dimension, and we can treat instructions-executed as another dimension. (I'll call it I since there isn't a standard SI unit for it, AFAIK, and one could argue it's not a real physical dimension. That doesn't stop this kind of dimensional analysis from being useful, though.)
(An example of a standard count-based unit is the mole in chemistry, a count of particles. It's an SI base unit.)
Counts of clock cycles can be treated as another dimension, in which case clock frequency is cycles / sec rather than just s-1. (Seconds, s, are the base SI unit of time.) If we want to make sure we're correctly cancelling it out in both sides, that's a useful approach, especially when we have quantities like cycles/instruction (CPI). Thus cycle time is s/c, seconds per cycle.
Hz has dimensions of s-1, so if it's something per second we should not use Hz, if something isn't dimensionless. (Clock frequencies normally are given in Hz, because "cycles" aren't a real unit in physics. That's something we're introducing to make sure everything cancels properly).
MIPS has dimensions of instructions / time (I / s), so the factors that contribute to it must cancel out any cycle counts. And we're not calling it Hz because we're considering "instructions" as a real unit, thus 4000 MIPS not 4000 MHz. (And MIPS is itself a unit so it's definitely not 4000 Hz MIPS; if it made sense to combine units that way, that would be dimensions of I/s2, which would be an acceleration not a speed.).
From your list of formulas, leaving out the factor of 10^6 (that's the M in MIPS, just a metric prefix in front of Instructions Per Sec, I/s)
instructions / total time obviously works without needing any cancelling.
I / (c * s / c) = I / s after cancelling cycles in the denominator
(I * c/s) / (I * c/I) cancel the Instructions in the denominator:
(I * c/s) / c cancel the cycles:
(I * 1/s) / 1 = I/s
(c/s) / (c/I) cancel cycles:
(1/s) / (1/I) apply 1/(1/I) = I reciprocal of reciprocal
(1/s) * I = I / s
All of these have dimensions of Instructions / Seconds, i.e. I/S or IPS. With a scale factor of 106, that's MIPS.
BTW, this is called "dimensional analysis", and in physics (and other sciences) it's a handy tool to see if a formula is sane, because both sides must have the same dimensions.
e.g. if you're trying to remember how position (or distance-travelled) of an accelerating object works, d = 1/2 * a * t^2 works because acceleration is distance / time / time (e.g. m/s^2), and time-squared cancels out the s^-2 leaving just distance. If you mis-remembered something like 1/2 a^2 * t, you can immediate see that's wrong because you'd have dimensions of m / s^4 * s = m / s^3 which is not a unit of distance.
(The factor of 1/2 is not something you can check with dimensional analysis; you only get those constant factors like 1/2, pi, e, or whatever from doing the full math, e.g. taking the derivative or integral, or making geometric arguments about linear plots of velocity vs. time.)
In a multi-user Operating System,20 requests are made to use a particular resourse per hour,on an average.The probability that no requests are made in 45 minutes is:
A). e^-15
B).e^-5
C).1-e^-5
D). 1-e^-10
I have spent time on wikipideia and several other sites but none of them clearly figured out
The stochastic process you are describing is a Poisson process. From Wikipedia:
In probability theory, a Poisson process is a stochastic process that counts the number of events and the time points at which these events occur in a given time interval. The time between each pair of consecutive events has an exponential distribution with parameter λ and each of these inter-arrival times is assumed to be independent of other inter-arrival times.
Since the exponential distribution is memoryless, we can define T to be an exponentially-distributed random variable that represents the time until the next event.
What should the expectation of T be? You have described a process in which the rate of events is 20 per hour. This is every 3 minutes. So E[T] = λ-1 = 3 min and thus λ = 1/3 min-1.
Now you are asking the question "What is the probability that no events occur in the next 45 minutes?" This is P(T > 45 min).
P(T > 45 min) = 1 - P(T ≤ 45 min) = 1 - (1 - e-45 min × λ) = e-15
This uses the fact that the cumulative density function for the exponential distribution is P(T ≤ t) = 1 - e-λt.
I'm trying to calculate the new temperature of an object when the air temperature around it changes, given a period of time.
Basically I get periodic readings from an air temperature sensor in a refrigerator. In some cases these readings are every 5 minutes, in others every 1 minute, so the time between readings is variable.
For each reading I get, I'd like to also calculate the approximate temperature of food at its core; something like a chicken for example (I know that part is vague, but if there is a variable I can tweak then that is fine).
The result should be a "damped" version of the actual air temperature, as obviously any objects will slowly change temperature to eventually meet the air temperature.
Initially there used to be "food simulant" put around the sensor, so the temperature would automatically be damped, but this is no longer the case.
I do not know much about thermodynamics. I'm not sure if I can just add a percentage of the temperature change to the previous damped value, or if I need a calculation based on the last few air temperature readings, or what.
I guess I'm looking for a result a bit like:
10:00 2 degrees (air), 2 degrees (product)
10:05 2.5 degrees (air), 2.1 degrees (product)
10:10 2.5 degrees (air), 2.2 degrees (product)
10:20 2.7 degrees (air), 2.5 degrees (product)
I could do something really cheap like averaging the readings over the last 30 minutes but I don't think that will cut it!
I'm not really sure this is the correct forum for this question! I'd appreciate any help - thanks very much.
EDIT: I have since found a solution by reading up on Fourier's Law. I will post the solution once I have some time. Thanks to anyone who commented.
A simple model would be to assume that the product changes temperature by a fraction of the difference between the product temerature and the air temperature.
airTemp = readAirTemp();
productTemp = productTemp + factor * (airtemp - productTemp);
If the time interval between readings changes, then you need to change the factor.
The factor also depends on which product you want to emulate.
Let's assume a factor of 0.5 at a 5 minute time interval.
Example (core temperature of a 25 degree product placed in a 5 degree refridgerator):
Time ProductTemp Temp Calculation:
0 25 5 <astart condition>
5 15 5 ptemp = 25 + 0.5 * (5-25)
10 10 5 ptemp = 15 + 0.5 * (5-15)
15 7.5 5 ptemp = 10 + 0.5 * (5-10)
20 6.25 5 ptemp = 7.5 + 0.5 * (5-7.5)
25 5.625 5 ptemp = 6.25 + 0.5 * (5-7.5)
A real physics model would consider heat transfer through thermal radiation, heat conduction and convection. However, having a single variable to tweak (factor) is a good start if you want a simple yet fairly realistic model.
Edit:
This is not an exact model. If you put something really hot in the fridge (like 1000 degrees), then radiation would be the leading term in the cooling equation and temperature would decline faster. The above model should work well when the difference is small. The factor would depend on the item (the things you mentioned and also the amount of energy it takes to change the temperature of the food and the shape of the food - thin food cools faster) and its surrounding (can air flow freely around it or is the fridge full).
Calculating the factor is by no means simple. I recommend that you put a thermometer in a couple of types of food, put them in the fridge and measure in 5 minute intervals and then calculate the factor for each food type. The factor would still be inexact - a small apple cools faster than a big apple and so on.
I have found below calculation from http://www.gridsouth.com/services/colocation/basics/bandwidth
I have no idea how they came up with final number 1.395 mbps. Can you please help me with the formula used in below example?
If your network provider bills you on average usage, let's say they sample your MBPS usage 100 times in one month (typically it would be more like every 5 minutes) and of those samples your network usage was measured as follows: 20 times: .1 MBPS, 30 times .1.5 MBPS, 30 times 1.8 MBPS, 15 times 1.9 MBPS and 5 times at 2 MBPS. If you average all these samples you would be billed at whatever the price is in your contract for 1.395 MBPS bandwidth.
(20*0.1 + 30*1.5 + ... + 5*2)/100 = 1.395
Looks like the standard definition for a (weighted) average...
I have a stream of data that trends over time. How do I determine the rate of change using C#?
It's been a long time since calculus class, but now is the first time I actually need it (in 15 years). Now when I search for the term 'derivatives' I get financial stuff, and other math things I don't think I really need.
Mind pointing me in the right direction?
If you want something more sophisticated that smooths the data, you should look into a a digital filter algorithm. It's not hard to implement if you can cut through the engineering jargon. The classic method is Savitzky-Golay
If you have the last n samples stored in an array y and each sample is equally spaced in time, then you can calculate the derivative using something like this:
deriv = 0
coefficient = (1,-8,0,8,-1)
N = 5 # points
h = 1 # second
for i range(0,N):
deriv += y[i] * coefficient[i]
deriv /= (12 * h)
This example happens to be a N=5 filter of "3/4 (cubic/quartic)" filter. The bigger N, the more points it is averaging and the smoother it will be, but also the latency will be higher. You'll have to wait N/2 points to get the derivative at time "now".
For more coefficients, look here at the Appendix
https://en.wikipedia.org/wiki/Savitzky%E2%80%93Golay_filter
You need both the data value V and the corresponding time T, at least for the latest data point and the one before that. The rate of change can then be approximated with Eulers backward formula, which translates into
dvdt = (V_now - V_a_moment_ago) / (T_now - T_a_moment_ago);
in C#.
Rate of change is calculated as follows
Calculate a delta such as "price minus - price 20 days ago"
Calculate rate of change such as "delta / price 99 days ago"
Total rate of change, i.e. (new_value - original_value)/time?