# bakant's profile - activity

2013-10-23 23:57:31 -0600 asked a question Social Network Analysis

I would like to know if there is any features in Sage to analise social networks like:

## Social Network Analysis

Drawing on Mathematica's strong graph and network capabilities, Mathematica 9 introduces a complete and rich set of state-of-the art social network analysis functions. Access to social networks from a variety of sources, including directly from social media sites, and high level functions for community detection, cohesive groups, centrality, and similarity measures make performing network analysis tasks easier and more flexible than ever before.

I mean exactly anlysis of the real networks not graph theory.

2013-07-24 21:57:42 -0600 commented question Maxima in online notebook

The problem was solved. Now it returns the plot.

2013-07-23 08:20:58 -0600 asked a question Maxima in online notebook

Is there any way to show maxima graphs in the online Sage notebook?

maxima('plot2d(sin(x),[x,-7,7])')


shows nothing.

maxima('plot2d(sin(x),[x,-7,7],[plot_format, gnuplot],[gnuplot_term, svg],[gnuplot_out_file, "plot2d.svg"])')


{}plot2d.svg{}

2013-07-18 20:38:12 -0600 asked a question Linear diophantine equations

Is there any basic function in Sage to solve linear diophantine equations?

2013-07-16 03:07:26 -0600 asked a question Save file from online notebook

Is it possible to save plot to svg file from online Sage notebook?

2013-07-05 20:48:46 -0600 commented answer Model of polynomial with integer coefficients

Thanks a lot! That's it!

2013-07-05 20:29:29 -0600 marked best answer Model of polynomial with integer coefficients

So, we want to find a polynomial P with integer coefficients and a fixed degree that minimizes max(abs(P(point)-value) where the max is for all (point,value) in mydata.

With such a formulation, we see that there is a possibility with integer programming. But the abs() function is not linear. So we add a error variable (to be minimized) such that both linear inequalities P(point)-value <= error and value-P(point) <= error hold.

Putting all together, we get:

sage: degree = 3
sage: mydata = [(0,0),(1,5),(2,1),(4,6)]

sage: p = MixedIntegerLinearProgram(maximization=False)
sage: a = p.new_variable(integer=True)
sage: error = p.new_variable(real=True)
sage: p.set_objective(error)

sage: for point,value in mydata:
....:     p.add_constraint(sum(a[d]*point^d for d in range(degree+1)) - value <= error)
....:     p.add_constraint(value - sum(a[d]*point^d for d in range(degree+1)) <= error)

sage: error = p.solve()

sage: dico = p.get_values(a)

sage: R = PolynomialRing(ZZ, 'x')
sage: P = sum(R(v*x^d) for d,v in dico.items())

sage: P
x + 2
sage: error
3.0


If you want to find the best polynomial with real entries, you just have to replace the two lines

sage: a = p.new_variable(integer=True)
sage: R = PolynomialRing(ZZ, 'x')


by

sage: a = p.new_variable(real=True)
sage: R = PolynomialRing(RR, 'x')


In our example, you will get :

sage: P
0.500000000000000*x + 2.25000000000000
sage: error
2.25


For huge data, it should also be possible to approximate the best solution with lattice reduction algorithms.

2013-07-05 03:34:25 -0600 commented answer Model of polynomial with integer coefficients

Thanks, but I meant that I want to find polyinomial with integer coefficients which will approximate my date by the best way, that is the distance from points in "mydata" to graph of the polyinomial will be the least. It is possible to look at this another way, lets polynomial is the function of its coefficients. It is easy to write function which will find sum of distances from graph of the polynomial to each point, then I need to find ArgMin of this function. Is there function in Sage like "ArgMin[{f, cons}, {x, y, ...}, dom] gives a position at which f is minimized over the domain dom, typically Reals or Integers." in Mathematica? It is important that I can choose from Integers and Reals/

2013-07-04 21:24:14 -0600 asked a question Model of polynomial with integer coefficients

Can Sage find fit to the data in form of the polynomial with integer coefficients? I mean that I want to find polyinomial with integer coefficients which will approximate my date by the best way, that is the distance from points in "mydata" to graph of the polyinomial will be the least.
Now I have:

...
mydata = [[A[i],B[i]] for i in range(0,len(A))]
var('a,b,c,x,t')
def intPol(a,b,c,x):
f=a*x^2 + b*x + c
return f
myfit = find_fit(mydata,intPol,parameters = [a, b, c], variables = [x],solution_dict=True)


Is there any way to approximate my data by same polynomial without models? Sorry for my English(