Why does the capitalization of words change the hash output so significantly in Keccak-256?
Example: Lets use sandy, Sandy
Input 1: Sandy
Output 1: 531e7238b18a2a98325e9378315ae7575250d3a65549eeed760b5128505f28f6
Input 2: sandy
Output 2: c451bebea4e5a4c987cfc8cb94f4824abd60b02348bf081b063d22d9cede0dff
Can anyone let me know why is the Output so different?
Related
I have a file names inputR_revised.tsv at https://www.dropbox.com/s/vtby4027rvprhga/inputR_revised.tsv?dl=0
In matlab, I typed
fid=fopen('BMC3C/example/inputR_revised.tsv','r')
covTable = textscan(fid,['%s',repmat('%.8n',[1,20])],'HeaderLines',1);
I get covTable{1,1} of size 41699 times 1. However when I type the following at terminal
wc -l inputR_revised.tsv
I get 41677.
Why does it differ? I have used sed and cut to modify the original file to get inputR_revised.tsv. Is this the reason?
Is there a way to fix this?
%.8 is not enough if you have decimals printed with more than 8 digits. For these cases digits after the 8th decimal could be treated as a separate entry. That will make more numbers than expected. You should use a higher value for number of decimals in the scan format. For example,
fid=fopen('BMC3C/example/inputR_revised.tsv','r')
covTable = textscan(fid,['%s',repmat('%.18n',[1,20])],'HeaderLines',1);
This should give you the correct number of rows.
I'm trying to do some text analysis to determine if a given string is... talking about politics. I'm thinking I could create a neural network where the input is either a string or a list of words (ordering might matter?) and the output is whether the string is about politics.
However the brain.js library only takes inputs of a number between 0 and 1 or an array of numbers between 0 and 1. How can I coerce my data in such a way that I can achieve the task?
new brain.recurrent.LSTM();
this does the trick for you.
Example,
var brain = require('brain.js')
var net = new brain.recurrent.LSTM();
net.train([
{input: "my unit-tests failed.", output: "software"},
{input: "tried the program, but it was buggy.", output: "software"},
{input: "i need a new power supply.", output: "hardware"},
{input: "the drive has a 2TB capacity.", output: "hardware"},
{input: "unit-tests", output: "software"},
{input: "program", output: "software"},
{input: "power supply", output: "hardware"},
{input: "drive", output: "hardware"},
]);
console.log("output = "+net.run("drive"));
output = hardware
refer to this link=> https://github.com/BrainJS/brain.js/issues/65
this has clear explanation and usage of brain.recurrent.LSTM()
You need to come up with the model to convert your data to a list of tuples [input, expected_output], where input is a list of numbers between 0 and 1 representing the given words, and output is one number between 0 and 1 representing how close the sentence is to your objective analysis (being political). For example, for the sentence "The quick brown cat jumped over the lazy dog" you might want to give a score of zero. A sentence like "President shakes off corruption scandal" you might want to give a score very close to one.
As you can see, your biggest challenge is actually obtaining the data and cleaning it. Converting it to the training format is easy, you could just hash words into numbers between 0 and 1, and make sure to handle different casing, punctuation, and you might want to step words to get the best results.
One more thing, you can use a term relevance algorithm to rank the importance of words in your training data set, so that you can choose only the top k relevant words in a sentence, since you need uniform data size for each sentence.
So apparently text doesn't coerce very well to NN input.
A Naive Bayes Classifier looks like exactly what I want. https://github.com/harthur/classifier
I'm asked to do a program that asks for two numbers, the first variable for example is 4 and the second is 5, i need the program to show the first variable as 5 and the second one as 4, so i need the variables to exchange their values
Thanks :DDDD
I think you are asking for number swapping logic.So you can use two logic to swap the number
1. By using 3rd variable.
2. Without using 3rd variable.
Their respective logic's are as follows.
Suppose you have x=4,y=5;
take 3rd variable like temp;
temp=x; x=y; y=temp;
and 2nd logic.
x = x+y; y=x-y; x=x-y;
Such questions are usually asked to reduce the space complexity and to do so we take the following approach:
a=a+b;
b=a-b;
a=a-b;
for example we take a=4 and b=5
a becomes 9
b becomes 4
a becomes 5
finally a=5 and b=4 (swapped)
I need to generate a random number that is between .0000001 and 1, I have been using rand(1) but this only gives me 4 decimal points, is there any other way to do this generation?
Thanks!
From the Octave docs:
By default, Octave displays 5 significant digits in a human readable form (option ‘short’ paired with ‘loose’ format for matrices).
So it's probably an issue with the way you're printing the value rather than the value itself.
That same page shows the other output formats in addition to short, the one you may want to look in to is long, giving 15 significant digits.
And there is also the output_precision which can be set as per here:
old_val = output_precision (7)
disp (whatever)
old_val = output_precision (old_val)
Set the output_precision to 7 and it should be ok :)
Setting the output precision won't help though because the number can still be less than .0000001 in theory but you will only be displaying the first 7 digits. The simplest way is:
req=0;
while (req<.0000001)
req=rand(1);
end
It is possible that this could get you stuck in a loop but it will produce the right number. To display all the decimals you can also use the following command:
format long
This will show you 15 decimal places. To switch back go:
formay short
I have made a regression tree, but Matlab shows numbers with 6 significant figures. The tree is very dense, and I don't need such a high precision, which makes it hard to read.
How can I change it to 3 figures for example?
you can use vpa
e.g.
vpa([114.234 0.0013452],3)= [ 114.0, 0.00135]
I think you need the following
while printing something you may use
a=2.335444444444
sprintf ('%.2f',a) % I want to print 2 significant digits of a only
Output
ans =
2.34
Try changing the format to something of your taste (help format)
You may be interested in:
format bank
or
format short