Ask Your Question
1

Evaluation of Boolean function at a point.

asked 2021-05-27 00:41:57 +0100

Dodul gravatar image

updated 2021-05-27 12:19:04 +0100

Hello! I am struggling with the following code. I have a random Boolean function, f, in n variables (n varies) and also a set of n tuples which is generated from some other code. Now I want to evaluate the function f at one of the points, i.e., I want to determine f(a). But a, being of the form say a = [random.randit(0,1) for i in range(n)], is not being taken as an input for f. Moreover changing a to tuple(a) or list(a) neither works. I am writing down the problem in the following code:

n = 4

R = BooleanPolynomialRing(n,['x%d'%i for i in range(n)])

f = R.random_element()

print(f)

import random

a = [random.randint(0,1) for i in range(n)]

print(f(a))

Upon running this shows the error:

"Number of arguments is different from the number of variables of parent ring."

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2021-05-27 12:05:08 +0100

rburing gravatar image

A single argument consisting of a list or a tuple is not accepted as input. Only keyword arguments or n positional arguments (but not both) are accepted. To pass n positional arguments, you can do f(*a).

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2021-05-27 00:37:22 +0100

Seen: 248 times

Last updated: May 27 '21