Platform
Resources
Pricing
Sign in
Get started
Vinícius Mello
Workspace
Fork
Published
By
Vinícius Mello
Edited
Aug 27, 2018
Insert cell
Insert cell
m
=
50
Insert cell
n
=
20
Insert cell
a
=
{
var
a
=
zeros
(
[
m
,
n
]
)
;
fill
(
a
,
(
i
,
j
)
=>
(
Math
.
random
(
)
<
0.6
?
1
:
0
)
)
;
return
a
;
}
Insert cell
show
(
a
.
transpose
(
0
,
1
)
)
Insert cell
d
=
{
var
d
=
zeros
(
[
n
]
)
;
fill
(
d
,
(
i
)
=>
(
1.0
/
(
blas1
.
asum
(
a
.
pick
(
null
,
i
)
)
)
)
)
;
return
d
;
}
Insert cell
score0
=
{
var
d
=
zeros
(
[
m
]
)
;
fill
(
d
,
(
i
)
=>
(
blas1
.
asum
(
a
.
pick
(
i
,
null
)
)
/
n
*
100
)
)
;
return
d
;
}
Insert cell
weight
=
{
var
i
=
0
;
var
sc
=
zeros
(
[
m
]
)
;
var
we
=
zeros
(
[
n
]
)
;
fill
(
we
,
(
i
)
=>
100
/
n
)
;
while
(
i
<
1000
)
{
gemv
(
1
,
a
,
we
,
0
,
sc
)
;
gemv
(
1
,
a
.
transpose
(
1
,
0
)
,
sc
,
0
,
we
)
;
cprod
(
d
,
we
)
;
let
s
=
blas1
.
asum
(
we
)
;
blas1
.
scal
(
1
/
s
*
100
,
we
)
;
yield
we
;
i
++
;
}
}
Insert cell
score
=
{
var
sc
=
zeros
(
[
m
]
)
;
gemv
(
1
,
a
,
weight
,
0
,
sc
)
;
return
sc
;
}
Insert cell
ndarray
=
require
(
"https://bundle.run/ndarray"
)
Insert cell
blas1
=
require
(
"https://bundle.run/ndarray-blas-level1"
)
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Purpose-built for displays of data
Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Try it for free
Learn more
Fork
View
Export
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
m
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
n
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
a
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
d
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
score0
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
weight
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
score
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
ndarray
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
blas1
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
gemv
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
cwise
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
cprod
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
fill
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
zeros
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
show
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML