fandaal: (Default)
[personal profile] fandaal
ну вот и пригождается этот блог.
жж висит с переменным успехом уже долго..
#classification
import math
class Predmet:
    def __init__():
        return
class Category(Predmet):
    pass
def Proto():#cathegory prototype calculation
    return
def Exemplar(m,n):#n is number of attributes, m is a range of attribute
    import random
    a=[]
    for i in range(n):
        a.append(random.randint(0,m))
    return a
def Distance(d,f):#calculates the distance between 2 exemplars
    dis=0
    for i in range(len(d)-1):
        dlin=(d[i]-f[i])*(d[i]-f[i])
        dis=dis+dlin
    return math.sqrt(dis)
def AverageDis(vid):
    aw=0
    for i in range(len(vid)-1):
        aw=aw+Distance(vid[i],vid[i+1])
    return aw/(len(vid))
        
c=3
cat=[]
klas=[]
while c>0:
    b=Exemplar(5,10)
    print(b)
    c=input()
    c=int(c)
    if c==1:
        cat.append(b)
    if c==2:
            klas.append(b)
print('first category')
print(cat)
print('second category')
print(klas)
print('distances between first category first two objects')
print(Distance(cat[0],cat[1]))
print('Average distances between 1 cat objects')

    
From:
Anonymous( )Anonymous This account has disabled anonymous posting.
OpenID( )OpenID You can comment on this post while signed in with an account from many other sites, once you have confirmed your email address. Sign in using OpenID.
User
Account name:
Password:
If you don't have an account you can create one now.
Subject:
HTML doesn't work in the subject.

Message:

 
Notice: This account is set to log the IP addresses of everyone who comments.
Links will be displayed as unclickable URLs to help prevent spam.

Profile

fandaal: (Default)
fandaal

August 2011

S M T W T F S
 123456
78910111213
14151617181920
21222324252627
28 293031   

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Sep. 26th, 2017 01:47 am
Powered by Dreamwidth Studios