reference request – Counting number of distinct eigenvalues

Let $Omega$ be a Lipschitz domain in $mathbb{R}^n$, and let $N(lambda)$ be the number of Dirichlet Laplacian eigenvalues less than or equal to $lambda$. The famous Weyl’s law says that as $lambda$ goes to infinity, the asymptotic growth of $N(lambda)$ is like $C(n)|Omega|lambda^{frac{n}{2}}$, where $C(n)=(2pi)^{-n}omega_n$, $omega_n$ is the volume of the unit ball in $mathbb{R}^n$.

Note that in the definition of $N(lambda)$, the multiplicity of Dirichlet eigenvalues have been considered. How about Weyl’s law for the number of distinct eigenvalues? More precisely, let $N_d(lambda)$ be the number of distict Dirichlet Laplacian eigenvalues less than or equal to $lambda$. What is the growth rate of $N_d(lambda)$? Are there any references?

Google sheet formula on counting categorized data

So I have lists of items. Each items belong to different groups. And then I have data of people who has the items. And I want to count how many items of each group that person has.

For example, I have A, B, C, and D.
A and B belongs to group 1.
C belongs to group 2.
D belongs to group 3.

So I have 2 items of group 1, 1 item of group 2, and 1 item of group 3. And I have 4 items in total.

Here are the sheet for a better understanding.

Please help me because I cant figure out what the exact keyword I should search for nor do I know about advanced formulas since I’m really a newbie at this. Thank you.

java – Counting uppercase and lowercase characters in a string

I created two programs (one with JAVA8) to calculate the total count of uppercase and lowercase characters in given String. After checking the execution time JAVA8 is taking longer execution time than expected. Is there any possible way to optimize any of these code more to reduce execution time and complexity?

Code:

import java.io.BufferedReader;
import java.io.InputStreamReader;
public class Counts
{
    public static void main(String arg())throws Exception
    {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int upperCase=0, lowerCase=0;
        String str=br.readLine();
        Long startTimeMemo = System.nanoTime();
        for (int k = 0; k < str.length(); k++) {
     // Check for uppercase letters.
        if (Character.isUpperCase(str.charAt(k))) upperCase++;
     // Check for lowercase letters.
        if (Character.isLowerCase(str.charAt(k))) lowerCase++;
        }

     System.out.printf("%d uppercase letters and %d lowercase letters.",upperCase,lowerCase);
     Long stopTimeMemo = System.nanoTime();
     System.out.println("");
     System.out.println("Memoization Time:" + (stopTimeMemo - startTimeMemo));
    }
 } 

JAVA8 Code:

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Count2
{
    public static void main(String arg())throws Exception
    {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str = br.readLine();
        Long startTimeMemo = System.nanoTime();
        System.out.println(countUpperCase(str) + " " + countLowerCase(str));    
        Long stopTimeMemo = System.nanoTime();
        System.out.println("");
        System.out.println("Memoization Time:" + (stopTimeMemo - startTimeMemo));
    }
    private static long countUpperCase(String s) {
    return s.codePoints().filter(c-> c>='A' && c<='Z').count();
}

private static long countLowerCase(String s) {
    return s.codePoints().filter(c-> c>='a' && c<='z').count();
}
}

statistics – Anydice: Counting Successes and Rerolling Failures In Dice Pools

The issue you’re running into here is that AnyDice loves summing numbers, especially when outputing. The output you’re getting is the sum of the dice, not the number of successes (hence going up to 60). The easiest way around this, is to have the function work out the number of successes, which we can handily do by comparing our ROLL sequence to our TARGET number. Also handily, to not have to worry about actually shuffling around the sequence to get the reroll, we can simply add the new roll and subtract a 1 (to compensate for the roll that should be removed). We also know that if we don’t reroll, we have no successes. The resulting function then becomes:

