Number of samples for doing FFT - fft

I have a set of 10006 samples which resembles 10 period s of a 50 hz signal which is sampled with 50 KHZ.
as you know the freqeuncy of bins are calculated via SF/N where SF is sampling frequency and N is the number of samples.
I want to have the magnitudes of the frequency in integer multiples of 5 HZ up to 9 KHZ (for example: 5 , 10 , ..., 1025, 1030...,8000, 80005..9000).
so if I do the fft with 10006 samples my frequency bins are not any more the integer multiples of 5 and instead they are integer multiples of 50000/10006.
and if I truncate my samples then i will have integer multiples of 5 Hz bins but my samples are not any more resembling exactly 10 periods which means I have leakge effec !
so I am wondering how to have exactlu 5 HZ bins and with out having the spectrum distorted by leakage effect ?!!

You can truncate and then window to reduce "leakage" effects. Or zero-pad to 20k points without windowing and resample the FFT result.

Related

INT type in SQL max value calculation

I am currently learning SQL.
When looking at the INT, I came to the understanding that an INT type is 4 bytes long, which translates to 8 bits each byte, leading to each INT being 32 bits.
However, for INT it is said that the max value for unsigned types is (2^32)-1 where the -1 is accounting for 0 value. I understand that the 32 comes from the fact that each int is 32 bits.
My question is where does the 2 come from in the calculation?
My intuition is telling me that each bit will have some sort of measure valued at 2.
int is actually a signed value in SQL. The range is from -2^31 through 2^31 - 1, which is -2,147,483,648 to 2,147,483,647. There are exactly 2^32 possible values in tis range. Note that it includes 0.
An unsigned integer would range from 0 to 2^32-1, that is up to 4,294,967,295. The - 1s are because 0 is included in the range, so the counting starts at 0 rather than 1.
The range of possible values is easily seen at with fewer bits. For instance, 3 bits can represent the values from -4 to 3:
Bits Unisgned Signed
000 0 0
001 1 1
010 2 2
011 3 3
100 4 -4
101 5 -3
110 6 -2
111 7 -1
Computers use binary system for storing values. Let's try analogy between binary and decimal system:
Consider 10-based (decimal) system. If You have number with 32 decimal places, every place having value 0-9, You have 10^32 possible values (obviously enough; we use this system on daily basis).
Now consider 2-based system, which is the one used by computers (for practical reasons - two states are easiest to distinguish and wiring logic is simplest). Every place (bit) has value 0-1, so there are 2^32 possible values.

cusparse sparse-dense multiplication x4 larger cost over x100 more time

Using cusparse, I first tried a sparse-dense multiplication with the following sizes:
C1 [8692 x 8692] = A1 [8692 x 7000 sparse] x B1 [7000 x 8692]
It takes only 0.3 seconds. Then I did another one with the following sizes:
C2 [8820 x 8820] = A2 [8820 x 32000 sparse] x B2 [32000 x 8820]
The time it takes varies depending on what's in the sparse matrix, but it ranges from 30 seconds to 90 seconds. Is there anything I can do to accelerate it? I can chop the matrices in different ways if that can reduce the running time, but I'm not sure what the performance issues are here.
The sparse matrices A1 and A2 are stored in CSR formats and they do have a bad sparsity pattern, but they are equally bad. The two figures below show where the non-zero elements are in A1 and A2 respectively. The non-zero elements per column in both cases are controlled to be fixed at 127.
From the sparsity pattern of the matrix, you should split the matrix A1 in 2 parts with a matrix A11 containing about the first 8000 rows and A12 the remaining rows and use the csrmv twice. This way, cusparse will choose a better heuristic for the numbers of threads per row.
You should also consider using the new version in CUSPARSE 6.0 csrmv2 with the transpose case . You would need to transpose B first ( using cublasgeam ) and do :
C = A1 * (B')'
The transpose case is much better because the access to B are all coalesced.
Another option would be to densify A1 ( using cusparsecsr2dense ) and use cublas

How many Bits were used?

Assume a simple machine uses 4 bits to represent it instruction set. How many different instruction can this machine have? How many instruction could it have if eight bit are used? How many if 16 bits are used?
Sorry with the homework theory.. I didnt know how else to put it.. thanks
A bit can have two values: 0 or 1.
How many unique values are there of no bits? Just one. I'd show it here, but I don't know how to show no bits.
How many unique values are there of one bit? Two: 0 1
How many unique values are there of two bits? Four: 00 01 10 11
How many unique values are there of three bits? Eight: 000 001 010 011 100 101 110 111
Notice anything? Each time you add another bit, you double the number of values. You can represent that with this recursive formula:
unique_values(0) -> 1
unique_values(Bits) -> 2 * unique_values(Bits - 1)
This happens to be a recursive definition of "two to the power of," which can also be represented in this non-recursive formula:
unique_values = 2 ^ bits # ^ is exponentiation
Now you can compute the number of unique values that can be held by any number of bits, without having to count them all out. How many unique values can four bits hold? Two to the fourth power, which is 2 * 2 * 2 * 2 which is 16.
It's 2 to the power "bits". So
4 bits = 16 instructions
8 bits = 256 instructions
16 bits = 65536 instructions
You can have 2 raised to the power of the number of bits (since each bit can be 1 or zero). E.g. for the 4 bit computer: 2^4 = 16.

Calculating the total number of possibilities in binary?

How would you calculate the total number of possibilities that binary can have in one byte?
00000000 through 11111111 = num_of_possibilities
The total number is 2 to the power of the number of bits. So, eight bits has 28 possible values.
If you really mean "how to compute it", consider that each bit has two possible values.
So one bit implies 2 values.
Two bits has one set of two values of each possible value of the other bit, so
00
01
10
11
which means a total of 4 (= 2×2) values.
Three bits gives four values twice, or 8 (=4×2) values. Four bits, 8×2; five bits, 16×2, and so on.
So eight bits is 2×2×2×2×2×2×2×2 or 256.
It is a simple question: The number of possibilities is 2n where n is the number of bits.
So for 1 byte, which is 8 bits, there are 28 possibilites, 256.
There are several methods:
2^n where n is the number of bits (2^8) Each bit has 2 possibilities.
Unsigned value of all 1's + 1 (255 + 1) Count up from 0 to max value (all ones) + zero.
Build a tree where each leaf is the sum of the values to right and left of the new value from the row above. Possibilities is sum of row having n+1 entries. (2 ( 1 + 8 + 28 + 56 ) + 70) Each value is probability of that number of bits from 0 to n.

Quality Measurement

Suppose we are using DPMO system of quality and if a person has done 100 points and the opportunity is 9 and the person has got 10 qfails out of 70 as 70 transaction got selected for quality audit, then what would be the formula of measuring his quality by DPMO system ? 10 errors , 100 transactions , 9 opportunity per transaction, transaction QC'd 70?
DPMO = (1,000,000 * number of defects)/(number of units * number of opportunities)
What does that give you?