How to calculate cache miss time?

You have an L1 data cache, L2 cache, and main memory. The hit rates and hit times for each are: 50% hit rate, 2 cycle hit time to L1. 70% hit rate, 15 cycle hit time to L2. 100% hit rate, 200 cycle hit time to main memory.

1) What is the miss rate and miss time for the L2 cache?

Answer: Miss rate: 100% – 70% = 30% ; Miss time is 200 cycle.

2) What is the miss rate and miss time for the L1 cache? (Hint: depends on previous answer).

Miss rate: 100%-50%=50%

I understand how we find miss rates. However, how do we calculate the miss time of L1 cache ?

Calculate occluded parts for planet like object

enter image description here

So I have camera position, planet position, radius and coordinates for every side (node) corners and I want to hide side that is beyond horizon (with some safety margins). I think I could easily calculate in 2D using trigonometry, but in 3D have no idea right now. I found some code online:

TileNode.prototype.isWithinHorizon = function () {   var r = this.master.getRadius();   var camToTile = this.master.getCamToTile(this);   var camToCenter = this.master.getCamToCenter();    var camDistToCenter = camToCenter.length();   var dotCtCc = camToTile.dot(camToCenter.divideScalar(camDistToCenter));    return dotCtCc - this.scale*0.5 < (camDistToCenter - r*r/camDistToCenter); }; 

but can’t make sense of it, as it is not commented. Any help appreciated!

P.S. i hope i use the term “occluded” right here

Is there a spell, magical item, or any other method to accurately calculate how long ago an object/construct was created?

I’m interested in D&D 5e but I will also accept answers from previous D&D versions as well as similar systems (e.g., Pathfinder 1e/2e).


Janathiel II, famous historian, cartographer, and the Grand Wizard of Whitescar is studying the ancient structures of Ær-Toril known as Rhas.

These are gigantic and ancient structures/areas that cannot possibly have been created by nature. For example, Rhas Nolh is an almost perfect mountain pass that spans more than 100 kilometres, Rhas Aldhaen is an ancient forest that does not age (i.e., each tree is forever the same), etc.

Janathiel II has a theory: All of the Rhas constructs were created approximately during the same time period/era possibly by a technologically/magically advanced civilization.

To test this theory, however, he needs an accurate way of measuring how old an object is. Even worse, this method should be accurate even when counting thousands of years (if not hundreds of thousands).

If Janathiel II was living on Earth during the 21st century he could have used radiocarbon dating, but unfortunately for him, he lives in Ær-Toril.

Is there a spell, magical item, or any other method Janathiel II can use to accurately calculate how long ago an object/construct was created?

How do you calculate a warforged barbarian’s AC?

I am looking at the warforged AC calculation from the Integrated Protection feature, looking only at Darkwood Core (unarmored), for a possible warforged barbarian. (I am using the version of the warforged race from the Wayfinder’s Guide to Eberron.)

Darkwood Core says:
11 + your Dexterity modifier (add proficiency bonus if proficient with light armor)

What I want: Darkwood Core + Con
What I’m expecting: 11 + Dex + Con

Would this option be able to coincide with the Unarmored Defense for the Barbarian, or is this a case of conflicting Armor Classes?

Given a regular language, calculate its equivalence classes

I was given the following regular language:

For any $ n$ , the language $ L_{n}$ consists of all words over $ Σ = \{0, 1\}$ whose $ n$ th character from the end is 1.

I know it’s regular because it can be expressed as a regular expression ($ \Sigma^{*}1\Sigma^{n-1}$ ), and I constructed a DFA and an NFA for it. I need to calculate its equivalence classes. I thought that the equivalence classes will be words that have 1 in the same place later in the word – for example one of the classes will be $ L(\Sigma^{*}1\Sigma^{n-2})$ , because no matter what digit will be added to all these words, the new words will belong to the original language. But I’m not sure I’m on the right track. I would love it if I could understand the process of thinking on this kind of question.

Calculate the number of combinations of a sequence of numbers in a particular order

I have a problem solving coding challenge when I have to calculate the number of combinations, numbers from 0 to 9, with the length n, with 2 rules –

The first number cannot be 0

Every other number can be 0 or must be divisible by the previous number (number 1 can not be used as divisor), for example [5.0], [1,0] or [2,8], [4,8], [3,6]

For example, if the length n were 2, number of combinations would be 21 – [1,0]…[9,0] + [2,4], [2,6], [2,8], [3,6], [3,9], [4,8] + [2,2]…[9,9]


The resulting response can be code in some programming language or a formula to calculate answer

Cannot calculate Conv1D backprop gradients correctly

I’m a beginner trying to understand the backpropogation for Conv1D. I’m implementing it and comparing my gradients with pytorch’s gradients. However, the backprop step seems to be wrong. I have posted the full implemented class.

class Conv1D:     def __init__(self, input_channel, output_channel, kernel_size, stride):         self.input_channel = input_channel         self.output_channel = output_channel         self.kernel_size = kernel_size         self.stride = stride         self.W = np.random.normal(0, 1, [output_channel, input_channel, kernel_size])         self.b = np.random.normal(0, 1, [output_channel])         self.dW = np.zeros(shape=self.W.shape)         self.db = np.zeros(shape=self.b.shape)         self.dx = np.zeros(shape=self.b.shape)         self.input = np.array([])      def forward(self, x):         output_width = int(np.floor(len(x[0][0])-self.kernel_size)/self.stride) + 1         y = np.zeros(shape=[len(x), self.output_channel, output_width])         self.input = np.copy(x)         for i in range(len(x)):             for j in range(self.output_channel):                 k_ = 0                 for k in range(output_width):                     input_piece = x[i, :, k_:k_+self.kernel_size]                     y[i][j][k] = np.sum(np.multiply(input_piece, self.W[j])) + self.b[j]                     k_ += self.stride         return y      def backward(self, dl):         output_width = int(np.floor(len(dl[0][0])-self.kernel_size)/self.stride) + 1         self.dW = np.zeros(shape=self.W.shape)         self.db = np.zeros(shape=self.b.shape)         self.dx = np.zeros(shape=self.input.shape)         for i in range(len(dl)):             for j in range(self.output_channel):                 k_ = 0                 for k in range(output_width):                     input_piece = self.input[i][:, k_:k_+self.kernel_size]                     self.dx[i][:, k_:k_+self.kernel_size] += dl[i][j][k] * self.W[j]                     self.dW[j] += dl[i][j][k] * input_piece                     self.db[j] += dl[i][j][k]                      k_ += self.stride         return self.dx        def __call__(self, x):         return self.forward(x) 

I would really appreciate if someone could find my mistake.

How can I calculate the exponential integral?

(I’m not sure this is the right forum.)

I’m writing a program that uses the prime-counting function. Right now, I’m using x/log(x), but I want to switch to something more accurate. A better approximation is the logarithmic integral function (actually, its Eulerian variant), which can be computed from the exponential integral. Now how can I compute the exponential integral? I’m on a macOS Intel system using Swift, so I can use the various advanced floating-point functions provided by Apple’s system libraries if needed to help.