function: reroll greatest of ROLL:s as REROLL:n if greater than TARGET:n {
   if 1@ROLL >= TARGET {
      result: (ROLL >= TARGET) + (REROLL >= TARGET) -1
   } else {
      result: 0
   }
}

Which we can test over a range of targets (you’ll want to limit the number in that range so it doesn’t time out):

loop N over {10,12,14,16,18,20} {
  output (reroll greatest of 3d20 as 1d20 if greater than N) named "(N)"
}

And see the transposed graph to see how the probability of a given number of sucesses vary with the target.

enter image description here

dnd 5e – Do multiple sources of counting as one size larger for carrying capacity stack?

As you know, Powerful Build and the Bear totem ability stack. For the same reasons, Brawny and the Bear totem ability also stack. However, Brawny and Powerful Build won’t stack.

You count as if you were one size larger for the
purpose of determining your carrying capacity.

Your size is Medium. When you get Powerful Build, you count as Large for the purpose of determining your carrying capacity. Then, when you get Brawny, you are still Medium, and you count as Large for the purpose of determining your carrying capacity again.

If you had found a way to actually become Large, Brawny or Powerful Build would make you count as Huge for the purposes of carrying capacity, but as long as you’re still Medium, the best either of them can do is make you count as Large for the purposes of carrying capacity.

co.combinatorics – Counting families of subsets of a fixed finite set closed under taking subsets

Let’s fix a finite set $E, #E = n$. I am interested in families $cal S$ of subsets of $E$ with the property that if $A in {cal S}$ and $B subset A$ then $B in {cal S}$. My question is: How many such families are there? I’d be happy with a reasonable upper estimate. Bonus if you can estimate the number of such $cal S$ with fixed $#{cal S}$.

(By the way, does this property have a name? It occurs in one possible definition of a matroid but being a matroid is a stronger condition. Do we know how many matroids with a fixed ground set are there?)

algorithms – Counting primitive operations on recursive functions

I’m reading Algorithm Design and Applications, by Michael T. Goodrich and Roberto Tamassia, published by Wiley. They teach the concept of primitive operations and how to count then in a given algorithm. Everything was clear to me until the moment they showed a recursive function (a simple recursive way to calculate the maximum value of an array) and its primitive operation count.

The function (in pseudo-code) is this:

Algorithm recursiveMax(A, n):
    Input: An array A storing n ≥ 1 integers.
    Output: The maximum element in A.
    
    if n = 1 then
        return A(0)
    return max{recursiveMax(A, n − 1), A(n − 1)}

where A is an array and n its length. The author states what follows concerning how we calculate the number of primitive operations this function has:

As with this example, recursive algorithms are often quite elegant. Analyzing
the running time of a recursive algorithm takes a bit of additional work, however.
In particular, to analyze such a running time, we use a recurrence equation, which
defines mathematical statements that the running time of a recursive algorithm must
satisfy. We introduce a function T (n) that denotes the running time of the algorithm
on an input of size n, and we write equations that T (n) must satisfy. For example,
we can characterize the running time, T (n), of the recursiveMax algorithm as T(n) = 3 if n = 1 or T(n – 1) + 7 otherwise, assuming that we count each comparison, array reference, recursive call, max calculation, or return as a single primitive operation. Ideally, we would like to characterize a recurrence equation like that above in closed form, where no references to the function T appear on the righthand side. For the recursiveMax algorithm, it isn’t too hard to see that a closed form would be T (n) = 7(n − 1) + 3 = 7n − 4.

I can clearly understand that in the case of a single item array, our T(n) would be just 3 (only 3 primitive operations will occur, i.e. the comparision n = 1, the array index A(0) and the return operation), but I cannot understand why in the case where n is not 1 we have T(n-1) + 7. Why + 7? From where did we get this constant?

Also, I cannot comprehend this closed form: how did he get that T(n) = 7(n – 1) + 3?

I appreciate any help.

algorithms – Counting primitive operations on recursive functions

