Anova reject null hypothesis but T-test accept null hypothesis - anova

I tested my data using anova and the result is reject the null hypothesis, meaning that there are significance in my data. So, I tested the same data again using T-test but it then the result said that the null hypothesis is accepted. My data has 3 column (a, b and c). Is it logic for the result to show like that? anova rejected null hypothesis and t test accepted the null hypothesis? If it is logic, how should i conclude the result? I'm using 90% confidence interval.
For anova test :
F stats = 28126.8
P-value = 0
F crit = 1.42693
For T-test :
a vs b
t stat = 0.44965721
P two tail = 0.964191412
t crit two tail = 1.654554875
a vs c
t stat = -0.508842709
P two tail = 0.611586028
t crit two tail = 1.654743774
b vs c
t stat = -0.552393274
P two tail = 0.581474613
t crit two tail = 1.654743774

Related

What are the logical and arithmetical functions from the 74LS181

i want to use the 74ls181 in an Project of mine but i can not understand all of the functions of it mentioned in its datasheet.
Could someone please explain this boolean-mess?
EDIT:
Based on the very helpful answer from Axel Kemper i created this:
Your table was taken from the Texas Instruments 74ls181 datasheet?
Assuming from your question tags that you are asking about the logical functions
(explained from top to bottom as in the table):
F = NOT(A) set output to inverse of all A bits
F = NAND(A, B) inverse AND of inputs
F = OR(NOT(A), B)
F = 1 set all output bits to 1
F = NOR(A, B)
F = NOT(B) feed inverse B bits to output
F = NOT(EXOR(A, B))
F = OR(A, NOT(B))
F = AND(NOT(A), B)
F = EXOR(A, B) output is exclusive or of inputs
F = B feed B inputs bits to outputs
F = OR(A, B) bitwise disjunction
F = 0 set all output bits to 0
F = AND(A, NOT(B))
F = AND(A, B) bitwise conjuction
F = A
All functions are implemented 4-bit parallel.
A, B and F each have four signal lines.
A and B are the four-bit inputs. F is the four-bit output.
So, A=0 for example means A0=0, A1=0, A2=0, A3=0
There is a total of 16 different logical functions possible to implement with two inputs and one output. 74ls181 implements all of them.
A truth-table with two inputs and one output has four rows.
Each of the rows has output value 0 or 1. Therefore, a four-bit number defines the function described by the truth-table.
With four bits, 16 functions are possible.
There is a very instructive YouTube video available on the 74ls181.

How to determine if true/false and then return a function

I have truth tables for different logical operators;
truthtable a1
| a1 == "mynot" = [(p,q,r,s) | p <- [0,1], q <- [0,1], let r = mynot p, s <- ["mynot"]]
| a1 == "myand" = [(p,q,r,s) | p <- [0,1], q <- [0,1], let r = myand p q, s <- ["myand"]]
| a1 == "myor" = [(p,q,r,s) | p <- [0,1], q <- [0,1], let r = myor p q, s <- ["myor"]]
| a1 == "myimply" = [(p,q,r,s) | p <- [0,1], q <- [0,1], let r = myimply p q, s <- ["myimply"]]
Now I have to make a function (equiv) that determines if two operators act the same and give a counter example if not. So for equiv "myimply" "myimply" it should determine that it is equivalent, but for equiv "myimply" "myor" it should call the function counterEx which gives a counterexample (that the operators are not the same).
Now I had this:
equiv a1 a2
| truthtable a1 == truthtable a2 = True
| otherwise = counterEx a1 a2
counterEx a1 a2 = truthtable a1 ++ truthtable a2
But of course, equiv has different outcomes and thus is not possible. However I don't really know how I can give a better counter example (than just give all possibilities and you would just look what is not the same). As well I don't really know how I can call the function counterEx if the truth tables are not equivalent but only determine that they are the same if the truth tables really are the same.
The most idiomatic solution here is to use a custom return data type
type TTable = [(Int,Int,Int,Int)]
data EquivResult
= Equivalent
| NotEquivalent TTable
equiv :: TTable -> TTable -> EquivResult
equiv a1 a2
| truthtable a1 == truthtable a2 = Equivalent
| otherwise = NotEquivalent (counterEx a1 a2)
One can also use Maybe TTable instead of defining a custom EquivResult, but it is less obvious that Nothing would mean "equivalent", and Just _ would mean "_ is a counterexample".
equiv :: TTable -> TTable -> Maybe TTable
equiv a1 a2
| truthtable a1 == truthtable a2 = Nothing
| otherwise = Just (counterEx a1 a2)
By the way, why do you use the integers 0 and 1 for booleans? Why not False and True of type Bool. Using Int for booleans feels weird, and allows invalid values like 2.
(As a general recommendation, I would suggest to start writing each function by declaring its type. Type signatures are very important to detect potential errors soon, and to help the compiler to produce better error messages.)

