Why is the accurcy of my neural network not improving - machine-learning
The accurcy of my neural network stop at 70% and not inproving. Please help me. Below is my code.
import tensorflow as tf
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from sklearn.decomposition import PCA
from sklearn.preprocessing import MinMaxScaler
data = pd.read_csv("data.csv", sep='|')
nonlinearitiesactFunction = {'sigmoid':tf.sigmoid, 'tanh':tf.tanh, 'elu':tf.nn.elu, 'softplus':tf.nn.softplus, 'softsign':tf.nn.softsign}
linearitiesactFunction = {'relu':tf.nn.relu, 'relu6':tf.nn.relu6}
clFunction = {'sigmoidCrossEntropy':tf.nn.sigmoid_cross_entropy_with_logits, 'softmax':tf.nn.softmax, 'softmaxCrossEntropy':tf.nn.softmax_cross_entropy_with_logits}
opt = {'Adam':tf.train.AdamOptimizer, 'GradientDescent':tf.train.GradientDescentOptimizer}
def retrieveXAndY():
X = data.drop(['Name', 'md5', 'legitimate'], axis=1 ).as_matrix()
y = data['legitimate'].as_matrix()
return X, y
def addLayer(input, inSize, outSize, activationFunction = None):
hiddenlay = {'weights':tf.Variable(tf.random_normal([inSize, outSize])),'biases':tf.Variable(tf.random_normal([outSize]))}
hl = tf.add(tf.matmul(input,hiddenlay['weights']), hiddenlay['biases'])
if activationFunction == None:
output = hl
else:
output = activationFunction(hl)
return output
def costAndOpt(y,output, n_samples, learning_rate, optFunction = None):
cost = tf.reduce_sum(tf.pow(y - output, 2))/(2*n_samples)
optimizer = optFunction(learning_rate).minimize(cost)
return cost, optimizer
def fiveLayer(x, n_nodes_hl1, n_nodes_hl2, n_nodes_hl3, n_nodes_hl4, n_nodes_hl5, n_output, activationFunction, optFunction):
l1 = addLayer(x, n_feature,n_nodes_hl1,activationFunction)
l2 = addLayer(l1, n_nodes_hl1,n_nodes_hl2,activationFunction)
l3 = addLayer(l2, n_nodes_hl2,n_nodes_hl3,activationFunction)
l4 = addLayer(l3, n_nodes_hl3,n_nodes_hl4,activationFunction)
l5 = addLayer(l4, n_nodes_hl4,n_nodes_hl5,activationFunction)
output = addLayer(l5, n_nodes_hl5, n_output, activationFunction)
cost, optimizer = costAndOpt(y,output, n_samples, learning_rate, optFunction)
return cost, optimizer
if __name__ == '__main__':
inputX, inputY = retrieveXAndY()
#Normalization
pca_input = PCA(n_components = int(inputX.shape[1]/2))
inputX = pca_input.fit_transform(inputX)
inputX = MinMaxScaler().fit_transform(inputX)
inputY = inputY.reshape([-1,1])
n_samples = inputY.size
n_feature = inputX.shape[1]
n_node = 40
display_step = 50
learning_rate=0.01
n_nodes_hl1 = n_node
n_nodes_hl2 = n_node
n_nodes_hl3 = n_node
n_nodes_hl4 = n_node
n_nodes_hl5 = n_node
n_output = 1 #number of output
#input data
x = tf.placeholder(tf.float32,[None,n_feature]) #feature
y = tf.placeholder(tf.float32,[None,n_output]) #label#cost, optimizer
cost, optimizer = fiveLayer(x, n_nodes_hl1, n_nodes_hl2, n_nodes_hl3, n_nodes_hl4, n_nodes_hl5, n_output, nonlinearitiesactFunction['softsign'], opt['Adam'])
cost1, optimizer1 = fiveLayer(x, n_nodes_hl1, n_nodes_hl2, n_nodes_hl3, n_nodes_hl4, n_nodes_hl5, n_output, clFunction['softmax'], opt['Adam'])
cost2, optimizer2 = fiveLayer(x, n_nodes_hl1, n_nodes_hl2, n_nodes_hl3, n_nodes_hl4, n_nodes_hl5, n_output, nonlinearitiesactFunction['softsign'], opt['Adam'])
cost3, optimizer3 = fiveLayer(x, n_nodes_hl1, n_nodes_hl2, n_nodes_hl3, n_nodes_hl4, n_nodes_hl5, n_output, nonlinearitiesactFunction['sigmoid'], opt['Adam'])
cost4, optimizer4 = fiveLayer(x, n_nodes_hl1, n_nodes_hl2, n_nodes_hl3, n_nodes_hl4, n_nodes_hl5, n_output, nonlinearitiesactFunction['tanh'], opt['Adam'])
cost5, optimizer5 = fiveLayer(x, n_nodes_hl1, n_nodes_hl2, n_nodes_hl3, n_nodes_hl4, n_nodes_hl5, n_output, nonlinearitiesactFunction['elu'], opt['Adam'])
hm_epochs = 2000
init = tf.global_variables_initializer()
with tf.Session() as sess:
sess.run(init)
for i in range(hm_epochs):
# Take a gradient descent step using our inputs and labels
_,c = sess.run([optimizer,cost],feed_dict={x: inputX, y: inputY})
epoch_loss = 0
if (i) % display_step == 0:
epoch_loss += c
print "Softmax Training step:", i, "cost=", c, 'loss=', epoch_loss #, \"W=", sess.run(W), "b=", sess.run(b)
mse = cost.eval({x: inputX, y: inputY})
acc = 1-np.sqrt(mse)
print "Acc = ", acc, "\n"
for i in range(hm_epochs):
# Take a gradient descent step using our inputs and labels
_,c1 = sess.run([optimizer1,cost1],feed_dict={x: inputX, y: inputY})
epoch_loss1 = 0
if (i) % display_step == 0:
epoch_loss1 += c1
print "Softsign Training step:", i, "cost=", c1, 'loss=', epoch_loss1 #, \"W=", sess.run(W), "b=", sess.run(b)
mse1 = cost1.eval({x: inputX, y: inputY})
acc1 = 1-np.sqrt(mse1)
print "Acc = ", acc1, "\n"
for i in range(hm_epochs):
# Take a gradient descent step using our inputs and labels
_,c2 = sess.run([optimizer2,cost2],feed_dict={x: inputX, y: inputY})
epoch_loss2 = 0
if (i) % display_step == 0:
epoch_loss2 += c2
print "Sigmoid Training step:", i, "cost=", c2, 'loss=', epoch_loss2 #, \"W=", sess.run(W), "b=", sess.run(b)
mse2 = cost2.eval({x: inputX, y: inputY})
acc2 = 1-np.sqrt(mse2)
print "Acc = ", acc2, "\n"
for i in range(hm_epochs):
# Take a gradient descent step using our inputs and labels
_,c3 = sess.run([optimizer3,cost3],feed_dict={x: inputX, y: inputY})
epoch_loss3 = 0
if (i) % display_step == 0:
epoch_loss3 += c3
print "tanh Training step:", i, "cost=", c3, 'loss=', epoch_loss3 #, \"W=", sess.run(W), "b=", sess.run(b)
mse3 = cost3.eval({x: inputX, y: inputY})
acc3 = 1-np.sqrt(mse3)
print "Acc = ", acc3, "\n"
for i in range(hm_epochs):
# Take a gradient descent step using our inputs and labels
_,c4 = sess.run([optimizer4,cost4],feed_dict={x: inputX, y: inputY})
epoch_loss4 = 0
if (i) % display_step == 0:
epoch_loss4 += c4
print "elu Training step:", i, "cost=", c4, 'loss=', epoch_loss4 #, \"W=", sess.run(W), "b=", sess.run(b)
mse4 = cost4.eval({x: inputX, y: inputY})
acc4 = 1-np.sqrt(mse4)
print "Acc = ", acc4, "\n"
I am using a dataset with 60000 records. Below is example of part of the dataset or can download the dataset from https://archive.ics.uci.edu/ml/datasets/Detect+Malacious+Executable(AntiVirus):
inputX = array([[ 3.32000000e+02, 2.24000000e+02, 8.45000000e+03,
8.00000000e+00, 0.00000000e+00, 5.32480000e+04,
1.63840000e+04, 0.00000000e+00, 5.40480000e+04,
4.09600000e+03, 5.73440000e+04, 2.08594534e+09,
4.09600000e+03, 4.09600000e+03, 4.00000000e+00,
0.00000000e+00, 8.00000000e+00, 0.00000000e+00,
4.00000000e+00, 0.00000000e+00, 7.37280000e+04,
4.09600000e+03, 1.20607000e+05, 2.00000000e+00,
3.20000000e+02, 1.04857600e+06, 4.09600000e+03,
1.04857600e+06, 4.09600000e+03, 0.00000000e+00,
1.60000000e+01, 4.00000000e+00, 2.70373594e+00,
1.05637876e+00, 6.22819008e+00, 1.63840000e+04,
4.09600000e+03, 5.32480000e+04, 1.59390000e+04,
9.92000000e+02, 5.28640000e+04, 6.00000000e+00,
1.37000000e+02, 8.10000000e+01, 2.50000000e+01,
1.00000000e+00, 3.52426821e+00, 3.52426821e+00,
3.52426821e+00, 8.92000000e+02, 8.92000000e+02,
8.92000000e+02, 7.20000000e+01, 1.60000000e+01],
[ 3.32000000e+02, 2.24000000e+02, 8.45000000e+03,
8.00000000e+00, 0.00000000e+00, 5.27360000e+04,
1.12640000e+04, 0.00000000e+00, 5.35300000e+04,
4.09600000e+03, 5.73440000e+04, 2.08699392e+09,
4.09600000e+03, 5.12000000e+02, 4.00000000e+00,
0.00000000e+00, 8.00000000e+00, 0.00000000e+00,
4.00000000e+00, 0.00000000e+00, 7.37280000e+04,
1.02400000e+03, 8.92300000e+04, 2.00000000e+00,
3.20000000e+02, 1.04857600e+06, 4.09600000e+03,
1.04857600e+06, 4.09600000e+03, 0.00000000e+00,
1.60000000e+01, 4.00000000e+00, 4.31899422e+00,
3.30769150e+00, 6.15499505e+00, 1.42080000e+04,
1.02400000e+03, 5.27360000e+04, 1.57382500e+04,
9.92000000e+02, 5.22730000e+04, 6.00000000e+00,
1.33000000e+02, 8.10000000e+01, 2.50000000e+01,
1.00000000e+00, 3.54207119e+00, 3.54207119e+00,
3.54207119e+00, 8.92000000e+02, 8.92000000e+02,
8.92000000e+02, 7.20000000e+01, 1.60000000e+01],
[ 3.32000000e+02, 2.24000000e+02, 8.45000000e+03,
8.00000000e+00, 0.00000000e+00, 4.09600000e+04,
2.04800000e+04, 0.00000000e+00, 2.66080000e+04,
4.09600000e+03, 4.50560000e+04, 1.92151552e+09,
4.09600000e+03, 4.09600000e+03, 4.00000000e+00,
0.00000000e+00, 0.00000000e+00, 0.00000000e+00,
4.00000000e+00, 0.00000000e+00, 6.55360000e+04,
4.09600000e+03, 1.21734000e+05, 2.00000000e+00,
3.20000000e+02, 1.04857600e+06, 4.09600000e+03,
1.04857600e+06, 4.09600000e+03, 0.00000000e+00,
1.60000000e+01, 5.00000000e+00, 3.58061262e+00,
8.04176679e-02, 6.23193618e+00, 1.22880000e+04,
4.09600000e+03, 4.09600000e+04, 1.04442000e+04,
9.64000000e+02, 3.76480000e+04, 2.00000000e+00,
6.80000000e+01, 0.00000000e+00, 1.12000000e+02,
6.00000000e+00, 3.00438262e+00, 2.40651198e+00,
3.59262288e+00, 6.10333333e+02, 1.24000000e+02,
1.41200000e+03, 7.20000000e+01, 1.60000000e+01],
[ 3.32000000e+02, 2.24000000e+02, 2.58000000e+02,
1.10000000e+01, 0.00000000e+00, 3.54816000e+05,
2.57024000e+05, 0.00000000e+00, 1.83632000e+05,
4.09600000e+03, 3.60448000e+05, 4.19430400e+06,
4.09600000e+03, 5.12000000e+02, 5.00000000e+00,
1.00000000e+00, 0.00000000e+00, 0.00000000e+00,
5.00000000e+00, 1.00000000e+00, 6.26688000e+05,
1.02400000e+03, 0.00000000e+00, 2.00000000e+00,
3.30880000e+04, 1.04857600e+06, 4.09600000e+03,
1.04857600e+06, 4.09600000e+03, 0.00000000e+00,
1.60000000e+01, 5.00000000e+00, 4.59039653e+00,
2.37894684e+00, 6.29682587e+00, 1.20524800e+05,
7.68000000e+03, 3.54816000e+05, 1.22148600e+05,
1.64680000e+04, 3.54799000e+05, 7.00000000e+00,
1.38000000e+02, 0.00000000e+00, 0.00000000e+00,
7.00000000e+00, 3.91441476e+00, 1.44168828e+00,
7.67709054e+00, 7.29842857e+03, 1.60000000e+01,
2.84380000e+04, 7.20000000e+01, 0.00000000e+00],
[ 3.32000000e+02, 2.24000000e+02, 2.71000000e+02,
6.00000000e+00, 0.00000000e+00, 2.40640000e+04,
1.64864000e+05, 1.02400000e+03, 1.25380000e+04,
4.09600000e+03, 2.86720000e+04, 4.19430400e+06,
4.09600000e+03, 5.12000000e+02, 4.00000000e+00,
0.00000000e+00, 6.00000000e+00, 0.00000000e+00,
4.00000000e+00, 0.00000000e+00, 2.41664000e+05,
1.02400000e+03, 0.00000000e+00, 2.00000000e+00,
3.27680000e+04, 1.04857600e+06, 4.09600000e+03,
1.04857600e+06, 4.09600000e+03, 0.00000000e+00,
1.60000000e+01, 5.00000000e+00, 4.10454072e+00,
0.00000000e+00, 6.44010555e+00, 6.75840000e+03,
0.00000000e+00, 2.40640000e+04, 4.62608000e+04,
3.14400000e+03, 1.54712000e+05, 8.00000000e+00,
1.55000000e+02, 1.00000000e+00, 0.00000000e+00,
6.00000000e+00, 3.19910735e+00, 1.97133529e+00,
5.21481585e+00, 4.52000000e+02, 3.40000000e+01,
9.58000000e+02, 0.00000000e+00, 1.50000000e+01],
[ 3.32000000e+02, 2.24000000e+02, 2.58000000e+02,
1.00000000e+01, 0.00000000e+00, 1.18784000e+05,
3.81952000e+05, 0.00000000e+00, 5.99140000e+04,
4.09600000e+03, 1.22880000e+05, 4.19430400e+06,
4.09600000e+03, 5.12000000e+02, 5.00000000e+00,
1.00000000e+00, 0.00000000e+00, 0.00000000e+00,
5.00000000e+00, 1.00000000e+00, 5.20192000e+05,
1.02400000e+03, 5.58287000e+05, 2.00000000e+00,
3.30880000e+04, 1.04857600e+06, 4.09600000e+03,
1.04857600e+06, 4.09600000e+03, 0.00000000e+00,
1.60000000e+01, 5.00000000e+00, 5.66240790e+00,
4.18369159e+00, 7.96187140e+00, 1.00147200e+05,
9.21600000e+03, 3.34848000e+05, 1.01559800e+05,
9.36800000e+03, 3.34440000e+05, 7.00000000e+00,
1.14000000e+02, 0.00000000e+00, 0.00000000e+00,
1.80000000e+01, 6.53094643e+00, 2.45849223e+00,
7.99268848e+00, 1.85234444e+04, 4.80000000e+01,
3.39450000e+04, 7.20000000e+01, 1.40000000e+01],
[ 3.32000000e+02, 2.24000000e+02, 2.58000000e+02,
1.00000000e+01, 0.00000000e+00, 1.74592000e+05,
3.00032000e+05, 0.00000000e+00, 1.17140000e+05,
4.09600000e+03, 1.80224000e+05, 4.19430400e+06,
4.09600000e+03, 5.12000000e+02, 5.00000000e+00,
1.00000000e+00, 0.00000000e+00, 0.00000000e+00,
5.00000000e+00, 1.00000000e+00, 4.87424000e+05,
1.02400000e+03, 5.13173000e+05, 2.00000000e+00,
3.30880000e+04, 1.04857600e+06, 4.09600000e+03,
1.04857600e+06, 4.09600000e+03, 0.00000000e+00,
1.60000000e+01, 5.00000000e+00, 5.73547047e+00,
4.75826034e+00, 7.36431335e+00, 9.30816000e+04,
1.53600000e+04, 1.92000000e+05, 9.46988000e+04,
2.15000000e+04, 1.91664000e+05, 1.10000000e+01,
2.54000000e+02, 1.50000000e+01, 0.00000000e+00,
1.50000000e+01, 5.73239307e+00, 2.85236422e+00,
7.98772639e+00, 1.27061333e+04, 1.18000000e+02,
6.05000000e+04, 7.20000000e+01, 1.40000000e+01],
[ 3.32000000e+02, 2.24000000e+02, 2.58000000e+02,
9.00000000e+00, 0.00000000e+00, 4.75648000e+05,
3.48672000e+05, 0.00000000e+00, 3.19769000e+05,
4.09600000e+03, 4.83328000e+05, 4.19430400e+06,
4.09600000e+03, 5.12000000e+02, 5.00000000e+00,
0.00000000e+00, 0.00000000e+00, 0.00000000e+00,
5.00000000e+00, 0.00000000e+00, 8.56064000e+05,
1.02400000e+03, 1.82072586e+09, 2.00000000e+00,
3.30880000e+04, 1.04857600e+06, 4.09600000e+03,
1.04857600e+06, 4.09600000e+03, 0.00000000e+00,
1.60000000e+01, 5.00000000e+00, 5.13993423e+00,
4.48079036e+00, 6.55814891e+00, 1.64864000e+05,
1.38240000e+04, 4.75648000e+05, 1.68145200e+05,
3.08400000e+04, 4.75580000e+05, 1.40000000e+01,
4.21000000e+02, 1.50000000e+01, 0.00000000e+00,
5.90000000e+01, 2.82782573e+00, 9.60953136e-01,
7.21232881e+00, 2.63703390e+03, 2.00000000e+01,
6.76240000e+04, 7.20000000e+01, 0.00000000e+00],
[ 3.32000000e+02, 2.24000000e+02, 2.59000000e+02,
9.00000000e+00, 0.00000000e+00, 1.57696000e+05,
6.24640000e+04, 0.00000000e+00, 6.70150000e+04,
4.09600000e+03, 1.63840000e+05, 4.19430400e+06,
4.09600000e+03, 5.12000000e+02, 5.00000000e+00,
0.00000000e+00, 0.00000000e+00, 0.00000000e+00,
5.00000000e+00, 0.00000000e+00, 2.33472000e+05,
1.02400000e+03, 2.72988000e+05, 2.00000000e+00,
3.30240000e+04, 1.04857600e+06, 4.09600000e+03,
1.04857600e+06, 4.09600000e+03, 0.00000000e+00,
1.60000000e+01, 4.00000000e+00, 4.81988481e+00,
2.97736539e+00, 6.48512410e+00, 5.50400000e+04,
3.58400000e+03, 1.57696000e+05, 5.56267500e+04,
6.70000000e+03, 1.57297000e+05, 2.00000000e+00,
7.60000000e+01, 0.00000000e+00, 0.00000000e+00,
1.30000000e+01, 3.94329633e+00, 1.81444345e+00,
6.12204520e+00, 2.70815385e+03, 1.32000000e+02,
9.64000000e+03, 7.20000000e+01, 1.40000000e+01],
[ 3.32000000e+02, 2.24000000e+02, 2.59000000e+02,
8.30000000e+01, 8.20000000e+01, 7.24992000e+05,
2.30604800e+06, 0.00000000e+00, 4.24345600e+06,
3.52256000e+06, 4.30899200e+06, 4.19430400e+06,
4.09600000e+03, 4.09600000e+03, 5.00000000e+00,
0.00000000e+00, 0.00000000e+00, 0.00000000e+00,
5.00000000e+00, 0.00000000e+00, 6.70924800e+06,
4.09600000e+03, 3.07704700e+06, 2.00000000e+00,
3.27680000e+04, 1.04857600e+06, 4.09600000e+03,
1.04857600e+06, 4.09600000e+03, 0.00000000e+00,
1.60000000e+01, 9.00000000e+00, 3.78312500e+00,
0.00000000e+00, 7.99951830e+00, 3.36782222e+05,
0.00000000e+00, 1.88416000e+06, 7.44182333e+05,
2.27200000e+03, 3.06129900e+06, 4.00000000e+00,
2.43000000e+02, 0.00000000e+00, 0.00000000e+00,
2.10000000e+01, 3.98746295e+00, 2.64215931e+00,
6.47369968e+00, 1.42880000e+04, 7.60000000e+01,
2.70376000e+05, 0.00000000e+00, 0.00000000e+00],
[ 3.32000000e+02, 2.24000000e+02, 2.58000000e+02,
1.00000000e+01, 0.00000000e+00, 1.20320000e+05,
3.85024000e+05, 0.00000000e+00, 6.15780000e+04,
4.09600000e+03, 1.26976000e+05, 4.19430400e+06,
4.09600000e+03, 5.12000000e+02, 5.00000000e+00,
1.00000000e+00, 0.00000000e+00, 0.00000000e+00,
5.00000000e+00, 1.00000000e+00, 5.28384000e+05,
1.02400000e+03, 5.66330000e+05, 2.00000000e+00,
3.30880000e+04, 1.04857600e+06, 4.09600000e+03,
1.04857600e+06, 4.09600000e+03, 0.00000000e+00,
1.60000000e+01, 5.00000000e+00, 5.64644365e+00,
4.11726412e+00, 7.96277585e+00, 1.01068800e+05,
9.72800000e+03, 3.30752000e+05, 1.02623800e+05,
9.40400000e+03, 3.39652000e+05, 3.00000000e+00,
8.90000000e+01, 0.00000000e+00, 0.00000000e+00,
6.00000000e+00, 3.72982391e+00, 2.45849223e+00,
5.31755236e+00, 2.73950000e+03, 4.80000000e+01,
9.64000000e+03, 7.20000000e+01, 1.50000000e+01],
[ 3.32000000e+02, 2.24000000e+02, 2.59000000e+02,
1.00000000e+01, 0.00000000e+00, 2.33984000e+05,
1.37779200e+06, 0.00000000e+00, 9.31200000e+04,
4.09600000e+03, 2.41664000e+05, 4.19430400e+06,
4.09600000e+03, 5.12000000e+02, 5.00000000e+00,
1.00000000e+00, 0.00000000e+00, 0.00000000e+00,
5.00000000e+00, 1.00000000e+00, 1.63020800e+06,
1.02400000e+03, 1.66150900e+06, 2.00000000e+00,
3.32800000e+04, 1.04857600e+06, 4.09600000e+03,
1.04857600e+06, 4.09600000e+03, 0.00000000e+00,
1.60000000e+01, 3.00000000e+00, 5.46068132e+00,
3.13962777e+00, 7.09009944e+00, 5.37258667e+05,
5.63200000e+03, 1.37216000e+06, 5.39602667e+05,
1.33160000e+04, 1.37185600e+06, 1.00000000e+00,
8.00000000e+01, 0.00000000e+00, 0.00000000e+00,
1.80000000e+01, 4.32832189e+00, 2.32321967e+00,
7.06841290e+00, 7.61582778e+04, 9.00000000e+00,
1.34273500e+06, 7.20000000e+01, 1.90000000e+01],
[ 3.32000000e+02, 2.24000000e+02, 2.71000000e+02,
6.00000000e+00, 0.00000000e+00, 4.91520000e+04,
5.61152000e+05, 0.00000000e+00, 3.38800000e+04,
4.09600000e+03, 5.32480000e+04, 4.19430400e+06,
4.09600000e+03, 4.09600000e+03, 4.00000000e+00,
0.00000000e+00, 0.00000000e+00, 0.00000000e+00,
4.00000000e+00, 0.00000000e+00, 6.14400000e+05,
4.09600000e+03, 0.00000000e+00, 2.00000000e+00,
0.00000000e+00, 1.04857600e+06, 4.09600000e+03,
1.04857600e+06, 4.09600000e+03, 0.00000000e+00,
1.60000000e+01, 4.00000000e+00, 3.69925758e+00,
0.00000000e+00, 6.48297395e+00, 1.94600000e+04,
1.60000000e+01, 4.91520000e+04, 1.50074000e+05,
1.60000000e+01, 5.48460000e+05, 4.00000000e+00,
1.19000000e+02, 1.00000000e+01, 0.00000000e+00,
0.00000000e+00, 0.00000000e+00, 0.00000000e+00,
0.00000000e+00, 0.00000000e+00, 0.00000000e+00,
0.00000000e+00, 0.00000000e+00, 0.00000000e+00],
[ 3.32000000e+02, 2.24000000e+02, 2.58000000e+02,
1.00000000e+01, 0.00000000e+00, 2.91840000e+04,
4.45952000e+05, 1.68960000e+04, 1.48190000e+04,
4.09600000e+03, 3.68640000e+04, 4.19430400e+06,
4.09600000e+03, 5.12000000e+02, 5.00000000e+00,
0.00000000e+00, 6.00000000e+00, 0.00000000e+00,
5.00000000e+00, 0.00000000e+00, 1.76537600e+06,
1.02400000e+03, 5.94294000e+05, 2.00000000e+00,
3.41120000e+04, 1.04857600e+06, 4.09600000e+03,
1.04857600e+06, 4.09600000e+03, 0.00000000e+00,
1.60000000e+01, 6.00000000e+00, 3.76419176e+00,
0.00000000e+00, 6.47970818e+00, 7.93600000e+03,
0.00000000e+00, 2.91840000e+04, 2.92339333e+05,
2.53600000e+03, 1.28204800e+06, 8.00000000e+00,
1.71000000e+02, 1.00000000e+00, 0.00000000e+00,
6.00000000e+00, 3.15203588e+00, 2.16096405e+00,
5.21367450e+00, 3.54333333e+02, 2.00000000e+01,
7.44000000e+02, 0.00000000e+00, 0.00000000e+00],
[ 3.32000000e+02, 2.24000000e+02, 3.31670000e+04,
2.00000000e+00, 2.50000000e+01, 3.78880000e+04,
1.53600000e+04, 0.00000000e+00, 4.00000000e+04,
4.09600000e+03, 4.50560000e+04, 4.19430400e+06,
4.09600000e+03, 5.12000000e+02, 1.00000000e+00,
0.00000000e+00, 0.00000000e+00, 0.00000000e+00,
4.00000000e+00, 0.00000000e+00, 8.19200000e+04,
1.02400000e+03, 6.78554440e+07, 2.00000000e+00,
0.00000000e+00, 1.04857600e+06, 1.63840000e+04,
1.04857600e+06, 4.09600000e+03, 0.00000000e+00,
1.60000000e+01, 8.00000000e+00, 2.33301385e+00,
0.00000000e+00, 6.63664803e+00, 6.65600000e+03,
0.00000000e+00, 3.78880000e+04, 7.19800000e+03,
8.00000000e+00, 3.77320000e+04, 8.00000000e+00,
9.60000000e+01, 0.00000000e+00, 0.00000000e+00,
1.40000000e+01, 3.42918455e+00, 2.41356665e+00,
5.05007355e+00, 7.17142857e+02, 4.40000000e+01,
2.21600000e+03, 0.00000000e+00, 1.50000000e+01]])
inputY = array([ 1., 1., 1., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.])
Related
Attempt to call a nil value (field 'getn')
Could you guys help me fix this lua code? I'm getting a problem on line 89 if IsMouseButtonPressed(1) and indexP < table.getn(weapon[indexW]) then getting the error attempt to call a nil value (field 'getn') "it" is asking me to add more details, so I will just add some letters down here. xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx AK47 = {{0,0}, {-0.56, 0.92}, {-0.55, 0.79}, {-0.45, 0.82}, {-0.27, 1.01}, {0.06, 2.49}, {0.65, 2.16}, {0.78, 2.17}, {0.46, 2.5}, {-0.04, 3.86}, {-0.41, 3.39}, {-0.54, 3.39}, {-0.41, 3.86}, {-0.36, 4.06}, {-0.36, 3.58}, {-0.1, 3.57}, {0.41, 4.02}, {1.14, 4.42}, {1.56, 3.73}, {1.74, 3.69}, {1.7, 4.28}, {1.05, 3.73}, {0.74, 3.34}, {0.84, 3.3}, {1.37, 3.6}, {1.9, 2.64}, {2.28, 2.1}, {1.8, 2.17}, {0.47, 2.85}, {-0.97, 2.71}, {-1.86, 1.95}, {-2.51, 1.4}, {-2.92, 1.06}, {-5.4, 0.71}, {-4.89, -0.84}, {-4.96, -1.29}, {-5.62, -0.64}, {-3.39, -0.37}, {-3.3, -0.53}, {-2.72, 0.24}, {-1.64, 1.95}, {0.7, 1.73}, {2.42, 0.96}, {2.49, 0.98}, {0.92, 1.79}, {-0.99, 1.83}, {-1.91, 0.87}, {-2.42, 0.28}, {-2.54, 0.05}, {-3.53, -0.87}, {-3.0, -1.9}, {-2.94, -1.57}, {-3.34, 0.1}, {-0.75, 0.42}, {-0.58, 0.61}, {-0.28, 0.72}, {0.15, 0.75}, {3.19, 2.01}, {4.93, -0.32}, {5.85, -0.97}, {5.95, 0.06}, {2.62, 0.6}, {2.26, 0.72}, {2.18, 0.93}, {2.39, 1.23}, {1.91, 1.37}, {1.51, 1.5}, {1.56, 1.38}, {2.07, 1.0}, {3.51, 0.62}, {3.18, -0.16}, {3.2, -0.6}, {3.59, -0.7}, {5.44, -0.2}, {5.49, 0.1}, {4.17, -0.95}, {1.46, -3.35}, {-1.57, -2.44}, {-3.26, -1.15}, {-3.41, 0.33}, {-2.02, 2.01}, {0.28, 0.57}, {0.98, 0.12}, {1.12, 0.12}, {0.68, 0.57}, {0.02, 1.49}, {-0.72, 1.24}, {-1.17, 1.1}, {-1.35, 1.06}, {-1.35, 0.49}, {-1.54, 0.11}, {-1.19, 0.22}, {-0.28, 0.84}, {1.38, 1.16}, {2.36, -0.91}, {2.85, -1.41}, {2.87, -0.36}, {1.28, 0.36}, {1.21, 0.51}, {0.8, 0.73}, {0.06, 1.01}, {-1.64, 1.63}, {-2.58, -0.2}, {-3.09, -0.97}, {-3.17, -0.69}, {-4.36, -0.19}, {-3.85, -0.15}, {-3.81, -0.39}, {-4.24, -0.91}, {-6.19, -2.43}, {-5.14, -2.99}, {-5.16, -2.9}, {-6.26, -2.15}, {-1.9, -0.25}, {-1.69, 0.03}, {-1.71, 0.15}, {-1.93, 0.09}} M4A4 = {{0,0}, {0.27, 1.1}, {0.24, 0.98}, {0.18, 1.12}, {0.16, 1.58}, {0.03, 1.42}, {-0.16, 1.58}, {-0.9, 2.81}, {-1.15, 2.42}, {-0.62, 2.84}, {0.71, 3.66}, {1.42, 3.17}, {0.72, 3.66}, {-0.77, 4.13}, {-1.54, 3.53}, {-1.48, 4.03}, {-1.55, 4.55}, {-1.24, 4.1}, {0.38, 4.49}, {2.06, 3.13}, {2.97, 2.07}, {3.13, 2.51}, {1.65, 2.3}, {1.35, 2.16}, {2.01, 1.87}, {4.02, 0.81}, {3.98, -0.19}, {2.91, 1.84}, {0.28, 1.96}, {-0.91, 1.83}, {-1.54, 1.67}, {-2.61, 1.79}, {-2.81, 0.8}, {-3.25, 0.37}, {-5.18, -0.21}, {-4.58, -1.06}, {-5.18, -0.88}, {-4.11, -0.07}, {-3.67, 0.14}, {-4.1, -0.18}, {-5.07, -1.48}, {-4.51, -1.72}, {-3.45, 0.38}, {-0.32, 0.53}, {0.04, 0.64}, {0.27, 0.64}, {1.69, 1.04}, {2.01, 0.46}, {0.71, 1.17}, {-1.18, 1.04}, {-2.05, -0.28}, {-2.26, -0.46}, {-2.93, -1.1}, {-2.62, -1.3}, {-1.82, 0.82}, {0.08, 0.52}, {0.59, 0.34}, {0.72, 0.25}, {4.48, 0.1}, {6.12, -0.65}, {6.58, 0.62}, {1.82, 0.98}, {1.43, 1.27}, {1.79, 1.05}, {4.5, 0.9}, {4.17, 0.02}, {4.65, 0.31}, {1.55, 0.35}, {1.37, 0.39}, {1.56, 0.31}, {2.47, 0.68}, {2.26, 0.52}, {1.03, -1.02}, {-1.23, -1.46}, {-2.51, -0.05}, {-1.82, 1.33}, {0.24, 1.0}, {1.2, 0.66}, {1.26, 0.8}, {0.67, 0.88}, {0.56, 0.82}, {0.81, 0.71}, {0.52, 0.23}, {0.51, 0.09}, {0.58, 0.01}, {0.76, -0.1}, {0.66, -0.21}, {0.74, -0.23}} AUG = {{0,0}, {0.63, 0.67}, {0.57, 0.59}, {0.33, 0.79}, {-0.06, 0.62}, {-0.27, 0.53}, {-0.29, 0.6}, {-0.34, 0.96}, {-0.29, 0.86}, {-0.3, 0.97}, {-0.64, 2.07}, {-0.52, 1.86}, {-0.26, 2.13}, {0.18, 3.0}, {0.57, 2.65}, {0.67, 2.97}, {0.53, 3.41}, {0.51, 3.03}, {0.98, 3.28}, {1.18, 2.33}, {1.32, 1.95}, {1.29, 2.29}, {0.59, 1.79}, {0.4, 1.65}, {0.73, 1.72}, {1.58, 1.47}, {1.69, 1.12}, {0.66, 1.68}, {-1.09, 1.68}, {-2.08, 0.85}, {-2.04, 1.26}, {-0.68, 0.65}, {-0.53, 0.65}, {0.04, 0.72}, {1.27, 0.34}, {1.66, -0.7}, {1.52, 0.14}, {0.47, 0.78}, {0.0, 0.89}, {-0.43, 0.83}, {-2.08, 1.29}, {-2.46, 0.06}, {-2.74, -0.35}, {-3.85, -0.78}, {-3.29, -1.31}, {-3.65, -1.59}, {-3.06, -2.07}, {-2.68, -2.03}, {-2.87, 0.14}, {-0.3, 0.61}, {0.19, 0.8}, {0.02, 0.86}, {-0.3, 0.84}, {-0.41, 0.68}, {-0.67, 0.51}, {-0.99, 0.33}, {-0.96, 0.02}, {-0.4, -0.55}, {1.44, -1.32}, {3.05, 0.79}, {3.34, 0.85}, {3.32, 0.11}, {2.95, 0.13}, {3.24, 0.58}, {1.66, 0.26}, {1.46, 0.36}, {0.51, 1.02}, {-0.62, 0.68}, {-1.04, 0.16}, {-0.63, -0.51}, {0.76, -1.0}, {2.11, 0.14}, {2.28, -0.03}, {3.06, -1.23}, {2.64, -1.34}, {3.12, -0.96}, {2.22, -0.53}, {2.03, -0.24}, {1.01, 1.06}, {-0.89, 1.38}, {-2.38, 0.16}, {-2.63, 0.13}, {-1.88, 0.27}, {-1.7, 0.16}, {-1.45, 0.39}, {-0.21, 0.14}, {-0.16, 0.16}, {-0.18, 0.18}} SG553 = {{0,0}, {-0.56, 1.34}, {-0.5, 1.2}, {-0.69, 1.27}, {-2.27, 2.8}, {-2.31, 2.28}, {-2.14, 2.87}, {-1.87, 4.11}, {-1.12, 3.9}, {-1.13, 4.42}, {-1.29, 4.98}, {-1.0, 4.47}, {-1.14, 5.02}, {-1.36, 5.54}, {-1.22, 4.93}, {-1.28, 5.55}, {-0.73, 6.22}, {-0.51, 5.58}, {-2.23, 5.6}, {-3.55, 2.59}, {-4.02, 1.51}, {-2.25, 3.06}, {1.53, 3.17}, {3.45, 2.22}, {2.02, 3.19}, {-0.54, 2.48}, {-1.56, 1.91}, {-2.1, 1.81}, {-2.59, 1.58}, {-2.61, 0.94}, {-2.73, 1.4}, {-1.08, 0.64}, {-0.9, 0.66}, {-0.35, 1.0}, {0.78, 0.98}, {1.4, 0.53}, {0.75, 0.98}, {-0.84, 1.3}, {-1.69, 0.71}, {-1.28, 1.22}, {0.28, 1.91}, {0.94, 1.77}, {-0.31, 1.5}, {-2.24, 0.51}, {-2.31, -1.29}, {-2.42, -1.74}, {-3.59, -2.94}, {-2.8, -3.15}, {-3.53, -3.04}, {-2.87, -1.56}, {-2.73, -1.06}, {-3.09, -1.14}, {-1.84, -0.31}, {-1.69, -0.23}, {-0.54, -0.99}, {4.26, -3.02}, {7.61, 2.5}, {8.4, 2.11}, {9.79, -0.58}, {8.69, -1.11}, {9.78, -0.94}, {7.46, -0.76}, {6.65, -0.54}, {7.3, 0.9}, {3.21, 1.27}, {2.62, 1.72}, {2.94, 1.94}, {2.62, 1.39}, {2.33, 1.25}, {2.4, 1.7}, {0.97, 1.19}, {0.73, 1.2}, {1.16, 0.88}, {3.64, 0.45}, {3.39, -0.87}, {3.8, -0.93}, {5.47, -1.88}, {4.93, -1.82}, {3.57, 1.82}, {-0.08, 1.49}, {-1.41, 1.18}, {-1.75, 1.09}, {-2.14, 1.27}, {-2.1, 0.77}, {-2.46, 0.43}, {-6.76, -0.03}, {-6.01, -1.16}, {-6.76, -1.25}} M4A1S = {{0,0}, {0.18, 0.78}, {0.17, 0.68}, {0.15, 0.68}, {0.1, 0.79}, {0.03, 0.66}, {-0.01, 0.58}, {-0.05, 0.58}, {-0.1, 0.65}, {-0.46, 1.77}, {-0.6, 1.51}, {-0.53, 1.52}, {-0.25, 1.78}, {0.31, 2.44}, {0.76, 2.1}, {0.75, 2.1}, {0.3, 2.44}, {-0.4, 2.86}, {-0.83, 2.43}, {-0.99, 2.41}, {-0.86, 2.8}, {-0.92, 3.14}, {-0.92, 2.8}, {-0.47, 2.79}, {0.43, 3.09}, {1.19, 2.24}, {1.7, 1.58}, {1.94, 1.45}, {1.91, 1.86}, {1.03, 1.57}, {0.77, 1.5}, {0.86, 1.41}, {1.31, 1.28}, {2.45, 0.88}, {2.6, 0.06}, {2.34, 0.28}, {1.67, 1.53}, {0.28, 1.37}, {-0.38, 1.28}, {-0.83, 1.2}, {-1.08, 1.12}, {-1.62, 1.23}, {-1.68, 0.71}, {-1.83, 0.38}, {-2.08, 0.24}, {-3.29, -0.0}, {-2.88, -0.52}, {-2.89, -0.67}, {-3.3, -0.43}, {-2.59, -0.0}, {-2.28, 0.17}, {-2.28, 0.15}, {-2.59, -0.05}, {-3.17, -0.72}, {-3.01, -1.12}, {-2.59, -0.67}, {-1.93, 0.63}, {-0.17, 0.34}, {0.04, 0.37}, {0.18, 0.38}, {0.25, 0.37}, {1.07, 0.64}, {1.34, 0.23}, {1.09, 0.29}, {0.32, 0.81}, {-0.62, 0.84}, {-1.16, 0.08}, {-1.44, -0.27}, {-1.45, -0.21}, {-1.86, -0.52}, {-1.8, -0.88}, {-1.5, -0.44}, {-0.98, 0.81}, {0.04, 0.32}, {0.35, 0.18}, {0.48, 0.13}, {0.46, 0.18}} FAMAS = {{0,0}, {-0.75, 0.66}, {-0.68, 0.59}, {-0.45, 0.83}, {0.06, 0.69}, {0.29, 0.62}, {0.1, 0.7}, {-0.86, 1.85}, {-1.31, 1.43}, {-1.07, 1.8}, {-0.53, 2.82}, {0.04, 2.6}, {0.1, 2.92}, {-0.27, 3.68}, {-0.18, 3.28}, {0.68, 3.53}, {1.75, 3.49}, {2.31, 2.7}, {2.89, 2.75}, {3.07, 1.81}, {3.0, 1.31}, {1.82, 2.52}, {-0.12, 2.33}, {-1.24, 1.93}, {-1.86, 1.77}, {-2.99, 1.84}, {-3.12, 0.89}, {-3.5, 1.0}, {-2.89, 1.16}, {-2.57, 1.01}, {-2.97, 0.87}, {-2.58, -0.09}, {-2.36, -0.31}, {-1.55, 1.11}, {0.11, 1.2}, {1.03, 0.93}, {1.34, 0.77}, {3.76, 1.22}, {3.67, 0.16}, {4.02, 0.6}, {2.01, 0.91}, {1.72, 1.0}, {2.06, 0.65}, {3.38, -0.16}, {3.0, -0.83}, {3.4, -0.48}, {1.01, 0.11}, {0.89, 0.21}, {1.01, 0.16}, {2.61, -0.21}, {2.34, -0.37}, {2.39, 0.54}, {0.93, 0.63}, {0.61, 0.82}, {0.09, 1.02}, {-0.45, 0.77}, {-0.8, 0.41}, {-0.97, 0.27}, {-4.59, -0.01}, {-4.21, -1.03}, {-3.75, 0.17}, {-0.71, 0.37}, {-0.52, 0.51}, {-0.01, 0.62}, {1.34, 0.82}, {1.89, -0.49}, {2.05, -0.73}, {2.67, -0.81}, {2.28, -1.02}, {2.47, -1.33}, {2.8, -1.73}, {2.37, -1.74}, {2.67, -1.94}} UMP45 = {{0,0}, {-0.12, 1.13}, {-0.1, 1.01}, {-0.23, 1.11}, {-0.58, 1.4}, {-0.66, 1.19}, {-0.55, 1.41}, {-0.46, 2.96}, {-0.06, 2.7}, {-0.23, 3.01}, {-0.62, 3.81}, {-0.71, 3.36}, {-1.06, 3.71}, {-1.63, 3.93}, {-1.72, 3.4}, {-1.42, 3.99}, {-1.07, 4.44}, {-0.5, 4.04}, {0.53, 4.44}, {1.74, 3.1}, {2.32, 2.43}, {1.39, 3.16}, {-0.51, 2.07}, {-1.16, 1.75}, {-0.48, 2.06}, {0.81, 2.65}, {1.56, 2.05}, {2.15, 1.92}, {2.97, 1.91}, {3.0, 1.13}, {3.42, 1.15}, {2.61, 0.48}, {2.38, 0.3}, {1.86, 1.39}, {0.07, 0.57}, {-0.23, 0.57}, {-0.06, 0.63}, {0.69, 1.15}, {0.96, 0.86}, {0.73, 1.14}, {-0.09, 1.02}, {-0.34, 0.95}, {0.27, 0.77}, {1.47, 0.23}, {1.47, -0.89}, {1.64, -0.98}, {1.13, -0.72}, {1.02, -0.69}, {0.68, 0.29}, {-0.64, 1.63}, {-2.73, 0.53}, {-3.04, 0.41}, {-3.7, 1.09}, {-3.4, 0.73}, {-2.32, -0.69}, {-0.12, -0.38}, {0.15, -0.4}, {0.28, -0.38}, {1.79, -1.35}, {2.25, -0.81}, {2.59, -0.68}, {3.29, -1.36}, {3.04, -1.03}, {1.92, 1.27}, {-0.18, 0.62}, {-0.8, 0.32}, {-0.94, 0.21}, {-3.72, 0.48}, {-3.39, -0.32}, {-3.6, -0.71}, {-0.68, -0.19}, {-0.58, -0.23}, {-0.66, -0.26}} MP7 = {{0,0}, {0.04, 0.6}, {0.06, 0.52}, {0.02, 0.52}, {-0.05, 0.59}, {-0.09, 0.45}, {-0.12, 0.39}, {-0.17, 0.37}, {-0.23, 0.4}, {-0.34, 0.46}, {-0.36, 0.36}, {-0.37, 0.35}, {-0.37, 0.44}, {-0.81, 1.23}, {-0.63, 1.13}, {-0.61, 1.15}, {-0.74, 1.28}, {-1.32, 1.82}, {-1.3, 1.53}, {-1.14, 1.6}, {-0.84, 2.03}, {-0.16, 2.21}, {0.42, 2.01}, {0.4, 2.0}, {-0.22, 2.19}, {-0.97, 1.85}, {-1.32, 1.38}, {-1.39, 1.35}, {-1.19, 1.76}, {-0.45, 1.75}, {-0.04, 1.68}, {-0.16, 1.6}, {-0.82, 1.5}, {-1.13, 0.79}, {-1.25, 0.28}, {-1.34, 0.15}, {-1.42, 0.39}, {-0.97, 0.31}, {-0.94, 0.25}, {-0.74, 0.4}, {-0.38, 0.76}, {0.22, 1.47}, {0.96, 1.09}, {1.4, 0.87}, {1.54, 0.81}, {2.39, 1.01}, {2.26, 0.47}, {2.34, 0.23}, {2.63, 0.29}, {2.39, 0.31}, {2.11, 0.2}, {2.11, 0.14}, {2.4, 0.14}, {2.04, -0.15}, {1.88, -0.36}, {1.75, -0.04}, {1.64, 0.82}, {0.42, 0.54}, {0.18, 0.62}, {-0.02, 0.67}, {-0.18, 0.7}, {-0.51, 0.93}, {-0.7, 0.66}, {-0.86, 0.53}, {-0.98, 0.54}, {-0.49, 0.23}, {-0.46, 0.14}, {-0.47, 0.12}, {-0.52, 0.17}, {-0.58, 0.14}, {-0.57, 0.09}, {-0.45, 0.18}, {-0.22, 0.42}, {0.21, 0.47}, {0.57, 0.24}, {0.63, 0.24}, {0.37, 0.46}, {0.03, 0.62}, {-0.17, 0.56}, {-0.36, 0.47}, {-0.52, 0.35}, {-1.94, 0.45}, {-1.81, -0.37}, {-1.84, -0.8}, {-2.02, -0.83}, {-2.72, -1.17}, {-2.32, -1.32}, {-2.27, -1.25}, {-2.57, -0.95}, {-0.52, -0.08}, {-0.47, 0.0}, {-0.47, 0.01}, {-0.53, -0.04}, {-1.43, -0.06}, {-1.38, 0.01}, {-1.13, -0.27}, {-0.66, -0.91}, {0.09, -0.32}, {0.36, -0.2}, {0.4, -0.2}, {0.23, -0.33}, {0.0, -0.3}, {-0.08, -0.29}, {-0.16, -0.21}, {-0.24, -0.05}, {-0.14, 0.14}, {0.03, 0.27}, {0.05, 0.3}, {-0.09, 0.25}, {-0.57, 0.22}, {-0.63, -0.1}, {-0.63, -0.11}, {-0.58, 0.21}, {-0.21, 0.31}, {-0.05, 0.35}, {0.01, 0.38}, {-0.03, 0.41}} MP9 = {{0,0}, {-0.06, 1.42}, {-0.25, 1.37}, {-0.78, 1.07}, {-0.63, 1.11}, {0.59, 2.78}, {1.0, 2.79}, {-0.48, 4.4}, {-0.29, 4.37}, {2.43, 5.36}, {2.47, 5.35}, {0.26, 5.22}, {-0.92, 5.21}, {-2.59, 5.49}, {-1.39, 5.53}, {1.82, 3.97}, {3.44, 3.05}, {4.88, 3.09}, {5.55, 1.7}, {5.5, 0.56}, {5.56, -0.51}, {6.82, -3.0}, {5.91, -0.05}, {0.32, 2.2}, {-0.78, 2.69}, {0.66, 2.9}, {-0.23, 2.62}, {-5.22, 2.59}, {-6.44, 1.18}, {-3.31, 2.16}, {-3.27, 2.24}, {-4.45, 1.93}, {-4.56, 1.71}, {-3.43, 1.78}, {-3.57, 1.31}, {-5.25, 0.28}, {-5.24, -0.86}, {-8.97, -4.96}, {-5.99, -0.22}, {0.73, 0.86}, {1.83, 0.35}, {4.05, 0.95}, {4.15, 0.48}, {5.39, -0.03}, {4.94, 0.56}, {1.1, 0.4}, {0.39, 0.72}, {-3.55, 0.93}, {-5.12, -1.93}, {-6.55, -2.47}, {-6.59, -1.18}, {-1.54, 0.71}, {-1.43, 1.04}, {-3.35, 0.7}, {-1.94, 1.62}, {1.7, 1.68}, {3.05, 1.07}, {1.29, 1.25}, {1.19, 1.36}} MAC = {{0,0}, {-0.82, 0.45}, {-0.73, 0.39}, {-0.66, 0.62}, {-0.38, 0.59}, {-0.2, 0.6}, {-0.03, 0.7}, {0.3, 1.08}, {0.57, 0.88}, {0.56, 1.03}, {0.7, 2.3}, {0.48, 2.09}, {0.78, 2.26}, {1.61, 2.97}, {1.72, 2.49}, {1.8, 2.88}, {2.11, 4.05}, {1.73, 3.67}, {1.86, 4.17}, {1.85, 3.48}, {1.61, 3.12}, {0.78, 3.72}, {-0.83, 3.03}, {-1.54, 2.59}, {-0.42, 2.98}, {1.07, 1.84}, {1.68, 1.26}, {1.58, 1.64}, {0.85, 1.84}, {0.49, 1.75}, {0.6, 1.95}, {0.93, 1.9}, {0.88, 1.68}, {0.43, 2.0}, {-0.16, 1.32}, {-0.46, 1.13}, {-0.59, 1.24}, {-0.29, 0.8}, {-0.3, 0.69}, {-0.53, 0.63}, {-1.46, 0.89}, {-1.52, 0.39}, {-1.75, 0.26}, {-3.53, 0.42}, {-3.18, 0.02}, {-3.56, -0.29}, {-5.85, -0.96}, {-5.23, -1.28}, {-3.24, -0.91}, {-0.31, -0.1}, {-0.28, -0.1}, {-0.31, -0.11}, {-2.34, -0.22}, {-2.42, -0.23}, {-0.93, -1.37}, {0.89, -0.29}, {1.49, 0.54}, {0.91, -0.29}, {-0.41, -0.78}, {-1.22, -0.21}, {-1.37, -0.14}, {-2.03, -0.36}, {-1.84, -0.12}, {-2.07, 0.06}, {-2.36, -0.15}, {-2.13, -0.01}, {-0.86, 1.18}, {1.45, 1.47}, {3.11, -0.47}, {3.4, -0.39}, {2.26, 0.29}, {2.0, 0.3}, {2.26, 0.27}, {2.72, 0.26}, {2.42, 0.17}, {2.73, 0.05}, {3.76, -0.62}, {3.35, -0.77}, {3.48, 0.62}, {0.8, 0.51}, {0.54, 0.67}, {-0.08, 0.74}, {-3.75, 1.42}, {-4.46, -1.43}, {-2.25, -2.49}, {0.19, -0.29}, {0.47, -0.07}, {0.51, -0.09}} weapon = {AK47, M4A4, AUG, SG553, M4A1S, FAMAS, UMP45, MP7, MP9, MAC} ------------------------ Rate of Fire ---------------------- ak47_ROF = {delay = 100, interpolation = 4} m4a4_ROF = {delay = 90, interpolation = 3} aug_ROF = {delay = 90, interpolation = 3} sg553_ROF = {delay = 90, interpolation = 3} m4a1s_ROF = {delay = 100, interpolation = 4} famas_ROF = {delay = 90, interpolation = 3} ump_ROF = {delay = 90, interpolation = 3} mp7_ROF = {delay = 80, interpolation = 4} mp9_ROF = {delay = 70, interpolation = 2} mac_ROF = {delay = 75, interpolation = 3} weaponRof = {ak47_ROF, m4a4_ROF, aug_ROF, sg553_ROF, m4a1s_ROF, famas_ROF, ump_ROF, mp7_ROF, mp9_ROF, mac_ROF} ------------------- Weapon Sensitivity --------------------- AKsen = 2.85 M4sen = 2.8 AUGsen = 4.7 SG553sen = 2.8 M4A1sen = 2.3 FAMsen = 3 UMPsen = 2.8 MP7sen = 3 MP9sen = 2.9 MACsen = 2.8 weaponSen = {AKsen, M4sen, AUGsen, SG553sen, M4A1sen, FAMsen, UMPsen, MP7sen, MP9sen, MACsen} ------------------------------------------------------------ indexW = 1 --index of weapon indexP = 1 --index of Pattern indexT = 1 -- 1 rifle / 2 smg function OnEvent(event, arg) EnablePrimaryMouseButtonEvents(true) if IsMouseButtonPressed(2) then indexW = indexW + 1 if indexT == 1 then if indexW > 6 then indexW = 1 end end if indexT == 2 then if indexW > 10 then indexW = 7 end end if indexW == 1 then PressAndReleaseKey("insert") end if indexW == 2 then PressAndReleaseKey("home") end if indexW == 3 then PressAndReleaseKey("pageup") end if indexW == 4 then PressAndReleaseKey("delete") end if indexW == 5 then PressAndReleaseKey("end") end if indexW == 6 then PressAndReleaseKey("pagedown") end if indexW == 7 then PressAndReleaseKey("up") end if indexW == 8 then PressAndReleaseKey("down") end if indexW == 9 then PressAndReleaseKey("left") end if indexW == 10 then PressAndReleaseKey("right") end end while IsMouseButtonPressed(4) do if IsMouseButtonPressed(1) and indexP < table.getn(weapon[indexW]) then MoveMouseRelative(weapon[indexW][indexP][1]*weaponSen[indexW], weapon[indexW][indexP][2]*weaponSen[indexW]) Sleep(weaponRof[indexW].delay/weaponRof[indexW].interpolation) indexP = indexP + 1 else Sleep(10) indexP = 1 end if IsMouseButtonPressed(2) then indexT = indexT + 1 if indexT > 2 then indexT = 1 end if indexT == 1 then indexW = 1 PressAndReleaseKey("insert") else indexW = 7 PressAndReleaseKey("up") end Sleep(300) OutputLogMessage(indexW) end end indexP = 1 end
table.getn does not exist in more recent versions of Lua. Instead, use the length operator: #weapon[indexW].
C++/Ubuntu/openCv: gopro very low fps/resolution
https://www.amazon.fr/gp/product/B08CGVSRQV/ref=ppx_yo_dt_b_asin_title_o00_s00?ie=UTF8&psc=1 My system: gopro3 => microHDMI to HDMI => HDMI to USB3 (my purchase above) => my computer. with: gst-launch-1.0 -v v4l2src! video/x-raw, framerate=30/1 ! xvimagesink Terminal: ... /GstPipeline:pipeline0/GstV4l2Src:v4l2src0.GstPad:src: caps = video/x-raw, framerate=(fraction)30/1, format=(string)YUY2, width=(int)720, height=(int)480, pixel-aspect-ratio=(fraction)1/1, colorimetry=(string)2:4:5:1, interlace-mode=(string)progressive ... => width=(int)720, height=(int)480 My gopro gives me 1920/1080/60, and by just changing fps capture, resolution is automatically adapted. If, for example, I force resolution: gst-launch-1.0 -v v4l2src! video/x-raw, framerate=30/1,width=1920,height=1080! xvimagesink gst-launch or opencv always crash: Setting pipeline to PAUSED ... Pipeline is live and does not need PREROLL ... Setting pipeline to PLAYING ... New clock: GstSystemClock ERROR: from element /GstPipeline:pipeline0/GstV4l2Src:v4l2src0: Internal data stream error. Additional debug info: gstbasesrc.c(3072): gst_base_src_loop (): /GstPipeline:pipeline0/GstV4l2Src:v4l2src0: streaming stopped, reason not-negotiated (-4) Execution ended after 0:00:00.000049118 Setting pipeline to PAUSED ... Setting pipeline to READY ... Setting pipeline to NULL ... Freeing pipeline ... except for 1920/1080/5fps or 1280/720/10fps or 800/600/20fps or 720/480/30fps, 60 fps is impossible. But my gopro3 black sends me 1920/1080/60fps, any explanation ?? I really don't understand what happen. gopro is able to do this, cable is able to do this, capture card is able to do this, my computer is able to do this..... Morover, in 1080p, about 1 second latency and 5 fps, in 720p about 0.5 second latency, for 800/600 latency is ok, and 480p latency is about 0.2 seconds (perfect for me). For opencv, that works as bad as gst-streamer: cv::VideoCapture video_capture(0, cv::CAP_V4L2); displays 480p, very fluent and cv::VideoCapture video_capture(0, cv::CAP_GSTREAMER); displays 1080p with strong latency where am I doing a mistake? I don't understand. Is my capture card just bad ? Are my parameters in gst-launch-1.0 bad ? (That's sure i've got a poor understood of gstreamer)
Check the camera capabilities using: v4l2-ctl --list-formats-ext -d /dev/video0 Most probably you can get 1080p/60FPS for MJPG only (and you have explicitly requested x-raw, no compression is done). If so, try: gst-launch-1.0 -e v4l2src ! image/jpeg,width=1920,height=1080,framerate=30/1 ! jpegdec ! xvimagesink
v4l2-ctl --list-formats-ext -d /dev/video0 ioctl: VIDIOC_ENUM_FMT Type: Video Capture [0]: 'MJPG' (Motion-JPEG, compressed) Size: Discrete 1920x1080 Interval: Discrete 0.033s (30.000 fps) Interval: Discrete 0.040s (25.000 fps) Interval: Discrete 0.050s (20.000 fps) Interval: Discrete 0.100s (10.000 fps) Interval: Discrete 0.200s (5.000 fps) Size: Discrete 1600x1200 Interval: Discrete 0.033s (30.000 fps) Interval: Discrete 0.040s (25.000 fps) Interval: Discrete 0.050s (20.000 fps) Interval: Discrete 0.100s (10.000 fps) Interval: Discrete 0.200s (5.000 fps) Size: Discrete 1360x768 Interval: Discrete 0.033s (30.000 fps) Interval: Discrete 0.040s (25.000 fps) Interval: Discrete 0.050s (20.000 fps) Interval: Discrete 0.100s (10.000 fps) Interval: Discrete 0.200s (5.000 fps) Size: Discrete 1280x1024 Interval: Discrete 0.033s (30.000 fps) Interval: Discrete 0.040s (25.000 fps) Interval: Discrete 0.050s (20.000 fps) Interval: Discrete 0.100s (10.000 fps) Interval: Discrete 0.200s (5.000 fps) Size: Discrete 1280x960 Interval: Discrete 0.020s (50.000 fps) Interval: Discrete 0.033s (30.000 fps) Interval: Discrete 0.050s (20.000 fps) Interval: Discrete 0.100s (10.000 fps) Interval: Discrete 0.200s (5.000 fps) Size: Discrete 1280x720 Interval: Discrete 0.017s (60.000 fps) Interval: Discrete 0.020s (50.000 fps) Interval: Discrete 0.033s (30.000 fps) Interval: Discrete 0.050s (20.000 fps) Interval: Discrete 0.100s (10.000 fps) Size: Discrete 1024x768 Interval: Discrete 0.017s (60.000 fps) Interval: Discrete 0.020s (50.000 fps) Interval: Discrete 0.033s (30.000 fps) Interval: Discrete 0.050s (20.000 fps) Interval: Discrete 0.100s (10.000 fps) Size: Discrete 800x600 Interval: Discrete 0.017s (60.000 fps) Interval: Discrete 0.020s (50.000 fps) Interval: Discrete 0.033s (30.000 fps) Interval: Discrete 0.050s (20.000 fps) Interval: Discrete 0.100s (10.000 fps) Size: Discrete 720x576 Interval: Discrete 0.017s (60.000 fps) Interval: Discrete 0.020s (50.000 fps) Interval: Discrete 0.033s (30.000 fps) Interval: Discrete 0.050s (20.000 fps) Interval: Discrete 0.100s (10.000 fps) Size: Discrete 720x480 Interval: Discrete 0.017s (60.000 fps) Interval: Discrete 0.020s (50.000 fps) Interval: Discrete 0.033s (30.000 fps) Interval: Discrete 0.050s (20.000 fps) Interval: Discrete 0.100s (10.000 fps) Size: Discrete 640x480 Interval: Discrete 0.017s (60.000 fps) Interval: Discrete 0.020s (50.000 fps) Interval: Discrete 0.033s (30.000 fps) Interval: Discrete 0.050s (20.000 fps) Interval: Discrete 0.100s (10.000 fps) [1]: 'YUYV' (YUYV 4:2:2) Size: Discrete 1920x1080 Interval: Discrete 0.200s (5.000 fps) Size: Discrete 1600x1200 Interval: Discrete 0.200s (5.000 fps) Size: Discrete 1360x768 Interval: Discrete 0.125s (8.000 fps) Size: Discrete 1280x1024 Interval: Discrete 0.125s (8.000 fps) Size: Discrete 1280x960 Interval: Discrete 0.125s (8.000 fps) Size: Discrete 1280x720 Interval: Discrete 0.100s (10.000 fps) Size: Discrete 1024x768 Interval: Discrete 0.100s (10.000 fps) Size: Discrete 800x600 Interval: Discrete 0.050s (20.000 fps) Interval: Discrete 0.100s (10.000 fps) Interval: Discrete 0.200s (5.000 fps) Size: Discrete 720x576 Interval: Discrete 0.040s (25.000 fps) Interval: Discrete 0.050s (20.000 fps) Interval: Discrete 0.100s (10.000 fps) Interval: Discrete 0.200s (5.000 fps) Size: Discrete 720x480 Interval: Discrete 0.033s (30.000 fps) Interval: Discrete 0.050s (20.000 fps) Interval: Discrete 0.100s (10.000 fps) Interval: Discrete 0.200s (5.000 fps) Size: Discrete 640x480 Interval: Discrete 0.033s (30.000 fps) Interval: Discrete 0.050s (20.000 fps) Interval: Discrete 0.100s (10.000 fps) Interval: Discrete 0.200s (5.000 fps) v4l2src ! image/jpeg,width=1920,height=1080,framerate=30/1 ! jpegdec ! xvimagesink Setting pipeline to PAUSED ... Pipeline is live and does not need PREROLL ... Setting pipeline to PLAYING ... New clock: GstSystemClock X Error of failed request: BadAlloc (insufficient resources for operation) Major opcode of failed request: 150 (XVideo) Minor opcode of failed request: 19 () Serial number of failed request: 72 Current serial number in output stream: 73
I found this which seems to work gst-launch-1.0 -v v4l2src ! "image/jpeg;video/x-raw" ! decodebin ! glimagesink and for opencv, it's this one : cv::VideoCapture video_capture("v4l2src ! image/jpeg;video/x-raw,framerate=30/1 ! decodebin ! videoconvert ! appsink", cv::CAP_GSTREAMER);
Latex document written in Arabic but the References List does not printed in English
In Latex, I am using biber but it does not show the references in the right format, maybe due to the use of second language Arabic and its package arabtex. There are many bilingual packages that allow you to make the references in another language. However, I am newbie in bilingual packages with LaTex and references. The references This how it suppose to be printed as \documentclass[article,10pt]{amsart} \usepackage{ifluatex,ifxetex} \ifluatex \usepackage{fontspec} % optional \else\ifxetex \usepackage{fontspec} % optional \else % assume that pdftex engine is in use \usepackage[T1]{fontenc} \usepackage[utf8]{inputenc} % optional for "\ng" \fi\fi \usepackage{graphicx} \graphicspath{ {./images/} } \usepackage[bibencoding=utf8, backend=biber, style=apa, language=english]{biblatex} \DeclareLanguageMapping{english}{english-apa} \addbibresource{func.bib} \usepackage{amsmath} \usepackage{hyperref} \usepackage{arabtex} \usepackage{utf8} \usepackage{boondox-cal} \usepackage[margin=0.5in]{geometry} \usepackage{steinmetz} \title{Functions} \author{Mohammad Alkahtani} \date{May 2020} \begin{document} \setcode{utf8} \pagenumbering{gobble} \maketitle \newpage \pagenumbering{arabic} \section{Power Series} \setarab \fullvocalize \arabtrue \begin{RLtext} الدوال بالإمكان تكوينها كمجموعه من حدود تعطي نتيجة الدالة إذا كانت الحدود غير منتهية و نتيجة تقريبية للدالة في حالة كانت الحدود محددة العدد و هذا ما يستخدم في الحاسب و تحويل الدوال من صيغيتها في الطبيعه إلى صيغتها في الأجهزه الإلكترونية لتكون مرئية أو مسموعه فعلى سبيل المثال جرب الموقع التالي و تأكد أن المسموع لك هو بين 20 هرتز إلى 20,000 هرتز و الدالة عندما نجمعها مع مجموعه مشاببه لها في تردد زمني معني يتكون لنا صوت \end{RLtext} \href{http://meettechniek.info/additional/additive-synthesis.html}{Sounds} \begin{RLtext} جرب الرابط الثاني بالإسفل و تأكد أن الصور و الرسمات يجسدها مجموعه من الدوال الرياضية في الحاسب و عند تجميع أكثر من صورة في تردد زمني معين يتكون لنا مقطع مرئي و بإمكان إضافة له موجات من الصوت فيصبح فلم \end{RLtext} \href{https://blogs.scientificamerican.com/guest-blog/making-mathematical-art/}{Pictures} \\* \begin{equation} 1 + x + x^2 + x^3 + .... \tag{1.1} \label{eq:frame0} \end{equation} \begin{equation} 1 + x + \frac{x^2}{2} + \frac{x^3}{6} + .... \tag{1.2} \label{eq:frame1} \end{equation} \begin{RLtext} الدالة \end{RLtext} \eqref{eq:frame0} from \autocite{Flint2012} \begin{RLtext} و الدالة \end{RLtext} \eqref{eq:frame1} from \autocite{Flint2012} \begin{RLtext} عبارة عن مجموعة حدود تمثل دوال أخرى \end{RLtext} \subsection{Sine} \begin{equation} \sin x = x - \frac{x^3}{3!} + \frac{x^5}{5!} - \frac{x^7}{7!} + ... \textrm{ where the degree } x \textrm{ in radians} \tag{1.1.1} \label{eq:frame2} \end{equation} \begin{RLtext} تكوين دالة الجا ، بهذا التكوين نستخدمها أستخدام أمثل في التطبيقات الهندسية عندما نواجه الأعداد التخيليه و ليس بإمكان إيجاد قيمة جذر سالب واحد و لكن عند ضرب عدد تخيلي بأخر فإننا نحصل على القيمة سالب واحد و تتسهل المعادلة بدل إيجاد قيمة عدد تخيلي \end{RLtext} \eqref{eq:frame2} from \autocite{Flint2012} \begin{equation} \sin 0.5 = 0.5 - \frac{(0.5)^3}{3!} + \frac{(0.5)^5}{5!} - \frac{(0.5)^7}{7!} + ... \tag{1.1.2} \label{eq:frame3} \end{equation} this eq \autocite{JamesFlint2012} From \eqref{eq:frame3} $\sin 0.5 \approx 0.5 - 0.0208333 + 0.0002604 = 0.4794271$ \begin{equation} \sin x \approx x \textrm{ where the degree } x \textrm{ is small and measured in radians} \tag{1.1.3} \label{eq:frame4} \end{equation} \begin{RLtext} قيمة تقريبية لتكوين دالة الجا \end{RLtext} \eqref{eq:frame4} from \autocite{Flint2012} \subsection{Cosine} \begin{equation} \cos x = 1 - \frac{x^2}{2!} + \frac{x^4}{4!} - \frac{x^6}{6!} + ... \tag{1.2.1} \label{eq:frame5} \end{equation} \begin{RLtext} تكوين دالة الجتا ، بهذا التكوين نستخدمها أستخدام أمثل في التطبيقات الهندسية عندما نواجه الأعداد التخيليه و ليس بإمكان إيجاد قيمة جذر سالب واحد و لكن عند ضرب عدد تخيلي بأخر فإننا نحصل على القيمة سالب واحد و تتسهل المعادلة بدل إيجاد قيمة عدد تخيلي \end{RLtext} \eqref{eq:frame5} from \autocite{Flint2012} \begin{equation} \cos x \approx 1 - \frac{x}{2!} \textrm{ where the degree } x \textrm{ is small and measured in radians} \tag{1.2.2} \label{eq:frame6} \end{equation} \begin{RLtext} قيمة تقريبية لتكوين دالة الجتا \end{RLtext} \eqref{eq:frame6} from \autocite{Flint2012} \subsection{Exponential} \begin{equation} \exp^x = 1 + x + \frac{x^2}{2!} + \frac{x^3}{3!} + \frac{x^4}{4!} + ... \tag{1.3.1} \label{eq:frame7} \end{equation} \begin{RLtext} تكوين الدالة الأسية ، بهذا التكوين نستخدمها أستخدام أمثل في التطبيقات الهندسية عندما نواجه الأعداد التخيليه و ليس بإمكان إيجاد قيمة جذر سالب واحد و لكن عند ضرب عدد تخيلي بأخر فإننا نحصل على القيمة سالب واحد و تتسهل المعادلة بدل إيجاد قيمة عدد تخيلي \end{RLtext} \eqref{eq:frame7} from \autocite{Flint2012} \section{Complex Number} \noindent \begin{RLtext} الأعداد التخيليه \end{RLtext} $\mathbb{C}$ $a+bi$ \\ $i^2=-1$ \\ $\mathbb{C}$ $a+bj$ \\ $j^2=-1$ \\ $\Re(z)$ and $\operatorname{Re}(z)$ \\ $\Im(z)$ and $\operatorname{Im}(z)$ \\ \begin{equation} \exp^x = 1 + x + \frac{x^2}{2!} + \frac{x^3}{3!} + \frac{x^4}{4!} + ... \tag{2.1} \label{eq:frame8} \end{equation} \begin{RLtext} تكوين الدالة الأسية ، بهذا التكوين نستخدمها أستخدام أمثل في التطبيقات الهندسية عندما نواجه الأعداد التخيليه و ليس بإمكان إيجاد قيمة جذر سالب واحد و لكن عند ضرب عدد تخيلي بأخر فإننا نحصل على القيمة سالب واحد و تتسهل المعادلة بدل إيجاد قيمة عدد تخيلي \end{RLtext} \eqref{eq:frame8} from \autocite{Flint2012} \subsection{The exponential form of a complex number} \noindent \\* From \eqref{eq:frame8} from \autocite{Flint2012} \begin{equation} \exp^{j\theta} = \cos \theta + j \sin \theta \tag{2.1.1} \label{eq:frame9} \end{equation} \begin{RLtext} تحويل الدالة الأسية عندما يكون العدد التخيلي في الأس موجب إلى جا و جتا، بهذا التحويل نستخدم الدوال و نغييرها في التطبيقات الهندسية عندما نواجه الأعداد التخيليه و ليس بإمكان إيجاد قيمة جذر سالب واحد و لكن عند ضرب عدد تخيلي بأخر فإننا نحصل على القيمة سالب واحد و تتسهل المعادلة بدل إيجاد قيمة عدد تخيلي \end{RLtext} \eqref{eq:frame9} from \autocite{Flint2012} \begin{equation} \exp^{-j\theta} = \cos \theta - j \sin \theta \tag{2.1.2} \label{eq:frame10} \end{equation} \begin{RLtext} تحويل الدالة الأسية عندما يكون العدد التخيلي في الأس سالب إلى جا و جتا، بهذا التحويل نستخدم الدوال و نغييرها في التطبيقات الهندسية عندما نواجه الأعداد التخيليه و ليس بإمكان إيجاد قيمة جذر سالب واحد و لكن عند ضرب عدد تخيلي بأخر فإننا نحصل على القيمة سالب واحد و تتسهل المعادلة بدل إيجاد قيمة عدد تخيلي \end{RLtext} \eqref{eq:frame10} from \autocite{JamesFlint2012} \begin{equation} \sin \theta = \frac{\left[e^{j\theta} - e^{-j\theta}\right] }{2j} \tag{2.1.3} \label{eq:frame11} \end{equation} \begin{RLtext} تحويل دالة الجا إلى دالة أسية ، بهذا التحويل نستخدم الدوال و نغييرها في التطبيقات الهندسية عندما نواجه الأعداد التخيليه و ليس بإمكان إيجاد قيمة جذر سالب واحد و لكن عند ضرب عدد تخيلي بأخر فإننا نحصل على القيمة سالب واحد و تتسهل المعادلة بدل إيجاد قيمة عدد تخيلي \end{RLtext} \eqref{eq:frame11} from \autocite{Flint2012} \begin{equation} \cos \theta = \frac{\left[e^{j\theta} + e^{-j\theta}\right] }{2} \tag{2.1.4} \label{eq:frame12} \end{equation} \begin{RLtext} تحويل دالة الجتا إلى دالة أسية ، بهذا التحويل نستخدم الدوال و نغييرها في التطبيقات الهندسية عندما نواجه الأعداد التخيليه و ليس بإمكان إيجاد قيمة جذر سالب واحد و لكن عند ضرب عدد تخيلي بأخر فإننا نحصل على القيمة سالب واحد و تتسهل المعادلة بدل إيجاد قيمة عدد تخيلي \end{RLtext} \eqref{eq:frame12} from \autocite{Flint2012} \section{Taylor Series, Maclaurin Series and Mansour’s theorem} \noindent \\* Taylor Series \noindent \begin{equation} f(x) = f(0) + \frac{f'(0)}{1!} (x -a)^1 + \frac{f(0)}{2!} (x -a)^2 + \frac{f'(0)}{3!} (x-a)^3 + \dotsb = \sum_{k=0}^\infty \frac{f^{\left(k\right)}(0)}{k!} (x-a)^k \tag{3.1} \label{eq:frame13} \end{equation} \begin{RLtext} سلسلة تايلور للقوى عبارة عن تكوين الدالة من القيمة الأبتدائية للدالة عند عدد معين ثم جمع مشتقات الدالة عند القيمة الأبتدائية مضروب في المتغير مطروح منه العدد المعين، المضروب يكون مروفع للأس أو القوة لرقم الحد أبتداء من الحد الثالث الأس الثاني أو للقوة 2 لأن الحد الأول 0 و الحد الثاني 1 و ناتج الأس أو القوة للحد الأول و الثاني عبارة عن 1 و نفس الدالة على التوالي، ثم نقسم على مضروب رقم الحد \end{RLtext} \eqref{eq:frame13} from \autocite{Flint2012} \\* Maclaurin Series \begin{equation} f(x) = f(0) + \frac{f'(0)}{1!}x + \frac{f(0)}{2!}x^2 + \frac{f'(0)}{3!}x^3+\dotsb = \sum_{k=0}^\infty \frac{f^{\left(k\right)}(0)}{k!} x^k \tag{3.2} \label{eq:frame14} \end{equation} \begin{RLtext} سلسلة ماك لورين للقوى نفس سلسلة تايلور مع جعل العدد الثابت صفر فتكوين الدالة من قيمة الدالة الأبتدائية عند صفر و لا يكون هناك طرح لأنك تطرح من صفر \end{RLtext} \eqref{eq:frame14} from \autocite{Flint2012} Mansour Series \begin{equation} f(x) = \dfrac{\sum\limits_{k=0}^{\infty} f_k (m) (g(m) -M)^k }{k!} \tag{3.3} \label{eq:frame15} \end{equation} \eqref{eq:frame15} \autocite{Hammad2013} Explaintaion of Mansour Series Let \begin{equation} f(x) = \sum_{k=0}^{\infty} S_k (g(m) -M)^k \textrm{ Where } S_k \textrm{ is a constant and } M \textrm{ is the value of the function } g(m) \textrm{ at variable } m \tag{3.4} \label{eq:frame16} \end{equation} \eqref{eq:frame16} \autocite{Hammad2013} \begin{equation} f_k(x) = \frac{f'_k(x)}{g'(m)} \textrm{ Where } f' \textrm{ and } g' \textrm{ are the functions first derivatives }\tag{3.5} \label{eq:frame17} \end{equation} \eqref{eq:frame17} \autocite{Hammad2013} In the papaer \autocite{Hammad2013} \href{https://www.researchgate.net/publication/277597486_Numerical_and_Analytical_Methods_in_Engineering_IRENA_If_fx_is_a_Function_in_gx_what_are_the_Coefficients_of_that_Function_A_New_Expansion_for_Analytic_Function_in_Standard_Form_fx_S_k0_S_k_gx_-_Mk/link/556e1db608aeab777226a184/download}{An article by Mansour Hammad} \begin{RLtext} في المثال الأول عند التعويض بقيمة للمتغيير \end{RLtext} \begin{equation} f(x) = g(x)^2 \textrm{ Where } g(x) = x^2 + x -6 \textrm{ The result is } f(x) = x^4 + 2 x^3 - 11 x^2 -12 x + 36 \tag{3.6} \label{eq:frame18} \end{equation} \eqref{eq:frame18} \autocite{Hammad2013} \begin{RLtext} نعوض عن قيمة المتغير ب 4 على سبيل المثال \end{RLtext} \begin{equation} f(x) = g(x)^2 \textrm{ Where } g(x) = 4^2 + 4 -6 = 16 + 4 -6 = 14^2 = 196 \textrm{ The result is } \tag{3.7} \label{eq:frame19} \end{equation} \eqref{eq:frame19} \begin{equation} f(x) = 4^4 + 2 4^3 - 11 4^2 -12 4 + 36 = 256 + 2(64) - 11(16) - 12(4) + 36 = 256 +128 -176 - 48 + 36 = 196 \textrm{ Both gives the same result } \tag{3.8} \label{eq:frame20} \end{equation} \eqref{eq:frame20} \begin{RLtext} الرابط بين الدالتين المذكورتين في المقالة هو أن أحدهما تساوي الدالة نفسها مضروبة في نفسها أكثر من مرة أي أنها من توليد القوى للدالة، بمعنى أخرى دالة تساوي الجذر التربيعي لدالة أخرى أو الجذر التكعيبي أو .... الخ. علماً أن المقالة في أخطأ أملائية في مقدمة المقالة المقطع الثاني إذاً - ثم كتبت من، ولم تصصح من مراجعي المقالة قبل النشر و لكن المادة العلمية عبارة عن طريقة جديدة مشابهه لطرق أخرى تنشر في مجلات علمية عديدة. الذي لم أجد له منطق هو جعل القيمة الإبتدائية للدالة في السلسلة مساوي لقيمة الدالة، فقيمة الدالة عند أول قيمة لها في السلسلة المجموعة برمز سيجما مساوي لقيمة الدالة كما في القاعدة 21 في المقالة. فهل هذا شرط لتطبيق السلسلة أن يكون الحد الأول مساوي للدالة نفسها، إذا كان كذلك فأن بقية الحدود عبارة عن زيادة لا حاجة لها. \end{RLtext} \begin{equation} f(x) = g(x)^2 or f(x) = g(x)^3 \tag{3.9} \label{eq:frame21} \end{equation} \eqref{eq:frame21} as in \autocite{Hammad2013} \newpage \section{Transmission Lines} \begin{RLtext} الموجات تمثل بدوال و الأصوات و الصور و الأفلام في الطبيعة عبارة عن إندماج موجات مع بعضها مما يؤدي إلى إندماج دوال مع بعضها، عند تمثيل هذه الأشياء الطبيعية على الحاسب فأننا نحتاج إلى تحويلها من صيغتها الطبيعية الغير منتهية في علم الجبر و الحساب تسمى متسلسلة لا نهائية إلى صيغة حاسوبية محدودة أو ما يسمى في علم الجبر و الحساب المجاميع المنتهية، هي تمثل المتسلسلة اللانهائيه بطريقة تقريبية. هذه الموجات تحتاج إلى وسط ينقلها من مكان إلى آخر و عند نقلها يتكون هناك ما يسمى بإرتداد الموجات عند النقل في خطوط النقل و أيضاً الموجات المتولدة من الموجات المغناطيسية المصاحبة للموجه الكهربائية في الحاسب فيكون لدينا عاملين دخيلين يغيرون في الموجه الأصلية الموجات المغناطيسية و إرتداد الموجات في خطوط النقل من المراجع الجيدة. \end{RLtext} \autocite{GuntherRoland2005} This is the course link: \href{https://ocw.mit.edu/courses/physics/8-02x-physics-ii-electricity-magnetism-with-an-experimental-focus-spring-2005/}{8.02x - MIT Physics II: Electricity and Magnetism. By Prof. Gunther M. Roland and Dr. Peter Dourmashkin in 2007}. \autocite{Lewin2002} Another course link with demonstration (note the link in the references list is the link in MIT University Website from Archive): \href{https://www.youtube.com/watch?v=rtlJoXxlSFE&list=PLyQSN7X0ro2314mKyUiOILaOC2hk6Pc3j}{Lectures by Walter Lewin for the course 8.02x - MIT Physics II: Electricity and Magnetism.}. \begin{RLtext} معادلة النواقل تمثل بدائرة فيها مقاومة مع ملف على التوالي متتالية مع مقاومة مع مكثف على التوازي \end{RLtext} The equations above used in transmission lines and wave propgation to solve their propsoed equation by expanding functions \begin{equation} \frac{d^2 V}{dt^2} =\frac{ 1}{\mathcal{L} C} \frac{d^2 V}{dx^2} \tag{4.1} \label{eq:frame22} \end{equation} \eqref{eq:frame22} as in \autocite{Kraus1999} \newpage \includegraphics{cables} \\* The picture of cables above from \autocite{Kraus1999} \newpage \begin{RLtext} بالنظر إلى الصورة نلاحظ أن المرجع ذكر أن الموصلات العصبية لا تفقد أي شيء من الموجات كما أنه لا يوجد أي موجه دخيلة على الموجات التي تنقلها. شاهدت قديماً في قناة BBC برنامج عن الموجات في العقل و كيف أنه عند أختيار لون معين أو عندما تحتار في إختيار شيء ينتج نشاط للعقل بالإمكان قياسه و معرفة في أي فص من فصوص العقل الأربعة شبية بالبرنامج أدناه \end{RLtext} \href{https://www.bbc.co.uk/programmes/p03gvnvn}{The brain of a world champion cup stacker} \begin{RLtext} فالإطباء بالتأكيد لديهم المعلومة الأكيدة حول نوعية الموجات إن كانت كهربائية الألكترومغناطيسية مصاحبة لها و تسبب نوع من التأثير على الموجه. إن كانت مغناطيسية فلها خواص المغناطيس من حيث الجذب إن كانت ضوئية فهي مزيج من الخواص. ربما تكون موجه معينة ذات طابع خاص و لكن بإلإمكان قياسها ب الإلكتروكارديو دايجرام مختصره إي سي جي يقيس الموجات الكهربائية كالموجة الضوئية بإلإمكان قياس الخاصية الكهربائيه بها. أو أن المرجع عندما ذكر أن الموجات العصبية غير مفقودة أو متداخلة أخطأ \end{RLtext} \begin{RLtext} ليتنا نجد مثل هذه الموصلات في الحاسب لأنه يحدث الخطأ عند نقل البيانات في الشبكة و الطريقة المستخدمة حالياً هي تصحيح الخطأ بمعادلات حسابية تضاف إلى الرسالة المرسلة لأنه لو أرسل مرسل رسالة عبر شبكة الحاسب ثم المستقبل رد هل أرسلت هذه الرسالة للتأكد ربما يكون هناك خطأ في الرسالة المرسلة أو الرسالة المرسلة من المستقبل و يحدث خطأ في الأرسال أو تأكد أن رسالة خاطئة تم أرسالها و تعتبر صحيحة أول الطرق المستخدمه هي إضافة رقم وحيد 0 أو 1 في نهاية الرسالة فإذا كان عدد الخانات التي تحمل الرقم 1 زوجي تكون الخانة الأخيرة 1 أما إن كان فردي تكون الخانة الأخيرة 0 . في هذه الحالة يتم رمي الرسالة و طلب إرسالها مره أخرى و هذه مكلف في عملية نقل البيانات حتى أوجدت معادلات تصحيح خطأ الرسالة و هي مستخدمة في أجزاء متفرقة في الحاسب غير نقل البيانات عبر الشبكة ، مبدأ تصحيح أخطأ البيانات \end{RLtext} \href{https://en.wikipedia.org/wiki/Parity_bit}{Parity bit} \\* \href{https://en.wikipedia.org/wiki/Cyclic_redundancy_check}{Cyclic redundancy check} \\* \href{http://www.cs.tau.ac.il/~amnon/Classes/2017-ECC/Lectures/Lecture2.pdf}{Error Correcting Codes} \\* \begin{RLtext} نحسب الإلترداد للموجات في الخطوط الناقلة بالمعادلة التالية \end{RLtext} \begin{equation} \frac{V_1}{V_0} =\frac{Z_L - Z_0}{Z_L + Z_0} = \rho_v \tag{4.2} \label{eq:frame23} \end{equation} $ \rho_v $ \begin{RLtext} وهذا هو معامل الإلترداد للموجات في الخطوط الناقلة للجهد الكهربائي \end{RLtext} \eqref{eq:frame23} as in \autocite{Kraus1999} \begin{equation} \textrm{ Where } V_0 = \mid V_0 \mid e^{\gamma x} \textrm{ The voltage of the signal that we sent } V_1 = \mid V_1 \mid e^{-\gamma x + j \zeta} \textrm{ The voltage of the signal that reflected }\tag{4.3} \label{eq:frame24} \end{equation} \eqref{eq:frame24} as in \autocite{Kraus1999} \\* $ x $ \begin{RLtext} الأكس عبارة عن مسافة الخط الناقل \end{RLtext} \begin{equation} \textrm{ Where } \gamma = \alpha + j \beta \textrm{ and } \zeta = \textrm{ is the phase shift at load L } \tag{4.4} \label{eq:frame25} \end{equation} \eqref{eq:frame25} as in \autocite{Kraus1999} \begin{equation} \textrm{ Where } \alpha = \operatorname{Re}(\sqrt{ZY}) \textrm{ and } \beta = \operatorname{Im}(\sqrt{ZY}) \tag{4.5} \label{eq:frame26} \end{equation} \eqref{eq:frame26} as in \autocite{Kraus1999} \begin{equation} \textrm{ Where } Z = R + j \omega \mathcal{L} \textrm{ and } Y = G + j \omega C \textrm{ G is the resistor parallel to the capcitor }\tag{4.6} \label{eq:frame26} \end{equation} \eqref{eq:frame26} as in \autocite{Kraus1999} \begin{RLtext} هذه الخواص تتغير بتغير المادة الناقلة ، لأن هذه الخواص تتحكم في معادلة القوة بين الشحنات الإلكترونية وهي أصغر وحدة في الموجة فمعامل السماح أو النفاذ أو التوصيل أدناه في مقام معادلة قوة التجاذب بين الشحنات و إن كبر المقام قلة قيمة قوة التجاذب بين الشحنات. \end{RLtext} \begin{equation} \epsilon_{r} \epsilon_{0} \textrm{ relative premittivity multiplied by vacuum premittivity } \tag{4.7} \label{eq:frame27} \end{equation} \begin{RLtext} عموماً معادلة مقاومة المواد هي \end{RLtext} \begin{equation} z_0 = \sqrt{\frac{\mu_{0}}{\epsilon_{0}}}\textrm{ mobility divided by premittivity } \tag{4.8} \label{eq:frame28} \end{equation} \eqref{eq:frame28} as in \autocite{Kraus1999} \\* \href{https://en.wikipedia.org/wiki/Relative_permittivity}{premittivity} \\* \href{https://en.wikipedia.org/wiki/Electron_mobility}{mobility} \begin{RLtext} لذلك تستخدم بعض المواد حسب الرغبة توصيل أم عزل و حسب الإرتداد في المسافة الموجودة فمثلاً الدوائر ذات التردد العالي و المسافة القصيرة مثل المعالجات قد تستخدم مواد مثل الذهب بدل النحاس \end{RLtext} \href{https://onlinelibrary.wiley.com/doi/pdf/10.1002/9781118936160.app2}{Material Properties} \begin{RLtext} المقاومة في طرف الإرسال و طرف الإستقبال يجب أن تكون قيمها متناسبه حسب المسافة بين الإرسال و الأستقبال لذلك نسمي المسافة أكس لكي نوجد قيم المقاومات لتتناسب \end{RLtext} \begin{equation} \textrm{ Where } Z_L \textrm{ and } Z_0 \textrm{ must match } \tag{4.9} \label{eq:frame29} \end{equation} \eqref{eq:frame29} as in \autocite{Kraus1999} \begin{RLtext} هناك معادلة لمقاومة المسافة و هي \end{RLtext} \begin{equation} \textrm{ } Z_x = Z_0 \frac{Z_L + Z_0 \tanh(\gamma x)}{Z_0 + Z_L \tanh(\gamma x)} \textrm{ } Z_0 \tag{4.10} \label{eq:frame30} \end{equation} \eqref{eq:frame30} as in \autocite{Kraus1999} \begin{RLtext} هذه المعادلة تم إستخلاصها من تحويل دوال الدوائر الجا و الجتا و الظا و الظتا و دوال الأسس و القوى مع السلاسل من معادلة التيار و فرق الجهد \end{RLtext} \begin{equation} \textrm{ Where } Z_x = \frac{V}{I} = \frac{\mid V_0 \mid}{\mid I_0 \mid} \phase{\delta} \left( \frac{e^{\gamma x} + \rho_{v} e^{-\gamma x}}{e^{\gamma x} - \rho_{v} e^{-\gamma x}} \right) \tag{4.11} \label{eq:frame31} \end{equation} \eqref{eq:frame31} as in \autocite{Kraus1999} \newpage \begin{frame}{References} \printbibliography \end{frame} \end{document} My BibTex File % Encoding: UTF-8 #Article{Hammad2013, author = {Mansour Hammad}, date = {2013-04-01}, journaltitle = {Numerical and Analytical Methods in Engineering (IRENA)}, title = {If f(x) is a Function in g(x), what are the Coefficients of that Function? A New Expansion for Analytic Function in Standard Form f(x) = Segma k=0 to infinity = S k (g(x) – M) to the power of k}, } #Misc{Lewin2002, author = {Walter Lewin}, title = {8.02X Physics II: Electricity and Magnetism, Spring 2002. Massachusetts Institute of Technology: MIT OpenCourseWare.}, howpublished = {https://www.youtube.com/channel/UCiEHVhv0SBMpP75JbzJShqw}, note = {Accessed on 2020-05-05}, url = {https://web.archive.org/web/20111229055249/http://ocw.mit.edu/courses/physics/8-02-electricity-and-magnetism-spring-2002}, month = mar, year = {2002}, } #Misc{GuntherRoland2005, author = {Gunther Roland, and Peter Dourmashkin}, title = {8.02X Physics II: Electricity and Magnetism with an Experimental Focus, Spring 2005. Massachusetts Institute of Technology: MIT OpenCourseWare.}, howpublished = {https://ocw.mit.edu/courses/physics/8-02x-physics-ii-electricity-magnetism-with-an-experimental-focus-spring-2005}, note = {Accessed on 2020-05-05}, url = {https://ocw.mit.edu/courses/physics/8-02x-physics-ii-electricity-magnetism-with-an-experimental-focus-spring-2005}, month = mar, year = {2005}, } #Book{Flint2012, author = {Flint, James and Hargreaves, Martin and Davison, Robert and Croft, Anthony}, date = {2012-12-04}, title = {Engineering Mathematics : A Foundation for Electronic, Electrical, Communications and Systems Engineers}, } #Book{Kraus1999, author = {John Daniel Kraus and Daniel A. Fleisch}, date = {1999-01-01}, title = {Electromagnetics with Applications}, } #Comment{jabref-meta: databaseType:biblatex;} The result is the reference page in this link (first reference) because the second is trying the BibTex file without Arabic Language https://drive.google.com/file/d/1RdBrj0wMEilmaT9ZxTCBQVT7zpleaIYz/view ŋŊßßþÞEngineering mathematics you can see the letters before Engineering
The problem comes from an interaction between arabtex and the apacase macro. If you make sure that all your references are already in the correct casing, you can switch off the macro like this: \documentclass{amsart} \usepackage[T1]{fontenc} \usepackage{arabtex} \usepackage[style=apa]{biblatex} \makeatletter \DeclareFieldFormat{apacase}{#1} \makeatother \begin{filecontents*}[overwrite]{\jobname.bib} #Book{Kraus1999, author = {John Daniel Kraus and Daniel A. Fleisch}, date = {1999-01-01}, title = {Electromagnetics with Applications}, } \end{filecontents*} \addbibresource{\jobname.bib} \begin{document} \autocite{Kraus1999} \printbibliography \end{document}
F# - Natural Sort Of Strings Containing Numbers
Is there an F# equivalent of Sorting for Humans: Natural Sort Order? For example, reproducing the following example: Actual (List.sort) : let strngLst = ["1-5"; "10-15"; "15-20"; "5-10"] Expected : let strngLst = ["1-5"; "5-10"; "10-15"; "15-20"] Please advise?
Based on the Python 3-liner in that article, I would do something like this: open System open System.Text.RegularExpressions let sortNicely l = let convert text = match Int32.TryParse(text) with | true, i -> Choice1Of2 i | false, _ -> Choice2Of2 text let alphanumKey key = Regex("([0-9]+)").Split(key) |> Array.map convert List.sortBy alphanumKey l The main difference is the use of the Choice type. The Python version cleverly uses dynamic typing in convert: Python always considers an int to be less than a string, so convert can return either an int or a string and sort will do what we want. But in F# we need to be more explicit. I used a discriminated union because it does what we want too: a value of the first case (Choice1Of2) is always less than a value of the second case (Choice2Of2).
Based on #matekus' comment, possibly the most correct solution is to port the AlphaNum sort to F#, so: let len = String.length let isnum (s: string) i = let c = s.Chars i c >= '0' && c <= '9' let chunk s f t = (f < len s) && (t < len s) && (isnum s f) = (isnum s t) let chunkto s f = let rec to_ s f e = if chunk s f e then to_ s f (e + 1) else e in to_ s f f let int_of_string str = let v = ref 0 if System.Int32.TryParse(str, v) then !v else 0 let alphanumcmp a b = let rec chunkcmp a ai b bi = let al, bl = len a, len b if ai >= al || bi >= bl then compare al bl else let ae, be = chunkto a ai, chunkto b bi let sa, sb = a.Substring(ai, (ae-ai)), b.Substring(bi, (be-bi)) let cmp = if isnum a ai && isnum b bi then compare (int_of_string sa) (int_of_string sb) else compare sa sb if cmp = 0 then chunkcmp a ae b be else cmp in chunkcmp a 0 b 0 type AlphanumComparer() = interface System.Collections.IComparer with member this.Compare(x, y) = alphanumcmp (x.ToString()) (y.ToString()) Test: let names = [ "1000X Radonius Maximus"; "10X Radonius"; "200X Radonius"; "20X Radonius"; "20X Radonius Prime"; "30X Radonius"; "40X Radonius"; "Allegia 50 Clasteron"; "Allegia 500 Clasteron"; "Allegia 51 Clasteron"; "Allegia 51B Clasteron"; "Allegia 52 Clasteron"; "Allegia 60 Clasteron"; "Alpha 100"; "Alpha 2"; "Alpha 200"; "Alpha 2A"; "Alpha 2A-8000"; "Alpha 2A-900"; "Callisto Morphamax"; "Callisto Morphamax 500"; "Callisto Morphamax 5000"; "Callisto Morphamax 600"; "Callisto Morphamax 700"; "Callisto Morphamax 7000"; "Callisto Morphamax 7000 SE";"Callisto Morphamax 7000 SE2"; "QRS-60 Intrinsia Machine"; "QRS-60F Intrinsia Machine"; "QRS-62 Intrinsia Machine"; "QRS-62F Intrinsia Machine"; "Xiph Xlater 10000"; "Xiph Xlater 2000"; "Xiph Xlater 300"; "Xiph Xlater 40"; "Xiph Xlater 5"; "Xiph Xlater 50"; "Xiph Xlater 500"; "Xiph Xlater 5000"; "Xiph Xlater 58" ];; names |> List.sortWith alphanumcmp |> printf "%A" Results: ["10X Radonius"; "20X Radonius"; "20X Radonius Prime"; "30X Radonius"; "40X Radonius"; "200X Radonius"; "1000X Radonius Maximus"; "Allegia 50 Clasteron"; "Allegia 51 Clasteron"; "Allegia 51B Clasteron"; "Allegia 52 Clasteron"; "Allegia 60 Clasteron"; "Allegia 500 Clasteron"; "Alpha 2"; "Alpha 2A"; "Alpha 2A-900"; "Alpha 2A-8000"; "Alpha 100"; "Alpha 200"; "Callisto Morphamax"; "Callisto Morphamax 500"; "Callisto Morphamax 600"; "Callisto Morphamax 700"; "Callisto Morphamax 5000"; "Callisto Morphamax 7000"; "Callisto Morphamax 7000 SE"; "Callisto Morphamax 7000 SE2"; "QRS-60 Intrinsia Machine"; "QRS-60F Intrinsia Machine"; "QRS-62 Intrinsia Machine"; "QRS-62F Intrinsia Machine"; "Xiph Xlater 5"; "Xiph Xlater 40"; "Xiph Xlater 50"; "Xiph Xlater 58"; "Xiph Xlater 300"; "Xiph Xlater 500"; "Xiph Xlater 2000"; "Xiph Xlater 5000"; "Xiph Xlater 10000"]val it : unit = ()
logstash Twitter error when geo_enable=true
I am trying to connect logstash to twitter. All the twitter that user.geo_enabled=false parsed ok, but of the other hand if user.geo_enabled=true I receive this error: Failed action. {:status=>400, :action=>["index", {:_id=>nil, :_index=>"twitter", :_type=>"logs", :_routing=>nil}, #<LogStash::Event:0xb1b69ba #metadata_accessors=#<LogStash::Util::Accessors:0x74b553ef #store={}, #lut={}>, #cancelled=false, #data={"created_at"=>"Wed Jul 06 16:15:26 +0000 2016", "id"=>750724847626493953, "id_str"=>"750724847626493953", "text"=>"#HillaryClinton I would never vote for you", "source"=>"Twitter for Android", "truncated"=>false, "in_reply_to_status_id"=>nil, "in_reply_to_status_id_str"=>nil, "in_reply_to_user_id"=>1339835893, "in_reply_to_user_id_str"=>"1339835893", "in_reply_to_screen_name"=>"HillaryClinton", "user"=>{"id"=>772001468, "id_str"=>"772001468", "name"=>"charles c hutchison", "screen_name"=>"49_mail", "location"=>nil, "url"=>nil, "description"=>nil, "protected"=>false, "verified"=>false, "followers_count"=>8, "friends_count"=>99, "listed_count"=>0, "favourites_count"=>8, "statuses_count"=>176, "created_at"=>"Tue Aug 21 18:22:06 +0000 2012", "utc_offset"=>nil, "time_zone"=>nil, "geo_enabled"=>true, "lang"=>"en", "contributors_enabled"=>false, "is_translator"=>false, "profile_background_color"=>"C0DEED", "profile_background_image_url"=>"http://abs.twimg.com/images/themes/theme1/bg.png", "profile_background_image_url_https"=>"https://abs.twimg.com/images/themes/theme1/bg.png", "profile_background_tile"=>false, "profile_link_color"=>"0084B4", "profile_sidebar_border_color"=>"C0DEED", "profile_sidebar_fill_color"=>"DDEEF6", "profile_text_color"=>"333333", "profile_use_background_image"=>true, "profile_image_url"=>"http://abs.twimg.com/sticky/default_profile_images/default_profile_0_normal.png", "profile_image_url_https"=>"https://abs.twimg.com/sticky/default_profile_images/default_profile_0_normal.png", "default_profile"=>true, "default_profile_image"=>true, "following"=>nil, "follow_request_sent"=>nil, "notifications"=>nil}, "geo"=>{"type"=>"Point", "coordinates"=>[#<BigDecimal:6d26d63b,'0.384274583E2',9(12)>, #<BigDecimal:43f314b6,'-0.823958636E2',9(12)>]}, "coordinates"=>{"type"=>"Point", "coordinates"=>[#<BigDecimal:669bf464,'-0.823958636E2',9(12)>, #<BigDecimal:3d160aa5,'0.384274583E2',9(12)>]}, "place"=>{"id"=>"e4197a23034fa912", "url"=>"https://api.twitter.com/1.1/geo/id/e4197a23034fa912.json", "place_type"=>"city", "name"=>"Huntington", "full_name"=>"Huntington, WV", "country_code"=>"US", "country"=>"United States", "bounding_box"=>{"type"=>"Polygon", "coordinates"=>[[[#<BigDecimal:4feaddd3,'-0.82530433E2',8(12)>, #<BigDecimal:5438cd7c,'0.38375981E2',8(12)>], [#<BigDecimal:413b49ac,'-0.82530433E2',8(12)>, #<BigDecimal:58a6101d,'0.38439347E2',8(12)>], [#<BigDecimal:445e692e,'-0.82349236E2',8(12)>, #<BigDecimal:5f332e20,'0.38439347E2',8(12)>], [#<BigDecimal:46c19531,'-0.82349236E2',8(12)>, #<BigDecimal:71e183de,'0.38375981E2',8(12)>]]]}, "attributes"=>{}}, "contributors"=>nil, "is_quote_status"=>false, "retweet_count"=>0, "favorite_count"=>0, "entities"=>{"hashtags"=>[], "urls"=>[], "user_mentions"=>[{"screen_name"=>"HillaryClinton", "name"=>"Hillary Clinton", "id"=>1339835893, "id_str"=>"1339835893", "indices"=>[0, 15]}], "symbols"=>[]}, "favorited"=>false, "retweeted"=>false, "filter_level"=>"low", "lang"=>"en", "timestamp_ms"=>"1467821726124", "#version"=>"1", "#timestamp"=>"2016-07-06T16:15:26.000Z"}, #metadata={}, #accessors=#<LogStash::Util::Accessors:0x40cb306f #store={"created_at"=>"Wed Jul 06 16:15:26 +0000 2016", "id"=>750724847626493953, "id_str"=>"750724847626493953", "text"=>"#HillaryClinton I would never vote for you", "source"=>"Twitter for Android", "truncated"=>false, "in_reply_to_status_id"=>nil, "in_reply_to_status_id_str"=>nil, "in_reply_to_user_id"=>1339835893, "in_reply_to_user_id_str"=>"1339835893", "in_reply_to_screen_name"=>"HillaryClinton", "user"=>{"id"=>772001468, "id_str"=>"772001468", "name"=>"charles c hutchison", "screen_name"=>"49_mail", "location"=>nil, "url"=>nil, "description"=>nil, "protected"=>false, "verified"=>false, "followers_count"=>8, "friends_count"=>99, "listed_count"=>0, "favourites_count"=>8, "statuses_count"=>176, "created_at"=>"Tue Aug 21 18:22:06 +0000 2012", "utc_offset"=>nil, "time_zone"=>nil, "geo_enabled"=>true, "lang"=>"en", "contributors_enabled"=>false, "is_translator"=>false, "profile_background_color"=>"C0DEED", "profile_background_image_url"=>"http://abs.twimg.com/images/themes/theme1/bg.png", "profile_background_image_url_https"=>"https://abs.twimg.com/images/themes/theme1/bg.png", "profile_background_tile"=>false, "profile_link_color"=>"0084B4", "profile_sidebar_border_color"=>"C0DEED", "profile_sidebar_fill_color"=>"DDEEF6", "profile_text_color"=>"333333", "profile_use_background_image"=>true, "profile_image_url"=>"http://abs.twimg.com/sticky/default_profile_images/default_profile_0_normal.png", "profile_image_url_https"=>"https://abs.twimg.com/sticky/default_profile_images/default_profile_0_normal.png", "default_profile"=>true, "default_profile_image"=>true, "following"=>nil, "follow_request_sent"=>nil, "notifications"=>nil}, "geo"=>{"type"=>"Point", "coordinates"=>[#<BigDecimal:6d26d63b,'0.384274583E2',9(12)>, #<BigDecimal:43f314b6,'-0.823958636E2',9(12)>]}, "coordinates"=>{"type"=>"Point", "coordinates"=>[#<BigDecimal:669bf464,'-0.823958636E2',9(12)>, #<BigDecimal:3d160aa5,'0.384274583E2',9(12)>]}, "place"=>{"id"=>"e4197a23034fa912", "url"=>"https://api.twitter.com/1.1/geo/id/e4197a23034fa912.json", "place_type"=>"city", "name"=>"Huntington", "full_name"=>"Huntington, WV", "country_code"=>"US", "country"=>"United States", "bounding_box"=>{"type"=>"Polygon", "coordinates"=>[[[#<BigDecimal:4feaddd3,'-0.82530433E2',8(12)>, #<BigDecimal:5438cd7c,'0.38375981E2',8(12)>], [#<BigDecimal:413b49ac,'-0.82530433E2',8(12)>, #<BigDecimal:58a6101d,'0.38439347E2',8(12)>], [#<BigDecimal:445e692e,'-0.82349236E2',8(12)>, #<BigDecimal:5f332e20,'0.38439347E2',8(12)>], [#<BigDecimal:46c19531,'-0.82349236E2',8(12)>, #<BigDecimal:71e183de,'0.38375981E2',8(12)>]]]}, "attributes"=>{}}, "contributors"=>nil, "is_quote_status"=>false, "retweet_count"=>0, "favorite_count"=>0, "entities"=>{"hashtags"=>[], "urls"=>[], "user_mentions"=>[{"screen_name"=>"HillaryClinton", "name"=>"Hillary Clinton", "id"=>1339835893, "id_str"=>"1339835893", "indices"=>[0, 15]}], "symbols"=>[]}, "favorited"=>false, "retweeted"=>false, "filter_level"=>"low", "lang"=>"en", "timestamp_ms"=>"1467821726124", "#version"=>"1", "#timestamp"=>"2016-07-06T16:15:26.000Z"}, #lut={"in-reply-to"=>[{"created_at"=>"Wed Jul 06 16:15:26 +0000 2016", "id"=>750724847626493953, "id_str"=>"750724847626493953", "text"=>"#HillaryClinton I would never vote for you", "source"=>"Twitter for Android", "truncated"=>false, "in_reply_to_status_id"=>nil, "in_reply_to_status_id_str"=>nil, "in_reply_to_user_id"=>1339835893, "in_reply_to_user_id_str"=>"1339835893", "in_reply_to_screen_name"=>"HillaryClinton", "user"=>{"id"=>772001468, "id_str"=>"772001468", "name"=>"charles c hutchison", "screen_name"=>"49_mail", "location"=>nil, "url"=>nil, "description"=>nil, "protected"=>false, "verified"=>false, "followers_count"=>8, "friends_count"=>99, "listed_count"=>0, "favourites_count"=>8, "statuses_count"=>176, "created_at"=>"Tue Aug 21 18:22:06 +0000 2012", "utc_offset"=>nil, "time_zone"=>nil, "geo_enabled"=>true, "lang"=>"en", "contributors_enabled"=>false, "is_translator"=>false, "profile_background_color"=>"C0DEED", "profile_background_image_url"=>"http://abs.twimg.com/images/themes/theme1/bg.png", "profile_background_image_url_https"=>"https://abs.twimg.com/images/themes/theme1/bg.png", "profile_background_tile"=>false, "profile_link_color"=>"0084B4", "profile_sidebar_border_color"=>"C0DEED", "profile_sidebar_fill_color"=>"DDEEF6", "profile_text_color"=>"333333", "profile_use_background_image"=>true, "profile_image_url"=>"http://abs.twimg.com/sticky/default_profile_images/default_profile_0_normal.png", "profile_image_url_https"=>"https://abs.twimg.com/sticky/default_profile_images/default_profile_0_normal.png", "default_profile"=>true, "default_profile_image"=>true, "following"=>nil, "follow_request_sent"=>nil, "notifications"=>nil}, "geo"=>{"type"=>"Point", "coordinates"=>[#<BigDecimal:6d26d63b,'0.384274583E2',9(12)>, #<BigDecimal:43f314b6,'-0.823958636E2',9(12)>]}, "coordinates"=>{"type"=>"Point", "coordinates"=>[#<BigDecimal:669bf464,'-0.823958636E2',9(12)>, #<BigDecimal:3d160aa5,'0.384274583E2',9(12)>]}, "place"=>{"id"=>"e4197a23034fa912", "url"=>"https://api.twitter.com/1.1/geo/id/e4197a23034fa912.json", "place_type"=>"city", "name"=>"Huntington", "full_name"=>"Huntington, WV", "country_code"=>"US", "country"=>"United States", "bounding_box"=>{"type"=>"Polygon", "coordinates"=>[[[#<BigDecimal:4feaddd3,'-0.82530433E2',8(12)>, #<BigDecimal:5438cd7c,'0.38375981E2',8(12)>], [#<BigDecimal:413b49ac,'-0.82530433E2',8(12)>, #<BigDecimal:58a6101d,'0.38439347E2',8(12)>], [#<BigDecimal:445e692e,'-0.82349236E2',8(12)>, #<BigDecimal:5f332e20,'0.38439347E2',8(12)>], [#<BigDecimal:46c19531,'-0.82349236E2',8(12)>, #<BigDecimal:71e183de,'0.38375981E2',8(12)>]]]}, "attributes"=>{}}, "contributors"=>nil, "is_quote_status"=>false, "retweet_count"=>0, "favorite_count"=>0, "entities"=>{"hashtags"=>[], "urls"=>[], "user_mentions"=>[{"screen_name"=>"HillaryClinton", "name"=>"Hillary Clinton", "id"=>1339835893, "id_str"=>"1339835893", "indices"=>[0, 15]}], "symbols"=>[]}, "favorited"=>false, "retweeted"=>false, "filter_level"=>"low", "lang"=>"en", "timestamp_ms"=>"1467821726124", "#version"=>"1", "#timestamp"=>"2016-07-06T16:15:26.000Z"}, "in-reply-to"], "type"=>[{"created_at"=>"Wed Jul 06 16:15:26 +0000 2016", "id"=>750724847626493953, "id_str"=>"750724847626493953", "text"=>"#HillaryClinton I would never vote for you", "source"=>"Twitter for Android", "truncated"=>false, "in_reply_to_status_id"=>nil, "in_reply_to_status_id_str"=>nil, "in_reply_to_user_id"=>1339835893, "in_reply_to_user_id_str"=>"1339835893", "in_reply_to_screen_name"=>"HillaryClinton", "user"=>{"id"=>772001468, "id_str"=>"772001468", "name"=>"charles c hutchison", "screen_name"=>"49_mail", "location"=>nil, "url"=>nil, "description"=>nil, "protected"=>false, "verified"=>false, "followers_count"=>8, "friends_count"=>99, "listed_count"=>0, "favourites_count"=>8, "statuses_count"=>176, "created_at"=>"Tue Aug 21 18:22:06 +0000 2012", "utc_offset"=>nil, "time_zone"=>nil, "geo_enabled"=>true, "lang"=>"en", "contributors_enabled"=>false, "is_translator"=>false, "profile_background_color"=>"C0DEED", "profile_background_image_url"=>"http://abs.twimg.com/images/themes/theme1/bg.png", "profile_background_image_url_https"=>"https://abs.twimg.com/images/themes/theme1/bg.png", "profile_background_tile"=>false, "profile_link_color"=>"0084B4", "profile_sidebar_border_color"=>"C0DEED", "profile_sidebar_fill_color"=>"DDEEF6", "profile_text_color"=>"333333", "profile_use_background_image"=>true, "profile_image_url"=>"http://abs.twimg.com/sticky/default_profile_images/default_profile_0_normal.png", "profile_image_url_https"=>"https://abs.twimg.com/sticky/default_profile_images/default_profile_0_normal.png", "default_profile"=>true, "default_profile_image"=>true, "following"=>nil, "follow_request_sent"=>nil, "notifications"=>nil}, "geo"=>{"type"=>"Point", "coordinates"=>[#<BigDecimal:6d26d63b,'0.384274583E2',9(12)>, #<BigDecimal:43f314b6,'-0.823958636E2',9(12)>]}, "coordinates"=>{"type"=>"Point", "coordinates"=>[#<BigDecimal:669bf464,'-0.823958636E2',9(12)>, #<BigDecimal:3d160aa5,'0.384274583E2',9(12)>]}, "place"=>{"id"=>"e4197a23034fa912", "url"=>"https://api.twitter.com/1.1/geo/id/e4197a23034fa912.json", "place_type"=>"city", "name"=>"Huntington", "full_name"=>"Huntington, WV", "country_code"=>"US", "country"=>"United States", "bounding_box"=>{"type"=>"Polygon", "coordinates"=>[[[#<BigDecimal:4feaddd3,'-0.82530433E2',8(12)>, #<BigDecimal:5438cd7c,'0.38375981E2',8(12)>], [#<BigDecimal:413b49ac,'-0.82530433E2',8(12)>, #<BigDecimal:58a6101d,'0.38439347E2',8(12)>], [#<BigDecimal:445e692e,'-0.82349236E2',8(12)>, #<BigDecimal:5f332e20,'0.38439347E2',8(12)>], [#<BigDecimal:46c19531,'-0.82349236E2',8(12)>, #<BigDecimal:71e183de,'0.38375981E2',8(12)>]]]}, "attributes"=>{}}, "contributors"=>nil, "is_quote_status"=>false, "retweet_count"=>0, "favorite_count"=>0, "entities"=>{"hashtags"=>[], "urls"=>[], "user_mentions"=>[{"screen_name"=>"HillaryClinton", "name"=>"Hillary Clinton", "id"=>1339835893, "id_str"=>"1339835893", "indices"=>[0, 15]}], "symbols"=>[]}, "favorited"=>false, "retweeted"=>false, "filter_level"=>"low", "lang"=>"en", "timestamp_ms"=>"1467821726124", "#version"=>"1", "#timestamp"=>"2016-07-06T16:15:26.000Z"}, "type"]}>>], :response=>{"create"=>{"_index"=>"twitter", "_type"=>"logs", "_id"=>"AVXA_h0IgT1Xitpna0uT", "status"=>400, "error"=>{"type"=>"mapper_parsing_exception", "reason"=>"failed to parse", "caused_by"=>{"type"=>"illegal_state_exception", "reason"=>"Mixing up field types: class org.elasticsearch.index.mapper.core.DoubleFieldMapper$DoubleFieldType != class org.elasticsearch.index.mapper.geo.BaseGeoPointFieldMapper$GeoPointFieldType on field coordinates.coordinates"}}}}, :level=>:warn} I think that the relevent line is {"create"=>{"_index"=>"twitter", "_type"=>"logs", "_id"=>"AVXA_h0IgT1Xitpna0uT", "status"=>400, "error"=>{"type"=>"mapper_parsing_exception", "reason"=>"failed to parse", "caused_by"=>{"type"=>"illegal_state_exception", "reason"=>"Mixing up field types: class org.elasticsearch.index.mapper.core.DoubleFieldMapper$DoubleFieldType != class org.elasticsearch.index.mapper.geo.BaseGeoPointFieldMapper$GeoPointFieldType on field coordinates.coordinates"}}}}, :level=>:warn} my template is : { "template": "twitter", "order": 1, "settings": { "number_of_shards": 1 }, "mappings": { "tweet": { "_all": { "enabled": false }, "properties": { "coordinates": { "properties": { "coordinates": { "type": "geo_point" }, "type": { "type": "string" } } } } } } } What can be the problem?? thanks.
The problem is that the field coordinates.coordinates in ES expect a type of data which is not the type received. A solution would be to modify the template, removing the coordinates type. Then you delete your index and reindex your data. In that case the expected type of coordinates.coordinates will be dependent on the data inserted. That should resolve the problem.