I’m reading Algorithm Design and Applications, by Michael T. Goodrich and Roberto Tamassia, published by Wiley. They teach the concept of primitive operations and how to count then in a given algorithm. Everything was clear to me until the moment they showed a recursive function (a simple recursive way to calculate the maximum value of an array) and its primitive operation count.

The function (in pseudo-code) is this:

Algorithm recursiveMax(A, n):
    Input: An array A storing n ≥ 1 integers.
    Output: The maximum element in A.
    
    if n = 1 then
        return A(0)
    return max{recursiveMax(A, n − 1), A(n − 1)}

where A is an array and n its length. The author states what follows concerning how we calculate the number of primitive operations this function has:

As with this example, recursive algorithms are often quite elegant. Analyzing
the running time of a recursive algorithm takes a bit of additional work, however.
In particular, to analyze such a running time, we use a recurrence equation, which
defines mathematical statements that the running time of a recursive algorithm must
satisfy. We introduce a function T (n) that denotes the running time of the algorithm
on an input of size n, and we write equations that T (n) must satisfy. For example,
we can characterize the running time, T (n), of the recursiveMax algorithm as T(n) = 3 if n = 1 or T(n – 1) + 7 otherwise, assuming that we count each comparison, array reference, recursive call, max calculation, or return as a single primitive operation. Ideally, we would like to characterize a recurrence equation like that above in closed form, where no references to the function T appear on the righthand side. For the recursiveMax algorithm, it isn’t too hard to see that a closed form would be T (n) = 7(n − 1) + 3 = 7n − 4.

I can clearly understand that in the case of a single item array, our T(n) would be just 3 (only 3 primitive operations will occur, i.e. the comparision n = 1, the array index A(0) and the return operation), but I cannot understand why in the case where n is not 1 we have T(n-1) + 7. Why + 7? From where did we get this constant?

Also, I cannot comprehend this closed form: how did he get that T(n) = 7(n – 1) + 3?

I appreciate any help.

Can counting semaphore cause race conditions?

There exists a semaphore, and semaphore can be used as “Binary semaphore” and “Counting semaphore” which is classified by initial value. I understand binary semaphore can prevent race condition by acting similarly as mutex(but two are not the same by various reasons.) and their uses are slightly different.

What i am curious about is that when we initialize the semaphore’s value of more than or equal to 2, let’s say n, then n processes/threads can enter the critical session. Then does this use of semaphore cause race condition?

I read articles about counting semaphores and it is considered that they are considered to keep track of the access to resources, and I’m confused about do we not use counting semaphore like this, and is counting semaphore not used to solve concurrency problems?

For example, when there are 100 threads, and I initialize X=10, then initialize semaphore with sem_init(&s, 0, X), and if there is a critical session in threads’ code flow, then doesn’t it induce race condition because 10 threads are allowed to use resources and do through the threads’ flow?

I asked same question on stack-overflow and the comments said stack-exchange seems to be a better place for this subject, so the contents overlap. If this is considered duplicate of question, I’ll delete it.

Thank you!

number theory – Counting zeros of list from Twin Primes calculation

twinPs(n_) = If((Prime(n + 1) - Prime(n)) == 2, {Prime(n), Prime(n + 1)}, 0)
alst = Table(twinPs(x), {x, 41})

{0, {3, 5}, {5, 7}, 0, {11, 13}, 0, {17, 19}, 0, 0, {29, 31}, 0, 0, 
{41, 43}, 0, 0, 0, {59, 61}, 0, 0, {71, 73}, 0, 0, 0, 0, 0, {101, 103}, 
0, {107, 109}, 0, 0, 0, 0, {137, 139}, 0, {149, 151}, 0, 0, 0, 0, 0,  
{179, 181}}

How to make a count zeros list. ie. Return the length of a gap between successive pairs of twin primes?

answer = {1,1,1,2,2,3,2,5,1,4,1,5}