Order-dependant Bit Fields

How would one go about storing positional information in bit fields (the order in which the fields are OR'd or otherwise)?
Background: It popped into my head last night while writing a part of my game engine. Let's say that we are trying to describe a colour, and as part of that we have the colours that are present in the descriptor (and their order). For example we have the following colour orders on most graphics cards today:
RGBA
BGRA
The following flags can be used to describe colours that are supported:
None = 0x0
A = 0x1
R = 0x2
G = 0x4
B = 0x8
However, by using those fields A | R | G | B is the same thing as B | G | R | A. How would you design the flags and/or operations that can be used to add positional dependence? Bonus marks for adding exclusivity (you can't have R and G in position 1, for example) and for utility (some clever way that it could be used, possibly in this case scenario).
You can shift the bit field before adding each flag, by the number of bits required for each unique flag. The following flags would be used:
None = 0x0
A = 0x1
R = 0x2
G = 0x4
B = 0x8
Shift = 0x4
Mask = 0xF (A | R | G | B)
On a little-endian system you would shift it left by Shift (<<) before each OR. The shift left on None can be eliminated because 0 << x = 0. Given the original example:
A1 = A
A1R2 = (A1 << Shift) | R
A1R2G3 = (A1R1 << Shift) | G
A1R2G3B4 = (A1R1G3 << Shift) | B
B1 = B
B1G2 = (B1 << Shift) | G
B1G2R3 = (B1G2 << Shift) | R
B1G2R3A4 = (B1G2R3 << Shift) | A
To extract the position of each you would repeatedly shift it right (little-endian) and AND it with Mask. Repeating this until the current value reaches None would give you the reverse order.
let cur = the bit field we want to check
loop until cur = None:
let val = cur AND Mask
emit the name of val
let cur = cur >> Shift
This does not offer exclusivity (you can easily do a AAGB) and it doesn't look like it has any utility.

Reducing a boolean expression

I am having an expression, suppose,
a = 1 && (b = 1 || b != 0 ) && (c >= 35 || d != 5) && (c >= 38 || d = 6)
I expect it to be reduced to,
a = 1 && b != 0 && (c >= 38 || d = 6)
Does anyone have any suggestions? Pointers to any algorithm?
Nota Bene: Karnaugh Map or Quine-McCluskey are not an option here, I believe. As these methods don't handle grey cases. I mean, expression can only be reduced as far as things are like, A or A' or nothing, or say black or white or absense-of-colour. But here I'm having grey shades, as you folks can see.
Solution: I have written the program for this in Clojure. I used map of a map containing a function as value. That came pretty handy, just a few rules for a few combinations and you are good. Thanks for your helpful answers.
I think you should be able to achieve what you want by using Constraint Handling Rules. You would need to write rules that simplify the OR- and AND-expressions.
The main difficulty would be the constraint entailment check that tells you which parts you can drop. E.g., (c >= 35 || d != 5) && (c >= 38 || d = 6) simplifies to (c >= 38 || d = 6) because the former is entailed by the latter, i.e., the latter is more specific. For the OR-expressions, you would need to choose the more general part, though.
Google found a paper on an extension of CHR with entailment check for user-defined constraints. I don't know enough CHR to be able to tell you whether you would need such an extension.
I believe these kinds of things are done regularly in constraint logic programming. Unfortunatly I'm not experienced enough in it to give more accurate details, but that should be a good starting point.
The general principle is simple: an unbound variable can have any value; as you test it against inequalities, it's set of possible values are restricted by one or more intervals. When/if those intervals converge to a single point, that variable is bound to that value. If, OTOH, any of those inequalities are deemed unsolvable for every value in the intervals, a [programming] logic failure occurs.
See also this, for an example of how this is done in practice using swi-prolog. Hopefully you will find links or references to the underlying algorithms, so you can reproduce them in your platform of choice (maybe even finding ready-made libraries).
Update: I tried to reproduce your example using swi-prolog and clpfd, but didn't get the results I expected, only close ones. Here's my code:
?- [library(clpfd)].
simplify(A,B,C,D) :-
A #= 1 ,
(B #= 1 ; B #\= 0 ) ,
(C #>= 35 ; D #\= 5) ,
(C #>= 38 ; D #= 6).
And my results, on backtracking (line breaks inserted for readability):
10 ?- simplify(A,B,C,D).
A = 1,
B = 1,
C in 38..sup ;
A = 1,
B = 1,
D = 6,
C in 35..sup ;
A = 1,
B = 1,
C in 38..sup,
D in inf..4\/6..sup ;
A = 1,
B = 1,
D = 6 ;
A = 1,
B in inf.. -1\/1..sup,
C in 38..sup ;
A = 1,
D = 6,
B in inf.. -1\/1..sup,
C in 35..sup ;
A = 1,
B in inf.. -1\/1..sup,
C in 38..sup,
D in inf..4\/6..sup ;
A = 1,
D = 6,
B in inf.. -1\/1..sup.
11 ?-
So, the program yielded 8 results, among those the 2 you were interested on (5th and 8th):
A = 1,
B in inf.. -1\/1..sup,
C in 38..sup ;
A = 1,
D = 6,
B in inf.. -1\/1..sup.
The other were redundant, and maybe could be eliminated using simple, automatable logic rules:
1st or 5th ==> 5th [B == 1 or B != 0 --> B != 0]
2nd or 4th ==> 4th [C >= 35 or True --> True ]
3rd or 1st ==> 1st ==> 5th [D != 5 or True --> True ]
4th or 8th ==> 8th [B == 1 or B != 0 --> B != 0]
6th or 8th ==> 8th [C >= 35 or True --> True ]
7th or 3rd ==> 3rd ==> 5th [B == 1 or B != 0 --> B != 0]
I know it's a long way behind being a general solution, but as I said, hopefully it's a start...
P.S. I used "regular" AND and OR (, and ;) because clpfd's ones (#/\ and #\/) gave a very weird result that I couldn't understand myself... maybe someone more experienced can cast some light on it...

HowTo: select all rows in a cell array, where a particular column has a particular value

I have a cell array, A. I would like to select all rows where the first column (for example) has the value 1234 (for example).
When A is not a cell array, I can accomplish this by:
B = A(A(:,1) == 1234,:);
But when A is a cell array, I get this error message:
error: binary operator `==' not implemented for `cell' by `scalar' operations
Does anyone know how to accomplish this, for a cell array?
The problem is the expression a(:,1) == 1234 (and also a{:,1} == 1234).
For example:
octave-3.4.0:48> a
a =
{
[1,1] = 10
[2,1] = 13
[3,1] = 15
[4,1] = 13
[1,2] = foo
[2,2] = 19
[3,2] = bar
[4,2] = 999
}
octave-3.4.0:49> a(:,1) == 13
error: binary operator `==' not implemented for `cell' by `scalar' operations
octave-3.4.0:49> a{:,1} == 13
error: binary operator `==' not implemented for `cs-list' by `scalar' operations
I don't know if this is the simplest or most efficient way to do it, but this works:
octave-3.4.0:49> cellfun(#(x) isequal(x, 13), a(:,1))
ans =
0
1
0
1
octave-3.4.0:50> a(cellfun(#(x) isequal(x, 13), a(:,1)), :)
ans =
{
[1,1] = 13
[2,1] = 13
[1,2] = 19
[2,2] = 999
}
I guess the Class of A is cell. (You can see in the Workspace box).
So you may need to convert A to the matrix by cell2mat(A).
Then, just like Matlab as you did: B = A(A(:,1) == 1234,:);
I don't have Octave available at the moment to try it out, but I believe that the following would do it:
B = A(A{:,1} == 1234,:);
When dealing with cells () returns the cell, {} returns the contents of the cell.