Saturday, December 17, 2011

What is a fixed length code?

is it i use the huffman coding to find out the binary number and assign it to the variable?





Eg.


0.3 = 00


0.25 = 01


0.25 = 10


0.2 = 11





Need help here.|||A fixed length code is a kind of channel coding that was used in earlier communication systems. The idea is simple: lets suppose you want to encode an alphabet {A1, A2, A3, ... Ak}.


A fixed length code C is a set of code words {C1,.... Ck} , all of the same number of bits, each of which encodes a specific element of the alphabet. Notice that this last property is essential to be able to decode the original message from an encoded version.





E.g. if the alphabet of messages is {A, B, C, D, E} then 3 bits suffice to represent these five elements, and you can choose the code





A = 000


B = 001


C = 010


D = 011


E = 100





one among the many possibilities of assigning unique 3-bit code words to each message.





Huffman coding is variable length, so by definition a Huffman code cannot be a fixed length code.

I have a java code problem, can someone HELP?

ok, so i had to do a project of converting binary to decimal numbers, i think i made the right code but the compiler gives me an error





import javax.swing.JOptionPane;





public class BtoD


{


public static void main(String []args)


{


String testNum = JOptionPane.showInputDialog("Enter Bianry Number");


int x = testNum.length();


int[] binary= new int [x];


for(int i=0;i%26lt;x;i++)


{


binary[i]=Integer.parseInt(testNum.鈥?br>

}


int decimalNum=0;


int y=1;


for(int i=x-1;i%26gt;=0; i--);


{


decimalNum=decimalNum+(binary[i]*y)鈥?br>

y=2*y;


}


String output=" your decimal number is" + decimalNum;


JOptionPane.showMessageDialog(null,o鈥?br>

}


}





the error it gives me is: cannot find symbol


symbol : variable i


location: class BtoD


decimalNum=decimalNum+(binary[i]*y)鈥?br>




please someone help?!








|||This is a good one, took me a minute to spot the error. The problem is in this line:





for(int i=x-1;i%26gt;=0; i--);





The semi-colon at the end, ends the line so the code within the curly braces is not part of the if statement so doesn't have access to i.

C++ inheritance, polymorphism with the overloaded<< operator?

I have base class A and subclasses B, C, and D. A has a variable in that class that B, C, and D all use. A also has another variable called type (a string) that are for B and C. D also has a variable called type (an int) that I'm trying to override polymorphically over the type variable in the base class. I have a binary search tree class that each node points to an A object For testing, I currently have one A object that was instantiated from a D object and hangs on the binary search tree as an A object with variables from D as well. I can't figure out to print the variables from D and A that it has. I can print operator%26lt;%26lt; from the subclass or superclass, but it only will print the variables from the parent class. how can I print all of my variables? Open to moving variables...|||First, member variables aren't polymorphic, functions are. D has int type;, B and C have string type;, whether A has a type or not is irrelevant. What matters is that there has to be a virtual function in A which does something different depending on run-time type of A (whether it's really B or if it's really D)



For example, that function could return printable string representation of the type:



#include %26lt;iostream%26gt;

#include %26lt;string%26gt;

#include %26lt;sstream%26gt;

class A

{

聽聽聽聽 virtual std::string gettype_as_string() const = 0;

public: virtual ~A() {}

聽聽聽聽 friend std::ostream%26amp; operator%26lt;%26lt;(std::ostream%26amp; s, const A%26amp; a)

聽聽聽聽 {

聽聽聽聽聽聽聽聽 return s %26lt;%26lt; a.gettype_as_string();

聽聽聽聽 }

};

class B : public A

{

聽聽聽聽 std::string type;

聽聽聽聽 std::string gettype_as_string() const { return type; }

public: B(const std::string%26amp; t) : type(t) {}

};

class D : public A

{

聽聽聽聽 int type;

聽聽聽聽 std::string gettype_as_string() const { std::ostringstream os; os %26lt;%26lt; type; return os.str(); }

public: D(int i) : type(i) {}

};

int main()

{

聽聽聽聽 A* d = new D(1);

聽聽聽聽 std::cout %26lt;%26lt; "A created from D(1) prints " %26lt;%26lt; *d %26lt;%26lt; '\n';

聽聽聽聽 delete d;

聽聽聽聽 A* b = new B("hi");

聽聽聽聽 std::cout %26lt;%26lt; "A created from B(\"hi\") prints " %26lt;%26lt; *b %26lt;%26lt; '\n';

聽聽聽聽 delete b;

}

Why do creationists claim gravitational time dilation makes a young earth possible?

Gravitational time dilation, if it existed on such a large scale, should be easily observable. On the contrary, we observe (from the periods of Cepheid variable stars, from orbital rates of binary stars, from supernova extinction rates, from light frequencies, etc.) that such time dilation is minor. There is some time dilation corresponding with Hubble's law (i.e., further objects have greater red shifts), but this is due to the well-understood expansion of the universe, and it is not nearly extreme enough to fit more than ten billion years into less than 10,000.





Humphreys tried to use clocks in the earth's frame of reference. But the cosmos is much older than the earth. Judging from the heavy elements in the sun and the rest of the solar system, our sun is a second-generation star at least. Billions of years must have passed for the first stars to have formed, shone, and become novas, for the gasses from those novas to have gathered into new star systems, and for the earth to form and cool in one such system. The billions of years before the earth are not accounted for in Humphreys's model.





Humphreys's theory assumes that the earth is in a huge gravity well. The evidence contradicts this assumption. If the earth were in such a gravity well, light from distant galaxies should be blue-shifted. Instead, it is red-shifted.





See Conner and Page (1998) and Conner and Ross (1999) for several other technical objections.





There is a great deal of other independent evidence that the earth is very old.





If there were any substance to Humphreys's proposal, at least some competent cosmologists would build on it and share in the Nobel Prize. Instead, they dismiss it as worthless.|||The name sounds made up in order to impress other YECs that it is true.





Rev. Neil|||Don't paint with such a wide brush ~ not every creationist believes in a young earth. Disproving the young earth theory doesn't disprove the Creator.|||Please wake me up when its over......yawn!!!!|||Because they don't understand it to the point wherein they can actually do the math and figure just what exactly gravitational time dilation would require the universe to be like physically to cause the effects they describe in the first place.





They just jump on the qualitative meaning of words and refuse to entertain the idea that just because it says X it doesn't necessarily imply "significant X for your explanatory purposes".|||They don't really try to understand the argument: anything that superficially confirms their biases is repeated without further reflection.





Unfortunately, it doesn't do much good to refute a creationist's argument because he doesn't really understand his own argument in the first place. He'll just trot out another cut-and-pasted fallacy and say, "But what about that, huh? That sounds all science-y and says evolution is wrong. Checkmate."|||I haven't heard that as much as the universe expansion rate argument (see Einsten and Hubble).


All theories assume since we can't observe. There's also a great deal of "evidence" that the earth is rather young. It all depends on the assumptions.


If we assume that there is a God for instance (even though he can't be proven by observation), then we assume it's not possible to have happened by chance. On the flip side if we assume that there is no God (again, can't be proven against by observation) then we leave no room for having a purpose here. There's always going to be assumptions, we just need to clear out as many as possible by making observations and even then we still have to assume that which we cannot observe.|||I don't claim this at all.|||I haven't heard this one before.But who cares anyway? No one takes them seriously.

Somebody HELP me with this C++ program?

I dont know what is wrong it is supposed to convert decimal to binary!


Can I declare Arrays whose number of elements is variable?


How?


This program already output


the binary equivalent but it has extra numbers


#include %26lt;iostream.h%26gt;


void main ()


{


int num,xnum,dgts,counter;


cout%26lt;%26lt;"Enter Number"%26lt;%26lt;endl;


cin%26gt;%26gt;num;


if(num%26lt;=1)


cout%26lt;%26lt;endl%26lt;%26lt;num;


else


{


xnum=num;


dgts=0;


while(xnum%26gt;=1)


{


xnum=xnum/2;


dgts+=1;


}


int bnr[50];


for (counter=0;counter%26lt;dgts;counter++)


{


bnr[counter]=num%2;


num=num/2;


}


cout%26lt;%26lt;endl%26lt;%26lt;"The number entered converted to binary is ";


while(dgts%26gt;=0)


{


dgts=dgts-1;


cout%26lt;%26lt;bnr [dgts];


}


}


}|||Everything is right in the program. Only at the end, while printing the number, you are making a mistake. The while loop should be


"while (dgts%26gt;0)" instead of while(dgts%26gt;=0).


Whats happening is at the end, when dgts = 0;





dgts = dgts -1, will make dgts = -1;


and then you are trying to access bnr[-1], which is illegal.





And certainly you can use a dynamic array, instead of static. Using dynamic arrays you can have whose number of elements is variable.





In above example instead of int bnr[50], you can simply declare int * bnr;


And then when you know how mnay elements you need, you can allocate memory as :





bnr = (int *)malloc(dgts * sizeof(int));


The rest of the program will be as it is.


Here is the entire right program, with dynamic memory.





#include %26lt;iostream.h%26gt;


void main ()


{


int num,xnum,dgts,counter;


cout%26lt;%26lt;"Enter Number"%26lt;%26lt;endl;


cin%26gt;%26gt;num;


if(num%26lt;=1)


cout%26lt;%26lt;endl%26lt;%26lt;num;


else


{


xnum=num;


dgts=0;


while(xnum%26gt;=1)


{


xnum=xnum/2;


dgts+=1;


}


int *bnr;


bnr = (int *)malloc(dgts * sizeof(int));


for (counter=0;counter%26lt;dgts;counte++)


{


bnr[counter]=num%2;


num=num/2;


}


cout%26lt;%26lt;endl%26lt;%26lt;"The number entered converted to binary is ";


while(dgts%26gt;0)


{


dgts=dgts-1;


cout%26lt;%26lt;bnr [dgts];


}


}


}|||OK, I haven't compiled your given code in my compiler, but looking at the code, and assuming that you are getting the binary equivalent, with extra digits means that your array bnr[ ] is printing out ALL the elements in it.


I suggest you first initialize the array before assigning it any value. Then, you can assign a NULL character to index after that last element of the array. This should solve the problem.


Good Luck!

PROBABILITY THAT HEADS WILLE UP WHEN a FAIR COIN IS TOSSED?

Let 惟 = {w1,w2,w3...wn} , wi is an outcome in the sample space and


X be a discrete random variable over S with probability mass function


m(w):s--%26gt;[0,1]


then 危 (wi) | i=1..n =1. where m(w3)=...m(wn)=0.


The moment generating function of X is M_X(t)=EXP(e^(tX)), t E R


=危 (wi)


Let 胃 = { }. Then w1 /\ w2 = $theta;


Corillary: EXP(X) for a random variable X over a probabilitically symmetrical, binary and uniform S.


= Pr(X=wi) for each i.


=%26gt;危 e^(tw)*m(w) , w E Z= M_X(t)


where dM(t)/dt|t=0 =EXP(X). therefore


危 w*m(w) , w E Z = 1/2*1+0*1/2=1/2


Answer = 1/2





??????????????|||Erm... right. A coin has two sides. The probability that any one side will come up is 1/2 (the required side/the number of sides), so for n tosses, the probability that it will come up the same side every time is 1/(2^n).|||You are an idiot dude. you went thru all that and you kno there are 2 sides. That means you have a 50 percent chance of gettiing 1 side.

Truth tables and input variables?

What would be the truth table of a function with 4 input variables, A,B,C,D which is 1 if the binary value of the binary number represented by the bits AB = the value of the binary number represented by the bits CD.





For example: if AB = 10 and CD = 01 then the output is 0 since 2 is greater than 1.|||A B C D R


0 0 0 0 1


0 0 0 1 0


0 0 1 0 0


0 0 1 1 0


0 1 0 0 0


0 1 0 1 1


0 1 1 0 0


0 1 1 1 0


1 0 0 0 0


1 0 0 1 0


1 0 1 0 1


1 0 1 1 0


1 1 0 0 0


1 1 0 1 0


1 1 1 1 1





A+B = C+D

IEEE-754 floating-point JAVA CODE?

How can I do this:





1. Your program will use Float.parseFloat() to convert the String into a float variable.


2. It will then map the float into the coded bits using Float.floatToIntBits() method.


3. Save this value for later use.


4. You will write the code necessary to manually parse the String into separate pieces: sign part, integer part, fractional part, and exponent part (if present) with all parts being stored in int variables.


5. You will create a binary fraction part and adjust the exponent part, as needed to create a normal form binary fraction.


6. Using the logical operators: %26amp; (and), | (or), ^ (xor), ~ (not), and %26lt;%26lt; (left shift), form an int variable which contains the proper bit configuration to represent the floating-point number you read in.


7. Compare the int value you just created with the one you saved above (step 3). They should be identical.


8. Run multiple tests to validate that your code handles all cases of valid input from the user (you may safely assume that no invalid numeric string is entered.|||Wow...... I doubt if professionals come to answer here.|||The only help I can provide, without doing the actual code is the following:





- Create a class.


- Create a method, or use the main method to do it in.


- Follow the instructions 1 at a time.


- Check the API for the return values and possible exceptions thrown for each method of the Float class.


- Implement try-catch statements if exceptions are thrown.


- When you get to 6, learn about bit wise operators.





For 8, Create another class that will test the method of the first class. That is why it is better to make it a method, rather than just using main. Of course, the method of the first class can be a static method if you want. This saves having to make a constructor, etc.





IN the test class, have several different types of tests to ensure it all works correctly.


This way, if you have to change your code in the first class, the tests will be the same, and you do not have to remember what you typed in, etc. You can also see the differences due to the changes you made.





Hope that helps.





P.S. Check out the format for the IEEE-754 floating point numbers for an indication of how the numbers are stored in the java floats.


Here is one such page:


http://steve.hollasch.net/cgindex/coding鈥?/a>


Floats are single precision, Doubles are double precision.

Opensis problem installation on shared server?

trying to install open sis on a shared server, it giving me ""This function has none of DETERMINISTIC, NO SQL, or READS SQL DATA in its declaration and binary logging is enabled (you *might* want to use the less safe log_bin_trust_function_creators variable)"" error , i also tried to set mysql%26gt; SET GLOBAL log_bin_trust_function_creators = 1; it ask for privileges ,also tried manual installation ,but no luck, any suggestions??

How to make a .exe file copy program?

how should i make an c program that copies 2 exe files? i can't use fgetc() to copy character by character, And i dont know how to use fread() or fwrite() in this situation (because these functions need a variable to input the data in, and i dont know the data type of the binary symbols present int that file). So please write back a program.|||The 'fread' and 'fwrite' functions take 'void' pointers. They don't care what type the data is and you shouldn't either. For example (note that there's no error checking here):





void copy(FILE *infile, FILE *outfile)


{


char buf[256];


int i;


while(1)


{


i=fread(buf, 1, 256, infile);


if(i%26lt;=0) return;


fwrite(buf, 1, i, outfile);


}


}|||If you are sharing with a friend who uses J, the only files you need to send are the program file (AS) and data, images, sounds, etc., for your program. If your user does not have J, you can still share your program by creating an EX file.|||yes it easy and basic to learn in programming languages.

Help with fread in c++?

I am using fread to read in a block of 512 bytes from a binary file. I need to define a variable to store the block in the same way you would type





int number;





to define a place to store an integer





what would you use. I am in c++|||To read 512 bytes, I would use a vector%26lt;uint8_t%26gt;, since this is C++, or just vector%26lt;char%26gt; (or even a string)



#include %26lt;iostream%26gt;

#include %26lt;cstdio%26gt;

#include %26lt;vector%26gt;

int main()

{

聽聽聽聽 FILE* file = std::fopen("test.txt", "r");

聽聽聽聽 // remember to test if it opened correctly before calling fread

聽聽聽聽 std::vector%26lt;char%26gt; data(512);

聽聽聽聽 size_t count = std::fread(%26amp;data[0], sizeof data[0], data.size(), file);

聽聽聽聽 ...

}



although if you are using C++, while are you using C I/O? Open the file as an ifstream, and use the simpler



#include %26lt;iostream%26gt;

#include %26lt;fstream%26gt;

#include %26lt;vector%26gt;

int main()

{

聽聽聽聽 std::ifstream file("test.txt");

聽聽聽聽 std::vector%26lt;char%26gt; data(512);

聽聽聽聽 file.read(%26amp;data[0], data.size());

聽聽聽聽 size_t count = file.gcount();

聽聽聽聽 ...

}|||You need an array. If you already know how much data you will be reading, you can define the array as such





int data[512];





Then that gives you 512 integers, you can access them as data[0] through data[511]...

Why is this c++ program not working (it is mainly a problem with the iostream library)?

//the idea, is for it to be cross platform, and open files in binary mode


#include %26lt;iostream%26gt;


#include %26lt;stdlib.h%26gt;


using namespace std;


int main()


{


string input;


cout %26lt;%26lt;"please input the full file name:"%26lt;%26lt;endl;


cin %26gt;%26gt;input;


cout %26lt;%26lt;endl%26lt;%26lt;endl;


ifstream file(input, binary);


file %26gt;%26gt;input;


cout %26lt;%26lt;input;


return 0;


}/*keep getting this error: "binary_file_reader.cpp:10: error: variable 鈥榮td::ifstream file鈥?has initializer but incomplete type"*/|||You need to #include %26lt;fstream%26gt;





also, the call to fstream's constructor should be


ifstream file(input.c_str(), ios::binary);

C# variables????????

Is there a variable that will store the following charaters "00101111", like binary but it must keep the first 0 and i dont want to use a string, array, or list.|||if you set the type to char (1 byte) and then assign the value as such


0x00101111. It will store the value.





If you mean for display (that leading 0 comment) purposes it has to be a string, character array, or list.

Chemistry help in writing the formula and naming of compounds?

give the formulas of the following compounds:


A. Binary compounds composed of metals with only once charge


1. aluminum oxide


2. magnesium sulfide


3. cadmium bromide


4. barium hydride


5. sodium nitride


B. binary compounds composed of metals with variable oxidation number:


1. Chromium (III) bromide


2. nickel (II) fluoride


3. mercuric chloride


4. tin (II) sulfide


5. antinomy (V) oxide


C. compounds composed of two nonmetals


1. hydrogen chloride


2. hydrogen peroxide


3. carbon dioxide


4. diphosphorous pentoxide


5. sulfur trioxide


D. compounds composed of polyatomic ions:


1. potassium nitrite


2. ammonium phosphate


3. silver nitrate


4. calcium hydroxide


5. sodium sulfate





II. Give the names of the following compounds


A. binary compounds composed of metals with only one charge:


1.ZnF2


2.BiCl3


3.BaS


4.Na2O2


5.LiI


B. Binary compounds composed of metals with variable oxidation number: write (a) stock method (or using Roman numeral to indicate the oxidation number of the metal) and (b) classic method (-ous, -ic)


1. CuS


2. Ni3P2


3. SnO2


4. FeCI3


5. PbI2


C. compounds composed of two nonmetals/diatomic:


1. CI2


2. O2


3. HI (g)


HI (aq)


4. HCI (g)


HCI (aq)


5. SO2


D. compounds composed of polyatomic ions:


1. Ca(CN)


2. Ag2CO3


3. NaHCO3


4. NH4OH


5. Mg(CIO4)2





--please help. :(( i need this so badddd :(((( thanks. :)|||A


1. Al2O3


2. MgS


3. CdBr2


4. BaH2


5. Na3N


B.


1. CrBr3


2. NiF2


3. Mercury(II) chloride HgCl2 , mercury(I) chloride Hg2Cl2


4. SnS


5. Sb2O5


C


1. HCl


2. H2O2


3. CO2


4. P2O5


5. SO3


D


1. KNO2


2. (NH4)3PO4


3. AgNO3


4. Ca(OH)2


5. NaSO4





II.


1. Zinc fluoride


2. Bismuth chloride


3. Barium sulfide


4. Sodium peroxide


5. Lithium iodide


B.


1. Copper(II) sulfide, cupric sulfide


2. Nickel (II) phosphide, nickelous phosphide


3. Tin(IV) oxide, Stannic oxide


4. Iron(III) chloride, ferric chloride


5. Lead(II) iodide, plumbous iodide


C.


1. Chlorine (nox 0)


2. Oxygen


3. Hydrogen iodide


Hydriodic acid


4. Hydrogen chloride


Hydrochloric acid


5. Sulfur dioxide, sulfur(IV) oxide, sulfurous anhydride


D.


1. are you sure its not Ca(CN)2? If its Ca(CN)2 the answer is Calcium cyanamide


2. Silver carbonate, silver(I)Carbonate


3. Sodium bicarbonate, sodium hydrogen carbonate


4. Ammonium hydroxide


5. Magnesium perchlorate

Comparing variables of long datatype?

I want to only copare the lower 8 bits of a variable named x (data type is long) to a range of bit patterns (0000 0000 to 1111 1111)





How can I go about converting the long datatype to binary format and then compare with the above mentioned range of patterns|||Values are already stored in binary format. The trick is in understanding that format. I'm assuming you're using a 32-bit long -- 32-bit longs are commonly stored in two possible formats, called big-endian and little-endian. This has to do with the order of the bytes in memory vs. their bit significance. The first thing you need to decide is when you say "lower 8 bits" whether you mean the least significant 8 bits, or the 8 bits at the lowest memory address in the long.





In C/C++, the "patterns" ranging from 0000 0000 through 1111 1111 can be viewed simply as unsigned char constants, ranging from 0 to 255.





If you take the long variable, x, mask and cast it to an unsigned char, "(unsigned char)(x %26amp; 0xffL)", you'll have an expression that represents the least significant 8 bits.





if (((unsigned char)(x %26amp; 0xffL))==7)


{


// x == %26lt;3 bytes of anything%26gt; 0000 0111


}





If instead you do this as a pointer cast with a dereference, "*(unsigned char *)%26amp;x", you'll have an expression that yields the bit pattern for the 8 bits of x at the lowest memory address. (On some machines, e.g. those with Intel and AMD x86 CPUs, this also yields the least significant 8 bits. On other hardware, e.g. Xbox 360, you'll have the most significant 8 bits instead.)





if ((*(unsigned char *)%26amp;x)==7)


{


/*


different on different hardware! but sometimes necessary,


e.g. when encoding/decoding information sent over the network


*/


}|||What do you mean, compare them to a range of bit patterns?





I would suggest subtracting to make the value less than 256, then xoring or something.

Science homework help... solar system stuff! :O help?!!?

word list;


black hole


variable star


photosphere


pulsar


binary star


chromosphere


quasar


corona




















questions...





what is a mysterious, briht, starlike object in the galxy core











betelgeuse... a large star oh high luminosity








whats a neutron star that rotates rapidly and gives out a beam of radiation picked up as pulse











whats the surface of the sun which emits the radiation we can see

















whats 2 stars orbiting a common center of gravity














whats athe hot gas of the sun visible only during a total eclipse of the sun








whats a collapsed star from which light cannot escape|||the last one is black hole.

Any tip/book for writing codes to read/write a specific type of file (for C++)?

I've looked into the code for importing Bitmap into C++, but I kind of not getting the point why they do this and that (such as declare struct bitmapheader-something with several variables, then use readf() to put the binary data into the structed variable). How can they be sure that readf() will read and put correct data from binary file into the multi-variable struct class (and each variable doesnt have the same length)?





What if i want to import a jpeg file? As I remember it has compression too, so how do we detect and decompressed them? What if i want to import other type of file? that doesn't fall in category of image... Can anyone give a tip what i suppose to do first before writing the code (study about the structure? compression?)





Any Books that help me learn about these stuffs? Like how to write these type of program... or maybe tutorial, resource are good too.. Thx in advance|||Rather than trying to do this yourself from the ground up you might be better off using one of the many freely available APIs out there for reading images in different formats. There are open source libraries for this kind of thing, and also freely available commercial stuff like the QuickTime SDK, which works on both Mac OS and Windows.|||EARN MONEY ONLINE WITH ZERO INVESTMENT


50$ SIGN UP BONOUS





checkout the link below..





http://mentmoney4u.blogspot.com/

Should I use multiple t-tests?

want to do a statistical test to find out the effect of 3 binary ("yes/no") variables on one continuous variable.





For example, is there a statistical difference in "happiness score, from 1 to 100" between people in the following groups?





Sex M/F


Obese Y/N


Computer-user Y/N





What would be the best statistical test to use?


I thought that 3 t-tests (for effect of Sex, Obesity and then Computer-use) would work.





Would it be easier if there were only 2 yes/no variables (Obesity and use of computer)?





If I use multiple t-tests, do I need a Bonferroni correction (and can someone explain what that really means? I read it in a book).|||Why not use OLS regression? If the dependent variable (happiness score) is continuous, then you can intrepret the b coefficients as the effect on happiness for the one unit increase in Sex, Obese, Computer-user. They would be directly comparable. This would give you the independent effect of each characteristic.





Yes, you could use t-tests, so long as you calculate the mean and standard deviation for each of the three pairs of comparison groups. The disadvantage of this approach is that you would not likley be able to account for the possibility of, say, a greater number of men than women using computers, or a greater numbe of men or women who are obese. Basically, regression does this for you, but three seperate t-tests on 3 pairs of means will not.|||If it's binary, it may be best to use an r x k analysis. Student t-tests are good for continuous data, where as ratios and matrices are good for discrete data.|||No, the t-test is for comparison of two mean values and you must know the sd as well.


In this case you need a 3 x2 khi square test|||Try the below website, it tells you how to adjust your critical values based on the fact that you are doing three t-tests

Should I use multiple t-tests?

I want to do a statistical test to find out the effect of 3 binary ("yes/no") variables on one continuous variable.





For example, is there a statistical difference in "happiness score, from 1 to 100" between people in the following groups?





Sex M/F


Obese Y/N


Computer-user Y/N





What would be the best statistical test to use?


I thought that 3 t-tests (for effect of Sex, Obesity and then Computer-use) would work.





Would it be easier if there were only 2 yes/no variables (Obesity and use of computer)?





If I use multiple t-tests, do I need a Bonferroni correction (and can someone explain what that really means? I read it in a book).|||This is probably the most widely used statistical test of all time, and certainly the most widely known. It is simple, straightforward, easy to use, and adaptable to a broad range of situations.





Its utility is occasioned by the fact that scientific research very often examines the phenomena of nature two variables at a time, with an eye toward answering the basic question: Are these two variables related? If we alter the level of one, will we thereby alter the level of the other? Or alternatively: If we examine two different levels of one variable, will we find them to be associated with different levels of the other?

Help with logistic regression?

Hello, Just wondering if someone could help me with some data analysis/regression work I am doing. I am trying to do propensity score matching, but first need to do logistic regression and that's what I am have trouble with.. suppose I have a model as follows: gpa (the dependent variable) and sex and race being the independent variables. So if I want to do logistic regression, do I take the log of all the variables (dependent and independent) first and then do the regression? for example, in STATA do I type 'regress gpa sex race' (using the log of all the variables) to get regression results.. or do I do 'logit gpa sex race' (using the log of all the variables)? Also, in logistic regression, are all the variables meant to be binary (ie. yes and no). because race being a categorical variable and having several categories, do I generate a new variable, that is for example, 1 = black and else 0.. basically do I generate the dummy variable first and then take the log of the dummy variable for logistic regression?


part of my data is as follows:





GPA sex race


3.2 m black


3.5 f black


3.1 m hispanic


3.6 f white


3.2 f white


3.5 m asian


3.3 f hispanic


3.6 m white





part of my stata code is as follows:


gen black = race==black


gen female = sex==f





gen loggpa = log(gpa)


gen logsex = log(female)


gen lograce = log(black)


and then do something like:





logit loggpa logsex lograce or


regress loggpa logsex lograce





does this seem correct for doing logistic regression? Or can someone show me if I must do it differently, in terms of stata commands? I鈥檓 just confused about when to generate the variable, taking the log of the variable and on to regression.





Thanks, any help will be greatly appreciated,





Mike|||I don't quite understand everything you're doing. With logistic regression you usually have a dichotomous outcome - gpa, your outcome, is not dichotomous (is it?) so you can't use that as an outcome. If you are doing propensity matching, your outcome is the thing that you want to match people on (maybe race or sex? And you want to match on gpa?)





Anyway, once you have a dichotomous outcome (I'll call Y and some predictors (I'll call X1, X2) you can either use:





logistic Y X1 X2





If you want to you can use:





logit Y X1 X2





and if you do





logit Y X1 X2, or





that's the same as the first command. (You also forgot the comma).

Help with doing logistic regression?

Hello, Just wondering if someone could help me with some data analysis/regression work I am doing. I am trying to do propensity score matching, but first need to do logistic regression and that's what I am have trouble with.. suppose I have a model as follows: gpa (the dependent variable) and sex and race being the independent variables. So if I want to do logistic regression, do I take the log of all the variables (dependent and independent) first and then do the regression? for example, in STATA do I type 'regress gpa sex race' (using the log of all the variables) to get regression results.. or do I do 'logit gpa sex race' (using the log of all the variables)? Also, in logistic regression, are all the variables meant to be binary (ie. yes and no). because race being a categorical variable and having several categories, do I generate a new variable, that is for example, 1 = black and else 0.. basically do I generate the dummy variable first and then take the log of the dummy variable for logistic regression?


part of my data is as follows:





GPA sex race


3.2 m black


3.5 f black


3.1 m hispanic


3.6 f white


3.2 f white


3.5 m asian


3.3 f hispanic


3.6 m white





part of my stata code is as follows:


gen black = race==black


gen female = sex==f





gen loggpa = log(gpa)


gen logsex = log(female)


gen lograce = log(black)


and then do something like:





logit loggpa logsex lograce or


regress loggpa logsex lograce





does this seem correct for doing logistic regression? Or can someone show me if I must do it differently, in terms of stata commands? I鈥檓 just confused about when to generate the variable, taking the log of the variable and on to regression.





Thanks, any help will be greatly appreciated,





Mike|||I only know Statistical Analysis System (SAS). If you want, download it from Taringa web site. SAS. Analize this output. My email is gegmartinez@hotmail.com


9.2 for free


44 data in;


45 input gpa sex race;


46 datalines;





NOTE: The data set WORK.IN has 8 observations and 3 variables.


NOTE: DATA statement used (Total process time):





56 proc logistic;


57 model gpa = sex race;


58 run;





NOTE: PROC LOGISTIC is fitting the cumulative logit model. The probabilities modeled are summed over


the responses having the lower Ordered Values in the Response Profile table. Use the response


variable option DESCENDING if you want to reverse the assignment of Ordered Values to the


response levels.


NOTE: Convergence criterion (GCONV=1E-8) satisfied.


NOTE: There were 8 observations read from the data set WORK.IN.


NOTE: PROCEDURE LOGISTIC used (Total process time):


real time 0.03 seconds


cpu time 0.03 seconds





The SAS System 11:10 Tuesday, August 4, 2009 3





The LOGISTIC Procedure





Model Information





Data Set WORK.IN


Response Variable gpa


Number of Response Levels 5


Model cumulative logit


Optimization Technique Fisher's scoring








Number of Observations Read 8


Number of Observations Used 8








Response Profile





Ordered Total


Value gpa Frequency





1 3.1 1


2 3.2 2


3 3.3 1


4 3.5 2


5 3.6 2





Probabilities modeled are cumulated over the lower Ordered Values.








Model Convergence Status





Convergence criterion (GCONV=1E-8) satisfied.








Score Test for the Proportional Odds Assumption





Chi-Square DF Pr %26gt; ChiSq





13.8071 6 0.0319








Model Fit Statistics





Intercept


Intercept and


Criterion Only Covariates





AIC 32.953 35.300


SC 33.271 35.777


-2 Log L 24.953 23.300





The SAS System 11:10 Tuesday, August 4, 2009 4





The LOGISTIC Procedure





Testing Global Null Hypothesis: BETA=0





Test Chi-Square DF Pr %26gt; ChiSq





Likelihood Ratio 1.6531 2 0.4376


Score 1.6085 2 0.4474


Wald 1.4710 2 0.4793








Analysis of Maximum Likelihood Estimates





Standard Wald


Parameter DF Estimate Error Chi-Square Pr %26gt; ChiSq





Intercept 3.1 1 -1.0396 1.8418 0.3186 0.5725


Intercept 3.2 1 0.6537 1.7648 0.1372 0.7111


Intercept 3.3 1 1.2428 1.8061 0.4735 0.4914


Intercept 3.5 1 2.4635 1.9460 1.6027 0.2055


sex 1 1.0415 1.3281 0.6150 0.4329


race 1 -0.7350 0.6882 1.1408 0.2855








Odds Ratio Estimates





Point 95% Wald


Effect Estimate Confidence Limits





sex 2.833 0.210 38.266


race 0.479 0.124 1.847








Association of Predicted Probabilities

Prove that G ⊕ Z is isomorphic to G.?

Let G be the group of polynomials in the variable x, with the binary operation of addition.|||I'm guessing that the polynomials have coefficients in Z.





Then consider the map f: G ⊕ Z -%26gt; G


defined by


f( g(x), z) = x*g(x) + z

Unsigned char initializing?

i want to set everybit of unsigned char 1 byte variable to 1 to get binary value 255 .How to initialize that?|||It's really as easy as it looks.





unsigned char c = 255;





Or you perform a bitwise negation of 0:





unsigned char c = ~0;

驴Is There a Theoretical Assumption behind the use of a Gompit Model?

In econometrics, binary dependent variables are aproximated trough some density or functional forms such as normal (probit model) and logistic (logit). When the density function is Gompertz we have a Gompit model.. now, is there a theoretical/theorical framework that justifies or suggest the use of a gompit model?





(P.S.: I mean besides econometric tests, is there a theorical idea that drives toward the use of gompit models?)|||The following is another example (other than econometrics),

How does this code work? - I'm new at C++?

//Includes the libary?


#include %26lt;iostream%26gt;





//Use standard function; so I wont have to write it all the time


using namespace::std;





//the "int a(int b)" how does that work?


int binary(int decimal)


{


//Make variable "reminder"


int remainder;





//And if the variable decimal is less or equal to 1, then run following function?


if(decimal %26lt;= 1)


{


//post decimal's value?


cout %26lt;%26lt; decimal;


//Return to the start and run it again?


return 0;


}





//I don't got this line at all


remainder = decimal%2;





//If decimal is greater then 1, then run this function?


binary(decimal %26gt;%26gt; 1);


//and write the remainder value


cout %26lt;%26lt; remainder;


}





//Start main process, isn't this suppost to be runned before anything els?


int main()


{


//Make variable "num"


int num;





//Ask the user for input


cout %26lt;%26lt; "Enter decimal: ";


//Set the input as "num"


cin %26gt;%26gt; num;


//Write "endl?", then "binary of", then the "num" you just inputted, and then "is"?


cout %26lt;%26lt; endl %26lt;%26lt; "Binary of " %26lt;%26lt; num %26lt;%26lt; " is ";


//then say the binary number?, but how was this found, and posted?


binary(num);


//Pause it


system("PAUSE");


}





Anyone able to help me understand the code?|||In addition to what the guys above have already said:





return 0; doesn't return to the start. It exits the function with the value of 0. Actually this return value is never used, so the declaration for your function should be "void binary(int decimal)" (ie returning nothing) and "return 0" should be just "return".





What the function binary() does is convert a decimal number (like 3) into its binary form (namely 101) and then prints it out.





How it works: first it checks whether the decimal number is %26lt;= 1 (ie if it's 0 or 1). If it is, then it's ALREADY binary and can be printed. Otherwise, the function prints the remainder of a division by 2 (the result is 1 for odd numbers, 0 for even numbers), then shifts the number right by one bit position (decimal %26gt;%26gt; 1) and calls binary() again on that shifted value.





Call stack of binary(3):





binary(3): is it %26lt;= 1? No. Print remainder: 3%2=1. Call binary(3 %26gt;%26gt; 1) = binary(2).


binary(2): is it %26lt;= 1? No. Print remainder: 2%2=0. Call binary(2 %26gt;%26gt; 1) = binary(1).


binary(1): is it %26lt;= 1? Yes. Print 1





Result printed: 101|||It's just a recursive function which displays an integer in binary format. You enter a decimal integer value in main and then it calls binary() recursively to print an appropriate string of 1s and 0s.|||The functions that interact with the hardware (and OS) directly aren't in the program, their in what's called a library. So firstly you need to tell the compiler (the program that makes your program) to


#include %26lt;iostream%26gt;





using namespace::std;


just means that you only have to write cout or cin, rather than std::cout or std::cin. don't worry about this for now.





int binary(int decimal) is the declaration of a function that will be used later in your program.


the first int means that the function will return an integer.


the word "binary" is just the name of the function.


in the brackets, you would put all the parameters your function would accept separated by a comma, in this case it accepts only one parameter, "decimal" of type int(eger).


the function is them between the {


and the }





I think you've got the rest of the function understood until here,


remainder = decimal%2;


That means calculate the modulus of decimal and 2 (e.g. the remainder of decimal when divided by 2 - see http://www.cprogramming.com/tutorial/mod鈥?/a> for more info).





I must be honest, I don't quite know what this does,


//If decimal is greater then 1, then run this function?


binary(decimal %26gt;%26gt; 1);


but if your sure that the code is correct, then s'ok.





endl is a new line character, and the


binary(num);


will print out the number in binary (techincally it should have returned the number as you defined it as int binary, but it might work this way).





if you need more help, well, dunno. email, google, pm, whatever.

Astronomy help --points for best answer!?

Can someone help me with these astronomy questions? I am stumped!





Which of the following is an actual observation that falsifies (is inconsistent with) the theory that the Milky Way galaxy originated from the collapse of a spherical gas cloud that flattened into a disk?


a. We observe fewer white dwarf stars in the galactic disk than there should be for an 11-billion year old galactic disk.


b. The globular cluster stars in the galaxy halo are all old.


c. The metallicity of globular cluster stars is about one tenth the Sun's value.


d. Nonsense - all of the above observations are consistent with the standard collapse-from-a-cloud theory.





Which of the following is a correct list of distance indicators (standard candles) used by astronomers?


a. emission and reflection nebulae in molecular clouds; nova explosions on white dwarfs; main-sequence stars


b. white dwarf stars; Cepheid variables; black hole binary systems; massive star supernovae


c. lyra and cepheid variable stars; white-dwarf supernovae


d. emission by super-massive black holes located at the center of nearly every large galaxy; spinning spiral galaxies





Which of the following arguments supports the idea that large elliptical galaxies formed by mergers of smaller galaxies?


a. Big ellipticals lack gas and dust, and galactic collisions can allow central supermassive black holes to consume all pre-existing gas and dust.


b. Big ellipticals are generally found near the center of rich galaxy clusters containing many individual galaxies.


c. Ellipticals have lots of gas and dust, and collisions can spur star formation that also forms gas and dust.


d. All the above arguments support the idea of galaxy mergers forming big elliptical galaxies.





Dwarf detonation supernovae (type Ia) are useful standard candles for measuring large distances because


a. the periodicity of the light curve is tightly correlated with the peak luminosity.


b. the exploding star has about the same mass and composition in each case, it is bright, and the light curve is always the same.


c. the explosion is recurrent, and the time between explosions correlates with the peak luminosity.


d. the rotation rate of the object is easily measured and correlates with the peak luminosity.


e. none of the above 鈥?supernovae are useless for measuring distances





Thanks!!|||We're not here to do your homework.





You could at lest break this up into several questions, and rephrase those questions so they aren't duplicates of your homework. Make your questions so that they help lead you to the right answer.|||You want me to do that much work for mere points?

Astronomy help? points! A and C correct?

Which of the following is an actual observation that falsifies (is inconsistent with) the theory that the Milky Way galaxy originated from the collapse of a spherical gas cloud that flattened into a disk?


a. We observe fewer white dwarf stars in the galactic disk than there should be for an 11-billion year old galactic disk.


b. The globular cluster stars in the galaxy halo are all old.


c. The metallicity of globular cluster stars is about one tenth the Sun's value.


d. Nonsense - all of the above observations are consistent with the standard collapse-from-a-cloud theory.





Which of the following is a correct list of distance indicators (standard candles) used by astronomers?


a. emission and reflection nebulae in molecular clouds; nova explosions on white dwarfs; main-sequence stars


b. white dwarf stars; Cepheid variables; black hole binary systems; massive star supernovae


c. lyra and cepheid variable stars; white-dwarf supernovae


d. emission by super-massive black holes located at the center of nearly every large galaxy; spinning spiral galaxies|||I think that is correct.

Psychology multiple choice help please.?

1. What is the name for a variable which is measured using 2 different values?





A. Dichotomous.


B. All of these.


C. Binomial.


D. Binary.





2. A mediator variable is...





A. Another name for the dependent variable.


B. All of these.


C. Another name for the independent variable.


D. Responsible for the relationship between two other variables.





3. What is an example of a subject variable?





A. Race.


B. Sex.


C. Religion.


D. All of these.|||1)B...(Bi, and Di mean two)





2)D...(Mediator is one that controls or helps two opposing parters. It isnt dependent or independent





3)im guessing but i think D because there all base subjects. like you can do race in alot of ways, sex in alot of ways (lol hehe) and religion in alot of ways.|||Jamie is mostly right, but the first answer is A.

Help for econometrics please!!?

The static model for the investment of 10 companies is


INV= 伪 + 尾1V+尾2K+蔚





How do we define three binary dummy variables, one for each of the three companies you have selected out of the ten.





can you tell me how to solve this questions we have the statistics we need and we are using eviews could you tell me how to present the question and what i might need to answer it|||type "genr dummy1=0"


then open up the series and edit its first observation to be 1.





repeat for other two firms.

TRUTH TABLE IN ENGINEERING?

Using Truth Table, prove that


C = (A鈥?+ B)鈥?= A . B鈥?


where A, B and C are binary logical variables. Show a diagram showing the output C from inputs A and B using 鈥?-input NOR鈥?gates only.





please help! thank you in advance(:|||Use one Nor gate with its inputs tied together to make a Not gate (inverter) and connect B to the input and the output to the second Nor gate which has A as its other input.

Using Truth Table, prove that C = (A + B鈥?鈥?= A鈥?. B?

Using Truth Table, prove that


C = (A + B鈥?鈥?= A鈥?. B


where A, B and C are binary logical variables. Show a diagram showing the output C from inputs A and B using 鈥?-input NOR鈥?gates only.|||..A..B...C


..0...0...0


..0...1...0.....C = A


..1...0...1


..1...1...1








..A..B...C


..0...0...1


..0...1...0.....C = B'


..1...0...1


..1...1...0








..A..B...C


..0...0...1


..0...1...0.....C = (A + B' )


..1...0...1


..1...1...1








..A..B...C


..0...0...0


..0...1...1.....C = (A + B' )'


..1...0...0


..1...1...0








..A..B...C


..0...0...1


..0...1...1.....C = A'


..1...0...0


..1...1...0











..A..B...C


..0...0...0


..0...1...1.....C = A'B


..1...0...0


..1...1...0

Find the probability and standard deviation?

Suppose the discrete random variable X denotes the number of successes that is observed in n = 6 independent


binary trials with the probability of success p = 0.45 .





A)The probability of observing five or more successes is:


B)The standard deviation of the random variable X is:|||A) P(X 鈮?5) = P(X=5) + P(X=6) = choose(6,5) 0.45^5 0.55^1 + choose(6,6) 0.45^6 0.55^0





= 0.06089428 + 0.008303766 ~= 0.0692





B) Variance = 6 x 0.45 x 0.55 = 1.485. s.d = 鈭?.485 = 1.2186|||Let X be the discrete random variable the number of successes that is observed.





p = 0.45





q = 1 - 0.45 = 0.55





n = 6





A)





P(X 鈮?5) = P(X = 5) + P(X = 6) = 0.06089428125 + 0.008303765625 = 0.06919804688





P(X = 5) =





(6)


(5)*(0.45^5)*(0.55)^1 = 0.06089428125





(6)


(6)*(0.45^6)*(0.55)^0= = 0.008303765625





B)





SD(X) = sqrt(n*p*q) = sqrt(6*0.45*0.55) = 1.218605761

Would anyone like to see me destroy a typical Creationist argument?

I am referring to the low probability of abiogenesis argument. The answer is Bernoulli Trials (google it). Take a binary random variable (here, the probability of life forming on it's own) that has a very small chance of success (let's say 10^-100). It turns out mathematically that the probability of the unlikely event occurring once is quite large when the experiment is repeated a number of times equal to the reciprocal of the probability of success (enter the lottery enough times, you win right?). And of course it only needs to happen once, since evolution will take over (what's funny is that they are acknowledging abiogenesis when they use this argument). Well what do you think?|||And who created Bernoulli?





I never saw the universe compared to a lottery!





As for your initial question... my answer is, "NO!"








Have a blessed day.

PLEASE help with Probaility Problem?

At a university, 60% of the 7499 students are female. The student new paper reports results of a survey of a random sample of 50 students about various topics invinvolvingcohol abuse, such as participation in binge drinking. They report that their sample contained 26 females





a) Explain how you can set up a binary random variable X to represent gender





b) Identify the population distribution of gender at this university





c) Identify the data distribution gender for this sample





D) Identify the sampling distribution of the sample proportion of females i the sample.


State its mean and standard error for a random sample of size 50|||n = 50; p = 0.6; q = 0.4; x = 30


渭 = (n p) = 30; 蟽虏 = ( n p q ) = 12; 蟽 = 鈭? n p q ) = 3.4641


x P(x) 危P(x) 1-危P(x)


--- --------- --------- ---------


0 0.0000000 0.0000000 1.0000000


1 0.0000000 0.0000000 1.0000000


2 0.0000000 0.0000000 1.0000000


3 0.0000000 0.0000000 1.0000000


4 0.0000000 0.0000000 1.0000000


5 0.0000000 0.0000000 1.0000000


6 0.0000000 0.0000000 1.0000000


7 0.0000000 0.0000000 1.0000000


8 0.0000000 0.0000000 1.0000000


9 0.0000000 0.0000000 1.0000000


10 0.0000000 0.0000000 1.0000000


11 0.0000000 0.0000000 1.0000000


12 0.0000002 0.0000002 0.9999998


13 0.0000009 0.0000011 0.9999989


14 0.0000035 0.0000046 0.9999954


15 0.0000125 0.0000171 0.9999829


16 0.0000410 0.0000581 0.9999419


17 0.0001230 0.0001811 0.9998189


18 0.0003382 0.0005193 0.9994807


19 0.0008545 0.0013738 0.9986262


20 0.0019866 0.0033604 0.9966396


21 0.0042570 0.0076174 0.9923826


22 0.0084173 0.0160348 0.9839652


23 0.0153708 0.0314056 0.9685944


24 0.0259382 0.0573438 0.9426562


25 0.0404636 0.0978074 0.9021926


26 0.0583610 0.1561683 0.8438317


27 0.0778146 0.2339830 0.7660170


28 0.0958787 0.3298617 0.6701383


29 0.1091034 0.4389651 0.5610349


30 0.1145586 0.5535236 0.4464764


Normal Approximation:


z = ( x - 渭 ) / 蟽


P ( x %26lt; 29.5) = P ( z %26lt; -0.1443 ) = 0.4426


P (29.5 %26lt; x %26lt; 30.5) = P (-0.1443 %26lt; z %26lt; 0.1443) = 0.1148


P (30.5 %26lt; x ) = P (0.1443 %26lt; z ) = 0.4426

Thursday, December 15, 2011

Creating a logit model to run logistic regression?

hello, I am trying to construct a logit model to estimate the probability but I'm having trouble in doing so.


I know how to do the right hand side (RHS) for a logit model, but I am having trouble with the left hand side (LHS) of the equation.





am I correct in saying that a logistic function looks like this: Pi = 1/1+e^-(z) where in my case


z= beta + beta1(residence) + beta2(sex) + beta3(education) + u-error term





Is this what the logit model looks:


Pi = E(Y=1|Xi) = 1/1 + e -(z) ... or is it


Li = ln(Pi/1-Pi) = Zi = beta + beta1(residence) + beta2(sex) + beta3(education) + u-error term





in my case, I have binary outcome variable namely, whether a person suffers from heart disease or not... my independent variables are residence (1= rural or 0 =urban), sex (m=1 or f=0), education (primary=1, secondary=2 and highereduc=3).. can someone please show me how to write an actual logit model to predict the probability whether a person will suffer from heart disease.. for the left hand side, what should the exact notation look like? i hope this makes sense.. any help will be greatly appreciated.. thanks


Mike|||Logistic Regression: Statnotes, from North Carolina State ...


Logistic regression has many analogies to OLS regression: logit ..... The logistic regression model is run against the dependent for the full model with ...... After this, PASW/SPSS will automatically create dummy variables based on the

Creating a logit model?

hello, I am trying to construct a logit model to estimate the probability but I'm having trouble in doing so.


I know how to do the right hand side (RHS) for a logit model, but I am having trouble with the left hand side (LHS) of the equation.





am I correct in saying that a logistic function looks like this: Pi = 1/1+e^-(z) where in my case


z= beta + beta1(residence) + beta2(sex) + beta3(education) + u-error term





Is this what the logit model looks:


Pi = E(Y=1|Xi) = 1/1 + e -(z) ... or is it


Li = ln(Pi/1-Pi) = Zi = beta + beta1(residence) + beta2(sex) + beta3(education) + u-error term





in my case, I have binary outcome variable namely, whether a person suffers from heart disease or not... my independent variables are residence (1= rural or 0 =urban), sex (m=1 or f=0), education (primary=1, secondary=2 and highereduc=3).. can someone please show me how to write an actual logit model to predict the probability whether a person will suffer from heart disease.. for the left hand side, what should the exact notation look like? i hope this makes sense.. any help will be greatly appreciated.. thanks


Mike|||hey mike, i dint get you. your dependant variable is heart disease? also, you want to find probability under what conditions? like 'rural,m,secondary' or another combination? or overall probability?also, your model in terms of log is correct ,simply because it eases out estimation process for betas

BASIC ENGINEERING PROBLEM!?

You are working on setting up a security system for your apartment that has two large windows and one front entrance door. You install two sensors A and B on one of the large windows and want the alarm to sound if both sensors indicate intrusion. Similarly, sensors C and D are installed on the other window and the alarm should sound if both sensors indicate intrusion. Sensor E is installed on the front door and the alarm should sound if there is an intrusion.


Each of these sensors represents a binary logical variable with a value of zero when there is no intrusion and a value of one when there is an intrusion. The logic variable F represents an alarm for which a zero represents 鈥榥o alarm鈥?and a value of one means 鈥榓larm sounds.鈥?Express the logical variable F as a function of logical variables A, B, C, D and E and write the Truth Table for it.





pleaseeeeeee help! and thank you in advance(:|||In programmerese If (A AND B)=1 OR If (C AND D)=1 OR If E=1 then F=1

How to calculate regression model Probit?

Im trying to create a probit model using a Binary independent variable. Basically I am using variables to determine which characteristics influence political party affiliation with the dependent variable being republican or not republican and variables being things like income, sex, education etc.. The only national data I can find are percentages i.e. 43 % men 37% white etc. etc., and in my classes we only dealt with individual observations for example the results of 50 survey participant sample. Is is possible to use the percentages as my variables or would it be better for me to use individual observations and if so where can I find ?|||You cannot do it with percentages alone, unless you have complete breakup, like republcian-white-male-college = x%, republcian-white-male-highschool = y%, republcian-white-female-college = z%, and so on.





So in general you do need the observations, and the data from the surveys might be made available by authors of the surveys.





Try talking to reference person in the library if you have one.


Or use resources like jstor.org or scholar.google.com to find papers that did such surveys, and read them to see if data is publicly available.





If you really like some paper, try e-mailing the authors. They might share the data.

Is it possible to allocate over 650000 byte memory in c-programming language.?

i want to open one binary file that contain 650000 data(12 bit form one data that must be saved in one variable) how i can do this?|||unsigned char* buffer;





buffer = (unsigned char*)malloc(sizeof(unsigned char)*650000 );





//do stuff with it





//release it when you're done


free(buffer);

LP Relaxation in ILP model?

can someone explain this concept? if an ILP-model has 4 binary variables, at least how many LP-relaxations should we generate to solve it?

What is the output of the following Linux 'if' statement?

Given the following variable declarations,


HOME=/home/raem


BINDIR=/home/raem/bin





What is the output of the following if statement?


if [ $HOME/bin = $BINDIR ] ; then


echo "Your binaries are stored in your home directory."


fi|||Your binaries are stored in your home directory.|||Learn it man. I not gona do a homework for you. Its easy just read the book hell!

I need to convert a VHS cassette's magnetic format to a binary digital format?

I need some difficult to find hardware to convert the primary band data at magnetic pulse width vectors from a standard VHS video matrix signal divided by full ratio to a caption streamline digital matrix filter with a 4.5 mhz carrier wave modulation threshold at equal scan tracking perimeters of equal value and strength for reconversion at system tacking pulse variables by horizontal- vertical clamping at synchronization pulse to full-color video quality.





so where do i find the software to do this difficult conversion?





illustration


analog -%26gt;%26gt;%26gt;(((((())))))--%26lt;%26lt;~digital


magnetic-%26gt;%26gt;(((((())))))--%26lt;%26lt;~binary


frequency-%26gt;%26gt;(((((())))))--%26lt;%26lt;~video


------------------conversion


end-results





crystal clear low noise digital reproduction of magnetic signals to full color picture ratios|||You can get video grabbers which convert analog video into a digital signal in a computer.


They are just very fast analog to digital converters.


However, it does not improve the quality of the image. If the original picture is not perfect, the digital signal won't be either.


Digitized junk is still junk.





The 16 bit digital signal is already in binary mode.





The old rule of "garbage in, garbage out" applies.|||Did you pick these as random phrases about technology? They are not all that meaningful, even if clever construing of words.





To answer this and some of your other questions...





What you are talking about as far as I can see is getting better quality off the tape. Yes it can be digitised, and cleaned up to a small extent. This is simply because the video will then be stored in a computer, and you can spend any number of hours processing it. The digitizer could remove frame jitter, clean up timing for example. This is a reasonably standard process for bringing VHS tape recordings to broadcast standard. No amount of processing can extract stuff that isn't there. Perhaps some sort of software could remove pops and blips in some way similar to removing pops and crackles from analogue sound recordings. This works very well with records because the plops etc. have their own signature that can be exploited. I don't think this could be said of video, but I could be wrong. Maybe several playbacks even from different recorders can be compared. It may well be a subjective cleanup by removing (and interpolating) anything that looks wrong or untidy or whatever. Every bright pin spot flash could be real or false. The whole signal has already been processed in any recording or playback system. Directly reading the magnetic field with electron beams whatever? I don't know about this at all - yes there are some sort of techniques used with hard drive recovery, but you need to ask yourself why this is not common knowledge for analogue video. It may be something that could be developed, but does not exist because there is not enough demand. Incidentally such a doctored video is definitely going to be "non-authentic".





A modern digital video is more reproducible, and the picture is a significant improvement, but that doesn't mean there are no artifacts either. Most of the artifacts are less than human vision can detect though.





It is not possible to authenticate a video recording completely, if someone has gone to enough trouble to produce it carefully. For one, the recording itself could be completely authentic, but the content completely false. If the content is artificial perhaps a reviewer can find impossibilities. If it is real, like a model flying saucer, and the image is indistinct, it is likely to need perspective for proof. If it is "paranormal", by definition no one knows what they are looking at, and so anything goes, but cynicism is healthy. The very nature of a VHS recording is that it is low resolution, making it easier to conceal strangeness. In courts of law the video taped evidence is secured by seal. Some courts still will not accept it.





If you have strong beliefs, so be it - there is by definition no changing that. If you feel your stuff is worth the challenge, take it to whoever it is that offers one million dollars etc. I am sure you can ask them what their authentication rules are. They may even be someone trying to prove it, not reject it, and just because someone is a "Doubting Thomas" doesn't mean they will be unable to accept a new truth - in fact if that means a "non-believer", by definition a doubting Thomas is more able to accept a new truth.





There is one group who will welcome your video if it is dramatic, true or false. That is the visual media. They also have the where with all to clean up your tape by any reasonable means. I am not saying there is anything good about that approach. They may even try to ridicule you for dramatic effect. I would digitise the tape for safekeeping and distribute DVDs etc.





The link below shows a bit about what can be done to clean up videos especially if the original recoding was poor in brightness, contrast etc. One application I have seen mentioned is called Magic Bullet.|||You may use the best software I have seen AVS Video Tools. It can convert to/from all key format, upload video or DVD directly to key portables like iPod, Sony PSP, Archos, Zen Creative, and mobiles.





It can capture video from DV or webcams, TV tuners, DVB-T, DVB-S, transfer VHS tapes to DVD, remove commercials, edit video, copy and burn DVDs and video files: AVI (DivX, XviD, etc.), MP4, WMV, 3GP, 3G2, QuickTime (MOV, QT), SWF, DVD, VOB, VRO, MPEG 1,2,4, MPG, DAT, VCD, SVCD, ASF, H.263, H.264, RM, DVR-MS.





There is the free download link:


http://www.dvdtoipod.us/dvdvideoconverte鈥?/a>


There is the tutorial that how to rip DVD or convert among all key video formats


http://www.dvdtoipod.us/dvdvideoguide/ho鈥?/a>

C code. Invalid operands to binary * and /?

5* for first person who helps me fix. Sorry about messy code and comments my compiler doesn't handle copy well.








#include %26lt;stdio.h%26gt;


#include %26lt;stdlib.h%26gt;





/*Asks the user their age, reads input, and returns value*/


void readAge(int *age);





/* Tells the age back*/


void writeAge(int age);





void doubleAge(int *age);





void halveAge (int *age);


/*Sets up the main goal of the function by asking for age and returning


the value along with other statements*/


int main(void) {





/* Interger variable for age. */


int age;





readAge(%26amp;age);





writeAge(age);





doubleAge(%26amp;age);





halveAge(%26amp;age);





/* Tells computer everything is a-ok*/


return EXIT_SUCCESS;





}





void readAge(int *age )


{


printf("How old are you?");


scanf("%d", age);


}





void doubleAge(int *age)


{


printf("Double that time and... \n", age);


writeAge( *age = age * 2);


printf("Wow that's old! \n", age);


}





void halveAge(int *age)


{


printf("Now if I cut your age in half... \n", age);


writeAge(age / 2);


printf("Haha you're almost a kid again! \n", age);


}





/* Repeating statement after every line*/


void writeAge(int age)


{


printf("You are %d!\n\n", age);


}|||writeAge( *age = age * 2);



You are passing the result of an assignment statement to writeAge?



do you mean:



*age *= 2;

writeAge(*age);

Binary to decimal java?

when compiling my program i get an error saying that they cannot find symbol for variable result here is the code


public static int toDecimal (String b)


{





int l = b.length();


int result = 0;


int num_1 = Integer.parseInt(b);








for (int i = 0; i %26lt; l; i++)


{


int power = 1;


for (int p = 1; p %26lt;= i; p++)


{


power = power * 2;





}


if (b.charAt(i) == '1')


{


result = result + power;





}


}


{return result;}


}


public static void main(String[] args) {











String b = "10";





System.out.println(" Decimal for " + b + " is " + result);


}


}


Any help would be much appreciated|||In your main() function, you are referencing variable "result". You did NOT declare it there. You declared that variable inside toDecimal() function.





First of all, make sure you understand what a scope is, and how it works with variables.





You can fix your problem by making result to be a static variable like this:





class test {


static int result;





public static int toDecimal (String b)


{





int l = b.length();


result = 0;


int num_1 = Integer.parseInt(b);








for (int i = 0; i %26lt; l; i++)


{


int power = 1;


for (int p = 1; p %26lt;= i; p++)


{


power = power * 2;





}


if (b.charAt(i) == '1')


{


result = result + power;





}


}


{return result;}


}


public static void main(String[] args) {











String b = "10";





System.out.println(" Decimal for " + b + " is " + result);


}


}








P.S. Your program does not convert the number correctly, but that's up to you to figure that out.|||There's a much easier way to covert that string to decimal.





public static int toDecimal(String b){


return parseInt(b, 2);


}

Will someone please explain binary numbers to me in-depth(like u would with a grade school student)?

k so my mom is in a c++ programming course and her book for the course explains things in a way that i(a normal human being) wouldn't understand. she does'nt either and she is scared she is gonna fail the course. for instance it says note that 65=1x2(6)+0x2(5)+0x2(4)+0x2(3)+0x2(2)+0x鈥?i actually managed to stare at it for hours and grasp it...it works out to 65 and all the 0x and 1x is bits. which makes 1000001...i was baffled at the letters with all the variables and what not and i mean you cant just note that thats like a big math problem thats like saying note that the sun travels at exactly 2489894Xx amount of hours idk all that...i dont have my masters degree or a PHD so will someone please help me learn binary code for dummies?|||Okay .. Binary 001





Counting to 31 on one hand.





The concept to grasp here is that binary is JUST place holders. No incremental variety within the place, just it is, or it isn't. You start with 1, and double your way to the left (so ... 16 8 4 2 1 ). Other than that it works just like any other numbering system. (Decimal, Hexadecimal, Duodecimal, Binary, Base-whatever)





You have a place, and then next to it you have another place. In decimal you might have 15. That would be one Ten and Five ones.





In decimal you might have 1111. That would be an eight, a four a two and a one. Also 15. In Hex that would be F





So on your one hand.. (if you aren't some kind of FREAK) then you have enough fingers to hold a 16s place in binary. Go with your right hand palm towards you. Your thumb represents the Ones place. Pointer Twos, Middle Fours, Ring Eights, Pinky Sixteens. Up is on Down is off. All five fingers up is all on, so a sixteen an eight a four a two and a one is 31.





To figure out how to represent a given number in binary, you play "The Bit Is Right": Where you try to pick the place holder as close to the number you want, without going over, and then subtract that number from your target and play again until you fill the last bit needed to hit yout target.





So for a number like Decimal 11 (ten plus one) you play "The Bit Is Right" on Decimal 11 you get 8, which is the largest bit you can fill without going over. So now you subtract Decimal 8 from Decimal 11 and you have Decimal 3... so you play "The Bit Is Right" on Decimal 3 and you get 2... subtract two from three .. play again you get 1 which is the first bit (always filled in an odd number, always open in an even.)


so Decimal 11 is fill 8 2 and 1 So: 1011.





So your Heavy Metal hand is 19. 4 is "The bird". Peace is 6. and "A-Okay" is 24 depending on how you count that curled pointer finger!!|||It's all about place values.


We usually think in base 10. So, the number 65 is (5 * 10 ^ 0) + (6 * 10 ^ 1)





Note, the * is multiplication and the ^ means "to the power of".





Notice how both the digits 5 and 6 are multiplied by powers of 10.





Since binary is base 2, every digit is multiplied by powers of 2.





As an example, 4 is 100 in binary: (0 * 2 ^ 0) + (0 * 2 ^ 1) + (1 * 2 ^ 2).|||Each number is represented as a 1 or a 0. If it has a 1 it is counted as it place value. Place values are in multiples of 2.





1 2 4 8 16 32 64 128....





so using the numbers above





1 = 1


11 = 1 + 2 or 3


111 = 1 + 2 + 4 or 7


0001 = 0 + 0 + 0 + 8 or just 8





So what would 127 be?





remember our numbers


1 2 4 8 16 32 64 128





use the 1's to represent the number





it would be





1111111





because 1 + 2 + 4+ 8+16 + 32 + 64 = 127





Basically a 1 means that the number in that place is being counted, a 0 means that it is not.

Convert base10 to binary numbers w/ c++?

I've spent all day trying to figure out how to do this. We can't use shortcuts/built in functions. We need 8 if then statements. I'm assuming that's for 128, 64, 32, 16, 8, 4, 2, 1 right? (we're only required to go up to 8 numbers) I thought I made the correct program but it never works. can someone maybe show me a line or two of what to do? Thanks so much!





#include %26lt;iostream%26gt;





using std::cout;


using std::cin;


using std::endl;





int main ()


{


//declare variables


int n1 = 0;


int n2 = 0;


int n3 = 0;


int n4 = 0;


int n5 = 0;


int n6 = 0;


int n7 = 0;


int n8 = 0;








//enter input items


cout %26lt;%26lt; "Please enter a number between 0 and 255: " ;


cin %26gt;%26gt; n1;











//conversion


//128


if (n1 %26gt;= 128)


{


n1 = 1;


}


else


{


n1 = 0;


}


cout %26lt;%26lt; "Binary: " %26lt;%26lt; n1;





//64


n2 = n1 - 128;





//64


n2 = n1 - 128;





if (n2 %26gt;= 64)


{


n2 = 1;


}


else


{


n2 = 0;


}


cout %26lt;%26lt; n2;





//32


n3 = n2 - 64;





if (n3 %26gt;= 32)


{


n3 = 1;


}


else


{








ETC...|||//conversion


//128


if (n1 %26gt;= 128)


{


na = 1;


n1 = n1 - 128;


}


else


{


na = 0;


}


cout %26lt;%26lt; "Binary: " %26lt;%26lt; na;





//64





Do the subtraction only if the number is large enough!|||you are over writing the initial data when you set n1=1;


This causes you to have n2=-127





the best way to get around this is to put the initial data into a separate variable n then do the following;





if (n%26gt;= 128)


{ n1=1; n=n-128;}





if (n%26gt;=64)


{n2=1; n=n-64;}





ETC...





Putting the subtractions in the if statement ensues that you do not subtract the value unnecessarily.





since you have already initialized the values to zero the else statements are unnecessary.





There is another way to solve this problem using loops and division and mod functions. It is mathematically more difficult.





if you were going to have to solve for a larger number I would try it out.





But this should solve you problem, and that would require me to think for a while as i have not used it in several years.

C++ program converting binary to decimal?

what do i need to change this module to make it work, i did not declare any variables in the main function.








void BinToDec()


{ double dec;


int len;


string bin;


bin= “ ”





cout %26lt;%26lt;"Converting from Binary to Decimal number. Please enter a binary number" %26lt;%26lt;endl;


len=bin.len()


for (i=1; i%26lt;=len ; i++)


if (bin.at(i-1)==’1’)


dec = dec + pow(2, len-i);


}|||Also, you are not initializing dec, its value will be whatever garbage was left in memory.





Also again, using a double and calling pow is a waste, binary numbers are always whole numbers (except for IEEE-spec floating point registers, but that clearly does not apply here.)





Use the left-shift operator instead, it is much more efficient:





unsigned long dec = 0;


int len = bin.len();


for (i = len - 1; i %26gt;= 0; i--)


   if (bin.at(i) == '1')


      dec |= (1 %26lt;%26lt; i);|||Well for starters, after this:





cout %26lt;%26lt;"Converting from Binary to Decimal number. Please enter a binary number" %26lt;%26lt;endl;





You are asking the user to enter a binary number, yet, you have no input requests in your function such as:





getline(std::cin, bin);

Discrete Math: Unary and binary predicates?

For natural number x and y, define x mod y to be the remainder obtained upon dividing x by y. Allowing the variables x and y to range over the domain of natural numbers, let P(x,y) denote the binary predicate "x mod 2 = y mod 2" and let Q(x,y) denote the binary predicate "x mod 3= y mod 3."





(a) Is P(x,y) an equivalence relation? Justify your answer.


(b) Fix a natural number n. If P(n,2) holds, what must be true of n? What about if P(n,1) holds? For a fixed natural number n, must at least one of P(n,2) or P(n,1) hold? Can both P(n,2) and P(n,1) hold for a single natural number n?


(c)List the natural number n for which Q(n,1) holds, list the natural which Q(n,3) holds. Do the three lists have any natural numbers in common? Does every natural number appear in at least one of the three lists? For each of the lists, the collection of numbers appearing in that list is said to be an equivalence class of the equivalence relation Q(x,y). What are the equivalence classes of the equivalence relation P(x,y)?|||(A) An equivalence relation requires reflexivity, symmetry, and transitivity. If x,y,z are natural numbers, we check


x mod 2 = x mod 2


x mod 2 = y mod 2 =%26gt; y mod 2 = x mod 2


x mod 2 = y mod 2 and y mod 2 = z mod 2 =%26gt; x mod 2 = z mod 2


So we conclude it is an equivalence relation.





(B) P(n,2) simply says x mod 2 = 2 mod 2. But 2 mod 2 = 0 mod 2. So, by transitivity, we can conclude that n is even. On the other hand, if P(n,1) holds then n is odd. Obviously, every natural number is either even or odd, but not both.





(C) { n | Q(n,1)} = {1,4,7,10,13,...}


{ n | Q(n,2)} = {2,5,8,11,14,...}


{ n | Q(n,3)} = {0,3,6,9,12,...}


These are disjoint, i.e. they don't share anything, and they are the equivalence classes mod 3. The equivalence classes for P(x,y) are simply the even natural numbers and odd natural numbers.

Binary tree question... More of a misunderstanding of how they work.?

I understand how they speed up sort times. What I don't understand is how to implement them with multiple variables. If I have the Tree setup to sort the names how does it help when I want to sort on city, or state, or some other type of information?


Would I make a tree for each type of information?


When dealing with records with various amounts of information, how do binary trees come in to play is my real question?|||You would create a tree for each type of information you wanted to search/sort on. This is (at a rudimentary level) the same as creating an index in SQL for the different data queries you expect to make.





In situations where you want to sort on multiple values all at once, you would either combine all the values you want to use into a single value which could then be used as a single key or create separate sub-trees for each deeper value.





When using multiple values, search order becomes very important and depending on your algorithms you can run into some pretty hefty roadblocks with complex data designs. Although it's worth it to understand how a binary tree works, I highly recommend not trying to reinvent the wheel for any complex data tree. Find and use the methods that are available through the software you are using, or add/implement public domain code.|||What i've understood through your question is that u want to store multiple names in a single tree. Its so simple, Make the node of the tree with as many data containers as you want.


the basic structure would be


class node


{


int *right; // Address of right leaf


int *left; // address of left leaf


char *city; // your datum


char *state; // your datum


char *XYZ; // your datum


}|||I would suppose that non-numeric data is hashed somehow. It's the same way that String keys are hashed into numeric indices using bit manipulation, prime numbers, modulo arithmetic, etc. Then you can combine these hashed numbers.

Adding Binary numbers ?

// Oct 27, 2008


// Converting double to int and vice versa.


// Example for class CSE110





public class Lab6


{


public static void main(String[] args)


{





// See the program structure given at the end.





}


}





Read time using Console.readDouble method. Use "Type in time as


a decimal number" for your prompt string. Do not forget to


declare time as a variable of type double.





f. Declare hours and minutes as integers. Extract hours from time


using hours = (int)time. Obtain non-integer part of time in a


variable temp of type double. This will be in minutes, as a


decimal number. Try double temp = (time - hours)*60.0;


From temp, extract/separate integer part and store it in variable


minutes.





g. Include a statement to print hours and minutes.





h. Save your program as Lab6.java. Compile and execute. For time =


3.42, your program should print Hours = 3 Minutes = 25





3. Insert a while-loop





i Now suppose we want to run this as long as user is willing to


supply values for time. So we ask user if he/she wants to con-


tinue. If the response is Y, then we ask for a new value, else we


stop execution.





j. Declare a variable c of type char. Initialize it to value `Y',


before the loop. Place most of the code (except declarations)


inside a while loop with condition (c == 'Y').





k. At the end of loop, ask user a question. Read the response using


Console.readChar("Do you want to continue? Type Y/N ");


Read this value in variable c.





l. Save compile and run. Try different values for time and make sure


that it is printing correct values. For help see page 391 of the


textbook. It has a similar while loop.





4. Calculating seconds (Add this later)





m. We calculated hours and minutes from time. Now follow similar


steps and obtain seconds. Modify the print statement so that it


prints seconds as well.





n. This may or may not be an exact conversion to seconds. But the


error will be only in the last digit of seconds. DO NOT round to


the next higher value.





o. Save, compile and run your Lab6. Try time = 3.42 hours. When


split into 3 values, your program should print,


Hours = 3 Minutes = 25 and Seconds = 11


You must print like the example above.





Correction: Actually Java calculates double value of seconds


equal to 11.99999999999996. After casting you will get 11. This


a good example why rounding is useful.





p. Try some other value such as time = 6.249. See what is printed.


Use your calculator to verify the results.





6. Rounding time. (Add this later)





q. Now suppose we want to print a rounded integer value for time.


Remember time is of type double. Think how will you round it to


next higher integer if necessary. For example, with time = 3.42,


Rounded value of time is 3 hours. But if time = 3.74, the Rounded


value of time 4 hours. So if the fractional part is more than or


equal to 0.5 then we round it to the next higher integer, otherw-


ise we just get the integer part.





r. You just need one statement to obtain the rounded value of time.


Here again you need to cast to integer variable. Add one more


println statement that prints the rounded value. You must print


like this.


Rounded value of time is ..... hours.





7. Part-II





s. In the code, this part is after Part-I, but still inside the


while-loop. For this, read two integer variables feet and


inches. Use Console.readInt twice for this purpose. Assume that


inches will be less than equal to 11.





t. Convert feet and inches to a decimal value called length. We


want to print entire length as a decimal number in feet.


Although not necessary, you MUST first convert feet to a double


value. Use type casting. Similarly convert inches to a double


value after dividing it by 12.0. Add two double values to get


length in feet. To get full credit, explicit casting of types is


REQUIRED. For example (double)feet.





u. Insert one more println statement for printing length as a double


value.





v. Save, compile and execute. Try feet = 5 and inches = 11. Your


program should print in this format. Length in feet = 5.91666





w. Your program must have both parts, and the while-loop for con-


tinuation. Submit your program using ~cse110/submit command


before the due date (Nov 3, 11am).





Program Structure:








Declarations for part-I and part-II.





Initialization if any.





While loop starts





Part-I





Read time using Console.readDo|||Binary numbers are not referenced in your text. Binary ( base 2) was the initial form of computer programming. Adding binary numbers is done by microprocessors, some having decimal mode ( 6502), up to their programmed limits. Your request is best written in assembly language, not C.